33import { clsx } from 'clsx' ;
44
55type Category = 'All' | 'Tech' | 'Life' ;
6+ type CategoryFilterVariant = 'links' | 'pills' ;
67
78const CATEGORY_LABELS : Record < Category , string > = {
89 All : 'All' ,
@@ -15,44 +16,70 @@ interface CategoryFilterProps {
1516 activeCategory : Category ;
1617 onCategoryChange : ( category : Category ) => void ;
1718 categoryCounts : Record < Category , number > ;
19+ variant ?: CategoryFilterVariant ;
1820}
1921
2022export default function CategoryFilter ( {
2123 categories,
2224 activeCategory,
2325 onCategoryChange,
2426 categoryCounts,
27+ variant = 'pills' ,
2528} : CategoryFilterProps ) {
29+ const isLinkVariant = variant === 'links' ;
30+
2631 return (
27- < div className = "flex gap-2 flex-wrap" >
28- { categories . map ( ( category ) => (
29- < button
30- key = { category }
31- onClick = { ( ) => onCategoryChange ( category ) }
32- className = { clsx (
33- 'inline-flex min-h-11 items-center gap-2 rounded-[var(--radius-selection)] border px-4 py-2 text-sm transition-colors duration-[var(--duration-200)] ease-[var(--ease-default)]' ,
34- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-toss-blue)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--color-bg-primary)]' ,
35- activeCategory === category
36- ? 'border-[var(--color-toss-blue)] bg-[var(--color-toss-blue)] text-white'
37- : 'border-[var(--color-border)] bg-[var(--color-bg-primary)] text-[var(--color-grey-600)] hover:border-[var(--color-border-hover)] hover:bg-[var(--color-grey-50)]'
38- ) }
39- aria-pressed = { activeCategory === category }
40- >
41- < span className = "font-medium" > { CATEGORY_LABELS [ category ] } </ span >
42- < span
32+ < nav aria-label = "글 분류" >
33+ < div
34+ className = { clsx (
35+ 'flex flex-wrap items-center' ,
36+ isLinkVariant ? 'gap-x-5 gap-y-1' : 'gap-2'
37+ ) }
38+ >
39+ { categories . map ( ( category ) => (
40+ < button
41+ key = { category }
42+ onClick = { ( ) => onCategoryChange ( category ) }
4343 className = { clsx (
44- 'rounded-[var(--radius-selection)] px-1.5 py-0.5 text-[10px] font-semibold' ,
45- activeCategory === category
46- ? 'bg-white/20 text-white'
47- : 'bg-[var(--color-grey-100)] text-[var(--color-text-tertiary)]'
44+ 'inline-flex min-h-11 items-center text-sm transition-colors duration-[var(--duration-200)] ease-[var(--ease-default)]' ,
45+ isLinkVariant
46+ ? 'border-b-2 px-0 py-2 font-medium'
47+ : 'gap-2 rounded-[var(--radius-selection)] border px-4 py-2' ,
48+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-toss-blue)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--color-bg-primary)]' ,
49+ isLinkVariant
50+ ? activeCategory === category
51+ ? 'border-[var(--color-toss-blue)] text-[var(--color-toss-blue)]'
52+ : 'border-transparent text-[var(--color-text-secondary)] hover:border-[var(--color-grey-300)] hover:text-[var(--color-text-primary)]'
53+ : activeCategory === category
54+ ? 'border-[var(--color-toss-blue)] bg-[var(--color-toss-blue)] text-[var(--color-accent-foreground)]'
55+ : 'border-[var(--color-border)] bg-[var(--color-bg-primary)] text-[var(--color-grey-600)] hover:border-[var(--color-border-hover)] hover:bg-[var(--color-grey-50)]'
4856 ) }
57+ aria-pressed = { activeCategory === category }
4958 >
50- { categoryCounts [ category ] }
51- </ span >
52- </ button >
53- ) ) }
54- </ div >
59+ < span className = { clsx ( ! isLinkVariant && 'font-medium' ) } >
60+ { CATEGORY_LABELS [ category ] }
61+ </ span >
62+ { isLinkVariant ? (
63+ < span className = "ml-1 text-meta font-normal text-[var(--color-text-tertiary)]" >
64+ ({ categoryCounts [ category ] } )
65+ </ span >
66+ ) : (
67+ < span
68+ className = { clsx (
69+ 'rounded-[var(--radius-selection)] px-1.5 py-0.5 text-[10px] font-semibold' ,
70+ activeCategory === category
71+ ? 'bg-[var(--color-grey-700)] text-[var(--color-accent-foreground)]'
72+ : 'bg-[var(--color-grey-100)] text-[var(--color-text-tertiary)]'
73+ ) }
74+ >
75+ { categoryCounts [ category ] }
76+ </ span >
77+ ) }
78+ </ button >
79+ ) ) }
80+ </ div >
81+ </ nav >
5582 ) ;
5683}
5784
58- export type { CategoryFilterProps , Category } ;
85+ export type { CategoryFilterProps , Category , CategoryFilterVariant } ;
0 commit comments