-
Notifications
You must be signed in to change notification settings - Fork 3
スポンサー(パートナー)ページの実装 #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
スポンサー(パートナー)ページの実装 #170
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
328ed35
feat: partner page
snaka 0091001
SAMPLE json / images
snaka ab33e3c
fix: `desc` to `description`
snaka 166917d
fix: simplify prop type name
snaka 2293898
fix: `desc` to `description`
snaka ab2f842
fix: extract params from context
snaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"platinum": [ | ||
{ | ||
"id": "platinum-1", | ||
"name": "株式会社 プラチナワン", | ||
"description": "Sea tempor feugait et elit et sanctus kasd eirmod. Praesent amet qui iriure ipsum exerci clita sit et volutpat eos rebum elitr. Autem laoreet labore lorem commodo. At aliquyam sit est kasd diam nostrud adipiscing nonumy sit duo dolores in dolor suscipit. Consetetur quis ea dolore sed in magna facilisi delenit. Erat kasd at sea ex takimata feugiat. Eos tempor diam delenit adipiscing takimata. Autem diam accusam. Et nisl sanctus kasd ipsum diam odio nonumy amet. Nisl sed amet sea et clita autem nostrud dolore autem euismod invidunt. Augue blandit tempor no dolore. Et sit no duo. Diam takimata lobortis erat eos consetetur dolor ut ea amet justo eum eos invidunt ipsum nonummy justo ut." | ||
}, | ||
{ | ||
"id": "platinum-2", | ||
"name": "株式会社 プラチナツー", | ||
"description": "Sea tempor feugait et elit et sanctus kasd eirmod. Praesent amet qui iriure ipsum exerci clita sit et volutpat eos rebum elitr. Autem laoreet labore lorem commodo. At aliquyam sit est kasd diam nostrud adipiscing nonumy sit duo dolores in dolor suscipit. Consetetur quis ea dolore sed in magna facilisi delenit. Erat kasd at sea ex takimata feugiat. Eos tempor diam delenit adipiscing takimata. Autem diam accusam. Et nisl sanctus kasd ipsum diam odio nonumy amet. Nisl sed amet sea et clita autem nostrud dolore autem euismod invidunt. Augue blandit tempor no dolore. Et sit no duo. Diam takimata lobortis erat eos consetetur dolor ut ea amet justo eum eos invidunt ipsum nonummy justo ut." | ||
} | ||
], | ||
"gold": [ | ||
{ | ||
"id": "gold-1", | ||
"name": "株式会社 ゴールドワン", | ||
"description": "Hendrerit duis te vel et possim et feugiat. Dolores clita lorem quis nibh no takimata dolores invidunt vero rebum tempor. Nibh sanctus accusam commodo facilisis eirmod no at consetetur feugiat erat et dolores justo labore vel vel et. Et tation euismod vel duo assum ipsum takimata est et vulputate no dolore." | ||
}, | ||
{ | ||
"id": "gold-2", | ||
"name": "株式会社 ゴールド・ツー", | ||
"description": "Hendrerit duis te vel et possim et feugiat. Dolores clita lorem quis nibh no takimata dolores invidunt vero rebum tempor. Nibh sanctus accusam commodo facilisis eirmod no at consetetur feugiat erat et dolores justo labore vel vel et. Et tation euismod vel duo assum ipsum takimata est et vulputate no dolore." | ||
} | ||
], | ||
"silver": [ | ||
"silver-1", | ||
"silver-2", | ||
"silver-3", | ||
"silver-4", | ||
"silver-5", | ||
"silver-6", | ||
"silver-7", | ||
"silver-8" | ||
], | ||
"bronze": [ | ||
"bronze-1", | ||
"bronze-2", | ||
"bronze-3", | ||
"bronze-4", | ||
"bronze-5", | ||
"bronze-6", | ||
"bronze-7", | ||
"bronze-8", | ||
"bronze-9", | ||
"bronze-10", | ||
"bronze-11", | ||
"bronze-12" | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ export const Layout: NextPage<LayoutProps> = ({ children }) => { | |
<Box> | ||
<Header /> | ||
</Box> | ||
<Box component="main" sx={{ minHeight: 'calc(100vh - 124px)' }}> | ||
<Box component="main" sx={{ minHeight: 'calc(100vh - 300px)' }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. パートナーページのようにコンテンツの高さが小さい場合に余白が大きく感じたので短くしてみました。 |
||
{children} | ||
</Box> | ||
<Box> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Box, Typography } from '@mui/material' | ||
import { NextPage } from 'next' | ||
import Image from 'next/image' | ||
import { Layout } from 'src/components/commons' | ||
import { Header } from 'src/components/organisms' | ||
|
||
export type PartnerRank = 'platinum' | 'gold' | ||
|
||
type Props = { | ||
id: string | ||
name: string | ||
description: string | ||
} | ||
|
||
export const PagePartner = ({ id, name, description }: Props) => { | ||
return ( | ||
<Layout> | ||
<Box sx={{ mx: '160px' }} display="flex" flexDirection="column"> | ||
<Box sx={{ mt: '120px', py: '24px' }} display="flex"> | ||
<Image src={`/2023/images/partners/${id}.png`} width={'200px'} height={'120px'} alt={id} /> | ||
<Typography variant="h1" sx={{ ml: '24px', width: '100%', textAlign: 'center', alignContent: 'center' }}> | ||
{name} | ||
</Typography> | ||
</Box> | ||
<Box> | ||
<Typography variant="body1">{description}</Typography> | ||
</Box> | ||
</Box> | ||
</Layout> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { GetStaticPaths, GetStaticProps } from 'next' | ||
import { PagePartner } from 'src/components/pages/PagePartner' | ||
|
||
import partners from 'data/partners.json' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. パートナーの一覧を json から読み込む |
||
|
||
export type Rank = keyof typeof partners | ||
|
||
type PageProps = { | ||
id: string | ||
name: string | ||
description: string | ||
rank: Extract<Rank, 'platinum' | 'gold'> | ||
} | ||
|
||
export const PartnerPage = (props: PageProps) => { | ||
return <PagePartner {...props} /> | ||
} | ||
|
||
type PathProps = Pick<PageProps, 'id' | 'rank'> | ||
|
||
export const getStaticPaths: GetStaticPaths<PathProps> = async () => { | ||
const platinumPartners = partners.platinum.map(p => ({ params: { rank: 'platinum' as const, id: p.id } })) | ||
const goldPartners = partners.gold.map(p => ({ params: { rank: 'gold' as const, id: p.id } })) | ||
|
||
return { | ||
paths: [...platinumPartners, ...goldPartners], | ||
fallback: false | ||
} | ||
} | ||
|
||
/** | ||
* partners.json から path params に対応した情報の抜き出し page の props として返す | ||
*/ | ||
export const getStaticProps: GetStaticProps<PageProps> = async ({ params }) => { | ||
const rank = params?.rank as Rank | undefined | ||
if (!rank) throw new Error(`rank is required : ${params}`) | ||
if (rank !== 'platinum' && rank !== 'gold') throw new Error('invalid rank') | ||
|
||
const id = params?.id as string | undefined | ||
if (!id) throw new Error(`id is required : ${params}`) | ||
|
||
const { name, description } = partners[rank].find(p => p.id === id) ?? {} | ||
if (!name) throw new Error(`name is required : ${params}`) | ||
if (!description) throw new Error(`description is required : ${params}`) | ||
|
||
return { | ||
props: { id, name, rank, description } | ||
} | ||
} | ||
|
||
export default PartnerPage |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web ページなどの表記では
Platinum "Go"ld
ですが、2022 Spring の URL 見ると
platinum
になっていたので、それにならってコード上ではplatinum
という表記にしてます