import * as React from 'react'; import { View } from 'react-native'; import { getColor } from './style-utils'; import Text from './text'; // Badge 컴포넌트의 Props 타입 정의 type BadgeProps = | { variant: 'dot'; dotPosition?: string; color?: string; } | { variant: 'new'; size?: 'medium' | 'small'; color?: string; } | { variant: 'number'; count?: number; size?: 'medium' | 'small'; color?: string; }; const Badge: React.FC = (props) => { if (props.variant === 'dot') { const { dotPosition = 'absolute top-0 right-0', color = 'emerald-500' } = props; return ( ); } if (props.variant === 'new') { const { size = 'medium', color = 'emerald-500' } = props; const numberBadgePosition = size === 'small' ? 'top-[-2] right-[-6]' : 'top-[-4] right-[-8]'; return ( N ); } if (props.variant === 'number') { const { count = 1, size = 'medium', color = 'emerald-500' } = props; const isCountLarge = count > 99; const adjustedRight = isCountLarge ? size === 'small' ? '-16' : '-20' : size === 'small' ? '-6' : '-8'; const adjustedPosition = size === 'small' ? `top-[-2] right-[${adjustedRight}]` : `top-[-4] right-[${adjustedRight}]`; return ( {count > 99 ? '99+' : count} ); } }; export default Badge;