@@ -6,6 +6,7 @@ export interface StackItemData {
66 name : string
77 logo ?: boolean
88 showText ?: boolean
9+ subcategory ?: string
910 onClick ?: ( ) => void
1011}
1112
@@ -15,6 +16,7 @@ export interface StackSectionProps {
1516 items : StackItemData [ ]
1617 variant ?: 'neon' | 'green' | 'yellow' | 'purple' | 'pink' | 'orange' | 'grey' | 'blue' | 'red' | 'bone'
1718 className ?: string
19+ grouped ?: boolean
1820}
1921
2022const backgroundColorVariants = {
@@ -43,13 +45,82 @@ const borderColorVariants = {
4345 bone : 'border-bone-700'
4446}
4547
48+ // Group items by subcategory
49+ const groupItemsBySubcategory = ( items : StackItemData [ ] ) => {
50+ const groups : { [ key : string ] : StackItemData [ ] } = { } ;
51+
52+ items . forEach ( item => {
53+ const subcategory = item . subcategory || 'Other' ;
54+ if ( ! groups [ subcategory ] ) {
55+ groups [ subcategory ] = [ ] ;
56+ }
57+ groups [ subcategory ] . push ( item ) ;
58+ } ) ;
59+
60+ return groups ;
61+ } ;
62+
4663export default function StackSection ( {
4764 title,
4865 subtitle,
4966 items,
5067 variant = 'neon' ,
51- className = ''
68+ className = '' ,
69+ grouped = false
5270} : StackSectionProps ) {
71+ // If grouped is true, render grouped layout
72+ if ( grouped ) {
73+ const groupedItems = groupItemsBySubcategory ( items ) ;
74+ const subcategories = Object . keys ( groupedItems ) ;
75+
76+ return (
77+ < div className = { `flex flex-col lg:flex-row py-4 ${ className } ` } >
78+ { /* Title Section */ }
79+ < div className = { `lg:w-1/5 flex-shrink-0 pt-4 border-t ${ borderColorVariants [ variant ] } ` } >
80+ < h3 className = { `font-palatino text-2xl font-bold text-black-900 mb-2` } >
81+ { title }
82+ </ h3 >
83+ { subtitle && (
84+ < p className = "text-black-700 text-sm font-palatino" >
85+ { subtitle }
86+ </ p >
87+ ) }
88+ </ div >
89+
90+ { /* Grouped Items Layout */ }
91+ < div className = "lg:w-4/5 flex-1" >
92+ < div className = { `border border-white rounded-tr-xl backdrop-blur-sm rounded-b-xl p-4 ${ backgroundColorVariants [ variant ] } ` } >
93+ { subcategories . map ( ( subcategory , groupIndex ) => (
94+ < div key = { subcategory } className = { `${ groupIndex > 0 ? 'mt-6 pt-6 border-t border-white/20' : '' } ` } >
95+ { /* Subcategory Title */ }
96+ < h4 className = "font-palatino text-lg font-bold text-black-800 mb-3" >
97+ { subcategory }
98+ </ h4 >
99+ { /* Items in this subcategory */ }
100+ < div className = "flex flex-wrap gap-4" >
101+ { groupedItems [ subcategory ] . map ( ( item ) => (
102+ < StackItem
103+ key = { item . id }
104+ variant = { variant }
105+ onClick = { item . onClick }
106+ id = { item . id }
107+ title = { title }
108+ showLogo = { item . logo || false }
109+ showText = { item . showText !== false }
110+ >
111+ { item . name }
112+ </ StackItem >
113+ ) ) }
114+ </ div >
115+ </ div >
116+ ) ) }
117+ </ div >
118+ </ div >
119+ </ div >
120+ ) ;
121+ }
122+
123+ // Original non-grouped layout
53124 return (
54125 < div className = { `flex flex-col lg:flex-row py-4 ${ className } ` } >
55126 { /* Title Section */ }
@@ -94,6 +165,7 @@ export const createStackSection = (
94165 subtitle ?: string
95166 variant ?: StackSectionProps [ 'variant' ]
96167 onItemClick ?: ( itemName : string , index : number ) => void
168+ grouped ?: boolean
97169 }
98170) : StackSectionProps => {
99171 const stackItems : StackItemData [ ] = items . map ( ( item , index ) => {
@@ -111,6 +183,7 @@ export const createStackSection = (
111183 title,
112184 subtitle : options ?. subtitle ,
113185 items : stackItems ,
114- variant : options ?. variant || 'neon'
186+ variant : options ?. variant || 'neon' ,
187+ grouped : options ?. grouped || false
115188 }
116189}
0 commit comments