Skip to content

Commit 00f2b20

Browse files
committed
feat: 태그 컴포넌트 추가 및 스타일 개선
1 parent ba699a3 commit 00f2b20

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

src/pages/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Tag from '@/shared/components/tag/Tag';
12
import { Icon } from '@/shared/icons';
23

34
export default function Home() {
@@ -9,6 +10,9 @@ export default function Home() {
910
초기 세팅 완료
1011
<Icon name='User' color='mint-600' />
1112
</h1>
13+
<Tag label='리스트로 보기' icon='MapPin_' variant='toggle' />
14+
<Tag label='지도로 보기' icon='FadersHorizontal' variant='toggle' />
15+
<Tag label='#데이트' variant='hash' />
1216
<Icon name='CalendarBlank' size={200} color='gray-900' />
1317
<Icon name='User' size={200} color='blue-400' />
1418
<Icon name='User' size={200} color='red-300' />

src/shared/components/tag/Tag.tsx

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
1-
import { Icon } from '@/shared/icons';
2-
import { cn } from '@/shared/lib';
31
import { cva, type VariantProps } from 'class-variance-authority';
2+
import { cn } from '@/shared/lib';
3+
import { Icon } from '@/shared/icons';
4+
import type { IconName } from '@/shared/icons/iconNames';
45

5-
interface HeaderProps {}
6+
interface Props {
7+
label: string;
8+
icon?: IconName;
9+
className?: string;
10+
onClick?: () => void;
11+
variant?: VariantProps<typeof tagStyle>['variant'];
12+
}
613

7-
const TagStyle = cva('px-[1.2rem] py-[0.5rem] ', {
14+
const tagStyle = cva('flex items-center rounded-[500px] text-gray-50 ', {
815
variants: {
9-
color: {
10-
toggleTag: 'bg-pink-300 text-label-md',
11-
hashTag: 'bg-mint-600 text-title-sm',
16+
variant: {
17+
hash: 'bg-mint-600 text-title-sm px-[1.2rem] py-[0.3rem]',
18+
toggle:
19+
'bg-pink-300 w-[10rem] text-label-md gap-2 justify-center py-[0.5rem]',
1220
},
1321
},
1422
defaultVariants: {
15-
color: 'hashTag',
23+
variant: 'hash',
1624
},
1725
});
18-
const Tag = ({}: HeaderProps) => {
19-
return <></>;
26+
27+
const Tag = ({ label, icon, variant, className, onClick }: Props) => {
28+
return (
29+
<button
30+
type='button'
31+
className={cn(tagStyle({ variant }), className)}
32+
onClick={onClick}
33+
>
34+
{icon && <Icon name={icon} size={14} color='gray-50' />}
35+
<span className='truncate'>{label}</span>
36+
</button>
37+
);
2038
};
2139

2240
export default Tag;

0 commit comments

Comments
 (0)