Skip to content

Commit b7a9a87

Browse files
authored
feat: track card (#185)
1 parent a16ef0c commit b7a9a87

File tree

7 files changed

+153
-1
lines changed

7 files changed

+153
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"devDependencies": {
3131
"@babel/core": "7.19.3",
32+
"@faker-js/faker": "7.6.0",
3233
"@storybook/addon-actions": "6.5.12",
3334
"@storybook/addon-essentials": "6.5.12",
3435
"@storybook/addon-interactions": "6.5.12",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { ComponentMeta, ComponentStory } from '@storybook/react'
2+
import { PlenumCard } from '.'
3+
import { Box } from '@mui/material'
4+
5+
const meta: ComponentMeta<typeof PlenumCard> = {
6+
component: PlenumCard
7+
}
8+
export default meta
9+
10+
const Template: ComponentStory<typeof PlenumCard> = args => (
11+
<Box width="300px">
12+
<PlenumCard {...args} />
13+
</Box>
14+
)
15+
16+
export const Default = Template.bind({})
17+
Default.args = {
18+
title: 'Break'
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Typography, Box } from '@mui/material'
2+
import { Colors } from 'src/styles/color'
3+
4+
export interface PlenumCardProps {
5+
title: string
6+
}
7+
8+
export const PlenumCard = ({ title }: PlenumCardProps) => {
9+
return (
10+
<Box
11+
sx={{
12+
backgroundColor: Colors.background.secondary_blue,
13+
padding: '20px 16px',
14+
borderRadius: '4px',
15+
// TODO(@maito1201): タイムテーブルに組み込んだ時の適度な幅にする
16+
width: '100vw'
17+
}}
18+
>
19+
<Typography variant="body2">{title}</Typography>
20+
</Box>
21+
)
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import type { ComponentMeta, ComponentStory } from '@storybook/react'
2+
import { faker } from '@faker-js/faker'
3+
import { TrackCard } from '.'
4+
import { Box } from '@mui/material'
5+
import { Colors } from 'src/styles/color'
6+
7+
const meta: ComponentMeta<typeof TrackCard> = {
8+
component: TrackCard
9+
}
10+
export default meta
11+
12+
const Template: ComponentStory<typeof TrackCard> = args => (
13+
<Box width="300px">
14+
<TrackCard {...args} />
15+
</Box>
16+
)
17+
18+
export const Default = Template.bind({})
19+
Default.args = {
20+
id: 'A1-1',
21+
title: faker.lorem.paragraph(),
22+
minute: 20,
23+
speaker: faker.name.fullName(),
24+
speakerIcon: faker.image.avatar()
25+
}
26+
27+
export const Green = Template.bind({})
28+
Green.args = {
29+
id: 'A1-1',
30+
title: faker.lorem.paragraph(),
31+
minute: 20,
32+
speaker: faker.name.fullName(),
33+
speakerIcon: faker.image.avatar(),
34+
color: Colors.background.secondary_green,
35+
idColor: Colors.background.primary_green
36+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { Typography, Box } from '@mui/material'
2+
import { Colors } from 'src/styles/color'
3+
import Image, { StaticImageData } from 'next/image'
4+
5+
export interface TrackCardProps {
6+
id: string
7+
title: string
8+
minute: number
9+
speaker: string
10+
speakerIcon: string | StaticImageData
11+
color?: string
12+
idColor?: string
13+
}
14+
15+
export const TrackCard = ({
16+
id,
17+
title,
18+
minute,
19+
speaker,
20+
speakerIcon,
21+
color = Colors.background.secondary_pink,
22+
idColor = Colors.background.primary_pink
23+
}: TrackCardProps) => {
24+
return (
25+
<Box
26+
sx={{
27+
backgroundColor: color,
28+
padding: '16px',
29+
borderRadius: '4px',
30+
width: '100%'
31+
}}
32+
>
33+
<Box
34+
sx={{
35+
display: 'flex',
36+
backgroundColor: idColor,
37+
borderRadius: '2px',
38+
width: 'fit-content',
39+
padding: '0 4px',
40+
mb: '4px'
41+
}}
42+
>
43+
<Typography variant="caption" color={Colors.text.white}>
44+
{id}
45+
</Typography>
46+
</Box>
47+
<Box mb="4px">
48+
<Typography variant="body2">{title}</Typography>
49+
</Box>
50+
<Box display="flex" alignItems="center">
51+
<Box width="20px" height="20px" borderRadius="50%" overflow="hidden" margin="0 4px 0 0">
52+
<Image src={speakerIcon} width={20} height={20} objectFit="contain" alt={`${speaker}'s icon`} quality={100} />
53+
</Box>
54+
<Typography variant="caption" fontWeight="bold">
55+
{speaker}
56+
</Typography>
57+
<Typography variant="caption" margin="0 0 0 auto">
58+
({minute}min)
59+
</Typography>
60+
</Box>
61+
</Box>
62+
)
63+
}

src/styles/color.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ export const Colors = {
2424
secondary: '#F7F9FB',
2525
gopher_blue: '#00ADD8',
2626
gradation_blue: 'linear-gradient(180deg, #4E96E9 19.27%, rgba(77, 148, 230, 0) 88.54%)',
27-
darken_1: 'rgba(0,0,0,0.125)'
27+
darken_1: 'rgba(0,0,0,0.125)',
28+
// NOTE(@maito1201): primary_blue is brand_color
29+
primary_pink: '#EF5DA8',
30+
primary_green: '#61B236',
31+
secondary_pink: '#F8D9E8',
32+
secondary_green: '#D9EBD4',
33+
secondary_blue: '#D5E5F7'
2834
},
2935
border: {
3036
primary: {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,11 @@
14651465
minimatch "^3.1.2"
14661466
strip-json-comments "^3.1.1"
14671467

1468+
"@faker-js/faker@7.6.0":
1469+
version "7.6.0"
1470+
resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-7.6.0.tgz#9ea331766084288634a9247fcd8b84f16ff4ba07"
1471+
integrity sha512-XK6BTq1NDMo9Xqw/YkYyGjSsg44fbNwYRx7QK2CuoQgyy+f1rrTDHoExVM5PsyXCtfl2vs2vVJ0MN0yN6LppRw==
1472+
14681473
"@gar/promisify@^1.0.1":
14691474
version "1.1.3"
14701475
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"

0 commit comments

Comments
 (0)