File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import styled from 'styled-components' ;
2- import theme from '../../ styles/theme' ;
2+ import theme from '@ styles/theme' ;
33import { useMediaQuery } from 'react-responsive' ;
4-
5- export type FontStyleKey = keyof typeof theme . fontStyles ;
6-
7- // 플랫폼 별 폰트가 다른 경우
8- interface FontStylesByPlatform {
9- mobile : FontStyleKey ;
10- tablet : FontStyleKey ;
11- desktop : FontStyleKey ;
12- }
13-
14- export interface StyledTextProps {
15- $textTheme : {
16- style : FontStyleKey | FontStylesByPlatform ;
17- lineHeight ?: number ;
18- } ;
19- color ?: string ;
20- children : any ;
21- }
4+ import type { StyledTextProps } from './dto' ;
225
236export const StyledText = styled . div < StyledTextProps > `
247 color: ${ ( props ) => props . color || theme . colors . black } ;
258 white-space: pre-line;
26- line-height: ${ ( props ) => props . $textTheme . lineHeight || 1.5 } ;
279 ${ ( props ) => {
2810 const isMobile = useMediaQuery ( { maxWidth : '767px' } ) ;
2911 const isTabletPortrait = useMediaQuery ( { minWidth : '768px' , maxWidth : '991px' } ) ;
3012 const isTabletLandscape = useMediaQuery ( { minWidth : '992px' , maxWidth : '1219px' } ) ;
3113 const isDesktop = useMediaQuery ( { minWidth : '1220px' } ) ;
3214
3315 let fontStyle ;
16+
3417 if ( typeof props . $textTheme . style === 'string' ) {
18+ // style이 문자열이면 일괄적으로 사용
3519 fontStyle = theme . fontStyles [ props . $textTheme . style ] ;
3620 } else if ( typeof props . $textTheme . style === 'object' ) {
21+ // style이 객체면 기기에 따른 분기
3722 if ( isMobile ) {
3823 fontStyle = theme . fontStyles [ props . $textTheme . style . mobile ] ;
3924 } else if ( isTabletPortrait || isTabletLandscape ) {
Original file line number Diff line number Diff line change 1+ import theme from '@styles/theme' ;
2+
3+ // 플랫폼 별 폰트가 다른 경우
4+ interface FontStylesByPlatform {
5+ mobile : FontStyleKey ;
6+ tablet : FontStyleKey ;
7+ desktop : FontStyleKey ;
8+ }
9+
10+ export interface StyledTextProps {
11+ $textTheme : {
12+ style : FontStyleKey | FontStylesByPlatform ;
13+ lineHeight ?: number ;
14+ } ;
15+ color ?: string ;
16+ children : any ;
17+ }
18+
19+ export type FontStyleKey = keyof typeof theme . fontStyles ;
You can’t perform that action at this time.
0 commit comments