forked from next-step/react-payments
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
137 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,57 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { Typography, TypographyVariants, typographyVariantStyle } from './Typography'; | ||
import { AppLayout } from '@/components'; | ||
import { VStack } from '@/shared/components'; | ||
import { storybookControls, styleToken } from '@/shared/styles'; | ||
|
||
const meta: Meta<typeof Typography> = { | ||
title: 'Primitive/Typography', | ||
component: Typography, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
argTypes: { | ||
...storybookControls.argTypes, | ||
variant: { | ||
options: ['caption', 'title', 'body', 'subtitle', 'headline', 'display'], | ||
}, | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<AppLayout> | ||
<Story /> | ||
</AppLayout> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Typography>; | ||
|
||
export const Primary: Story = { | ||
args: { | ||
variant: 'body', | ||
children: 'Hello Typography', | ||
}, | ||
}; | ||
|
||
export const WithVariants: Story = { | ||
render: () => ( | ||
<VStack gap="24px"> | ||
{Object.entries(TypographyVariants).map(([key, value]) => { | ||
const { fontSize, fontWeight, lineHeight, letterSpacing } = typographyVariantStyle[value]; | ||
return ( | ||
<VStack> | ||
<Typography key={`${key}-name`} variant={value} color={styleToken.color.black}> | ||
{value} | ||
</Typography> | ||
<Typography key={`${key}-style`} variant="caption" color={styleToken.color.gray700}> | ||
{fontSize} {fontWeight} {lineHeight} {letterSpacing} | ||
</Typography> | ||
</VStack> | ||
); | ||
})} | ||
</VStack> | ||
), | ||
}; |
This file contains 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,71 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { DefaultStyled, styleToken } from '@/shared/styles'; | ||
import { AsProps, StyleProps } from '@/shared/types'; | ||
|
||
export enum TypographyVariants { | ||
caption = 'caption', | ||
title = 'title', | ||
body = 'body', | ||
subtitle = 'subtitle', | ||
headline = 'headline', | ||
display = 'display', | ||
} | ||
type TypographyVariant = keyof typeof TypographyVariants; | ||
|
||
type TypographyProps = PropsWithChildren< | ||
StyleProps & | ||
AsProps & { | ||
variant?: TypographyVariant; | ||
} | ||
>; | ||
|
||
export const Typography = ({ as, variant, children, ...restProps }: TypographyProps) => ( | ||
<Root as="span" variant={variant || 'body'} {...restProps}> | ||
{children} | ||
</Root> | ||
); | ||
|
||
const Root = styled(DefaultStyled)<TypographyProps>` | ||
white-space: pre-wrap; | ||
${({ variant }) => typographyVariantStyle[variant || 'body']}; | ||
`; | ||
|
||
export const typographyVariantStyle = { | ||
title: { | ||
fontSize: styleToken.fontSize.title, | ||
fontWeight: styleToken.fontWeight.medium, | ||
lineHeight: '1.3rem', | ||
letterSpacing: 'normal', | ||
}, | ||
body: { | ||
fontSize: styleToken.fontSize.body, | ||
fontWeight: styleToken.fontWeight.regular, | ||
lineHeight: '1.5rem', | ||
letterSpacing: 'normal', | ||
}, | ||
headline: { | ||
fontSize: styleToken.fontSize.headline, | ||
fontWeight: styleToken.fontWeight.medium, | ||
lineHeight: '1.3rem', | ||
letterSpacing: '0.05rem', | ||
}, | ||
subtitle: { | ||
fontSize: styleToken.fontSize.subtitle, | ||
fontWeight: styleToken.fontWeight.regular, | ||
lineHeight: '1.6rem', | ||
letterSpacing: '0.02rem', | ||
}, | ||
caption: { | ||
fontSize: styleToken.fontSize.caption, | ||
fontWeight: styleToken.fontWeight.regular, | ||
lineHeight: '1.4rem', | ||
letterSpacing: '0.01rem', | ||
}, | ||
display: { | ||
fontSize: styleToken.fontSize.display, | ||
fontWeight: styleToken.fontWeight.medium, | ||
lineHeight: '1.2rem', | ||
letterSpacing: '0.1rem', | ||
}, | ||
} as const; |
This file contains 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 @@ | ||
export * from './Typography'; |
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const colors = { | ||
white: '#fff', | ||
black: '#222', | ||
gray100: '#f5f5f5', | ||
gray200: '#ecebf1', | ||
gray300: '#d3d3d3', | ||
|