import React from 'react'; import { StyleProp, Text, TextProps, TextStyle } from 'react-native'; import { SemanticColor, StateColor, TextColor } from '../color/SemanticColor'; import { typoBodyTokens, typoDisplayTokens, typoHeadlineTokens, typoMiscTokens } from './constants'; type CustomTypoStyle = StyleProp>; type CustomTypoProps = Omit; type DisplayTypo = (typeof typoDisplayTokens)[number]; type HeadlineTypo = (typeof typoHeadlineTokens)[number]; type BodyTypo = (typeof typoBodyTokens)[number]; type MiscTypo = (typeof typoMiscTokens)[number]; type TypoType = | DisplayTypo | HeadlineTypo | BodyTypo // 포매팅시 항상 줄바꿈하기 위한 주석 | MiscTypo; const typoStyle = (typoType: TypoType, color?: TextColor | StateColor) => { const defaultStyle = (() => { switch (typoType) { case 'display_52_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 52, lineHeight: 72, }; case 'display_36_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 36, lineHeight: 46, }; case 'display_34_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 34, lineHeight: 44, }; case 'display_28_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 28, lineHeight: 38, }; case 'headline_24_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 24, lineHeight: 32, }; case 'headline_20_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 20, lineHeight: 28, }; case 'headline_18_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 18, lineHeight: 26, }; case 'headline_16_bold': return { fontFamily: 'Pretendard-Bold', fontSize: 16, lineHeight: 24, }; case 'body_18_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 18, lineHeight: 26, }; case 'body_18_medium': return { fontFamily: 'Pretendard-Medium', fontSize: 18, lineHeight: 26, }; case 'body_18_regular': return { fontFamily: 'Pretendard-Regular', fontSize: 18, lineHeight: 26, }; case 'body_16_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 16, lineHeight: 24, }; case 'body_16_medium': return { fontFamily: 'Pretendard-Medium', fontSize: 16, lineHeight: 24, }; case 'body_16_regular': return { fontFamily: 'Pretendard-Regular', fontSize: 16, lineHeight: 24, }; case 'body_14_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 14, lineHeight: 22, }; case 'body_14_medium': return { fontFamily: 'Pretendard-Medium', fontSize: 14, lineHeight: 22, }; case 'body_14_regular': return { fontFamily: 'Pretendard-Regular', fontSize: 14, lineHeight: 22, }; case 'body_12_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 12, lineHeight: 20, }; case 'body_12_medium': return { fontFamily: 'Pretendard-Medium', fontSize: 12, lineHeight: 20, }; case 'body_12_regular': return { fontFamily: 'Pretendard-Regular', fontSize: 12, lineHeight: 20, }; case 'button_12_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 12, lineHeight: 16, }; case 'button_14_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 14, lineHeight: 20, }; case 'button_16_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 16, lineHeight: 20, }; case 'button_18_semibold': return { fontFamily: 'Pretendard-SemiBold', fontSize: 18, lineHeight: 26, }; case 'chip_14_regular': return { fontFamily: 'Pretendard-Regular', fontSize: 14, lineHeight: 16, }; case 'navigation_10_medium': return { fontFamily: 'Pretendard-Medium', fontSize: 10, lineHeight: 14, }; // 토큰 교체를 돕기 위한 임시 처리. 이전 토큰을 제거할 때 함께 제거할 것. default: return {}; } })(); return { ...defaultStyle, color: SemanticColor[color ?? 'text_primary'], }; }; export const Typo: React.FC< { children: TextProps['children']; type: TypoType; color?: TextColor | StateColor; style?: CustomTypoStyle; } & CustomTypoProps > = ({ children, type, color, style, ...props }) => { return ( {children} ); };