-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(system): Text에 typography스타일 추가 #14
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
import { Text } from '@/system/components'; | ||
import { typographyVariant } from '@/system/token/typography'; | ||
|
||
export default function Home() { | ||
return <div>123</div>; | ||
return ( | ||
<> | ||
{typographyVariant.map((typo) => ( | ||
<Text typography={typo} key={typo}> | ||
하이하이 | ||
</Text> | ||
))} | ||
</> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Typography } from '@/system/token/typography/index'; | ||
|
||
// NOTE: px정보를 typography token에서 직접 가져올 경우 tailwind에서 인식하지 못하는 문제가 있어 임시적으로 값을 넣어놓습니다. | ||
// FIXME: 추후 수정해야합니다. | ||
export const fontSize: Record<Typography, `text-[${number}px]`> = { | ||
title1: 'text-[36px]', | ||
title2: 'text-[28px]', | ||
title3: 'text-[24px]', | ||
heading1: 'text-[20px]', | ||
heading2: 'text-[18px]', | ||
body1: 'text-[16px]', | ||
body2: 'text-[15px]', | ||
label1: 'text-[14px]', | ||
label2: 'text-[13px]', | ||
caption1: 'text-[12px]', | ||
caption2: 'text-[11px]', | ||
} as const; | ||
|
||
export const lineHeight: Record<Typography, `leading-[${number}px]`> = { | ||
title1: 'leading-[48px]', | ||
title2: 'leading-[38px]', | ||
title3: 'leading-[32px]', | ||
heading1: 'leading-[28px]', | ||
heading2: 'leading-[26px]', | ||
body1: 'leading-[24px]', | ||
body2: 'leading-[22px]', | ||
label1: 'leading-[20px]', | ||
label2: 'leading-[18px]', | ||
caption1: 'leading-[16px]', | ||
caption2: 'leading-[14px]', | ||
} as const; | ||
|
||
export const letterSpacing: Record<Typography, `tracking-[${number}em]`> = { | ||
title1: 'tracking-[-0.027em]', | ||
title2: 'tracking-[-0.0236em]', | ||
title3: 'tracking-[-0.023em]', | ||
heading1: 'tracking-[-0.012em]', | ||
heading2: 'tracking-[-0.002em]', | ||
body1: 'tracking-[0.0057em]', | ||
body2: 'tracking-[0.0096em]', | ||
label1: 'tracking-[0.0145em]', | ||
label2: 'tracking-[0.0194em]', | ||
caption1: 'tracking-[0.0252em]', | ||
caption2: 'tracking-[0.0311em]', | ||
} as const; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
import { typographyVariant } from '@/system/token/typography'; | ||
import { tv } from 'tailwind-variants'; | ||
import { cva } from 'class-variance-authority'; | ||
import type { Typography } from '@/system/token/typography'; | ||
import { fontSize, lineHeight, letterSpacing } from '@/system/components/Text/styles/typography'; | ||
|
||
export const textVariants = tv({ | ||
base: 'm-0', | ||
slots: { | ||
paragraph: [], | ||
}, | ||
export const paragraphVariants = cva(['m-0'], { | ||
variants: { | ||
typography: typographyVariant.reduce( | ||
(acc, typography) => { | ||
// TODO: fontsize, fontweight, lineheight등 tailwind정보 추가 | ||
acc[typography] = []; | ||
acc[typography] = [fontSize[typography], lineHeight[typography], letterSpacing[typography]]; | ||
return acc; | ||
}, | ||
{} as Record<Typography, []>, | ||
{} as Record<Typography, string[]>, | ||
), | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,57 @@ | ||
export const typographyVariant = [ | ||
'Display1', | ||
'Display2', | ||
'Title1', | ||
'Title2', | ||
'Title3', | ||
'Heading1', | ||
'Heading2', | ||
'Headline1', | ||
'Headline2', | ||
'Body1', | ||
'Body2', | ||
'Label1', | ||
'Label2', | ||
'Caption1', | ||
'Caption2', | ||
'title1', | ||
'title2', | ||
'title3', | ||
'heading1', | ||
'heading2', | ||
'body1', | ||
'body2', | ||
'label1', | ||
'label2', | ||
'caption1', | ||
'caption2', | ||
] as const; | ||
|
||
export type Typography = (typeof typographyVariant)[number]; | ||
|
||
// TODO: 자간 / 행간 높이 설정 | ||
export const fontSize: Record<Typography, number> = { | ||
Display1: 56, | ||
Display2: 40, | ||
Title1: 36, | ||
Title2: 28, | ||
Title3: 24, | ||
Heading1: 22, | ||
Heading2: 20, | ||
Headline1: 18, | ||
Headline2: 17, | ||
Body1: 16, | ||
Body2: 15, | ||
Label1: 14, | ||
Label2: 13, | ||
Caption1: 12, | ||
Caption2: 11, | ||
export const fontSize: Record<Typography, `${number}px`> = { | ||
title1: '36px', | ||
title2: '28px', | ||
title3: '24px', | ||
Comment on lines
16
to
+20
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. letter-spacing은 em단위를 가지고 있어 px, em단위를 명시해줍니다 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. 이 부분은 tailwind.config에서 작성된 extend로 해결되지 않는 부분인걸까요-?? 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. 토큰을 어딘가에 정의해둘 필요는 있다고 생각해서 파일로 만들어두었어요. 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. tailwind.config 얘기가 나와서 그런데, 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. 엇 그렇네요? ㅋㅋㅋㅋㅋ |
||
heading1: '20px', | ||
heading2: '18px', | ||
body1: '16px', | ||
body2: '15px', | ||
label1: '14px', | ||
label2: '13px', | ||
caption1: '12px', | ||
caption2: '11px', | ||
} as const; | ||
|
||
export const lineHeight: Record<Typography, `${number}px`> = { | ||
title1: '48px', | ||
title2: '38px', | ||
title3: '32px', | ||
heading1: '28px', | ||
heading2: '26px', | ||
body1: '24px', | ||
body2: '22px', | ||
label1: '20px', | ||
label2: '18px', | ||
caption1: '16px', | ||
caption2: '14px', | ||
} as const; | ||
|
||
export const letterSpacing: Record<Typography, `${number}em`> = { | ||
title1: '-0.027em', | ||
title2: '-0.0236em', | ||
title3: '-0.023em', | ||
heading1: '-0.012em', | ||
heading2: '-0.002em', | ||
body1: '0.0057em', | ||
body2: '0.0096em', | ||
label1: '0.0145em', | ||
label2: '0.0194em', | ||
caption1: '0.0252em', | ||
caption2: '0.0311em', | ||
} as const; |
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.
이런 문제가 있어, typography의 토큰을 복사해서 임시파일을 만들어 유지하였어요. 다른 해결책이 있다면 말씀주세요!
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.
혹시 NOTE에 대해 조금 더 설명해주실 수 있을까요??
className을 prop으로 넘겨주는 과정에서 오류가 난다는 말씀일까요??
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.
이게 검색을 좀 해보니 tailwind특성상 중간에
text-${something}
이런식으로 끼워넣으면 인식하지 못하는 것 같아요.우선 컴포넌트를 사용하는 것이 급할 것 같아서 임시로 대응해두었습니닷..!