@@ -206,6 +206,13 @@ function distributeToColumns(groups: GroupData[]): [GroupData[], GroupData[]] {
206206}
207207
208208function Group ( { group } : { group : GroupData } ) {
209+ // When odd count in 2-column layout, last item spans full width
210+ const isOddTwoColumn = group . columns === 2 && group . items . length % 2 === 1
211+ // Adjust break index: exclude spanning item from column distribution
212+ const effectiveBreakIndex = isOddTwoColumn
213+ ? Math . ceil ( ( group . items . length - 1 ) / 2 )
214+ : group . breakIndex
215+
209216 return (
210217 < div className = "group/item shrink-0 grow border border-neu-200 bg-neu-50 dark:border-neu-100 dark:bg-neu-50/25 lg:min-w-0 xl:min-w-[480px]" >
211218 < input
@@ -232,32 +239,40 @@ function Group({ group }: { group: GroupData }) {
232239 className = "divide-y divide-neu-200 [column-gap:0] dark:divide-neu-100 max-md:hidden peer-checked:max-md:block md:block lg:[column-count:var(--item-columns,1)]"
233240 style = { { "--item-columns" : group . columns } as CSSProperties }
234241 >
235- { group . items . map ( ( item , i ) => (
236- < li
237- key = { `${ group . id } -${ item . name } ` }
238- style = {
239- group . breakIndex
240- ? {
241- borderTop : i === group . breakIndex ? "none" : "" ,
242- borderLeftWidth : i >= group . breakIndex ? "1px" : "" ,
243- }
244- : { }
245- }
246- >
247- { item . href ? (
248- < a
249- href = { item . href }
250- className = "flex items-center justify-between bg-neu-0/40 px-4 py-3 text-neu-900 transition-colors hover:bg-neu-0 hover:duration-0"
251- >
252- { item . name }
253- </ a >
254- ) : (
255- < span className = "flex items-center justify-between bg-neu-0/40 px-4 py-3 text-neu-900" >
256- { item . name }
257- </ span >
258- ) }
259- </ li >
260- ) ) }
242+ { group . items . map ( ( item , i ) => {
243+ const isLastItem = i === group . items . length - 1
244+ const spansFullWidth = isOddTwoColumn && isLastItem
245+ const isAtBreak = i === effectiveBreakIndex
246+ const isInSecondColumn = ! spansFullWidth && i >= effectiveBreakIndex
247+
248+ return (
249+ < li
250+ key = { `${ group . id } -${ item . name } ` }
251+ className = { clsx ( spansFullWidth && "lg:[column-span:all]" ) }
252+ style = {
253+ group . columns === 2
254+ ? {
255+ borderTop : isAtBreak ? "none" : "" ,
256+ borderLeftWidth : isInSecondColumn ? "1px" : "" ,
257+ }
258+ : { }
259+ }
260+ >
261+ { item . href ? (
262+ < a
263+ href = { item . href }
264+ className = "flex items-center justify-between bg-neu-0/40 px-4 py-3 text-neu-900 transition-colors hover:bg-neu-0 hover:duration-0"
265+ >
266+ { item . name }
267+ </ a >
268+ ) : (
269+ < span className = "flex items-center justify-between bg-neu-0/40 px-4 py-3 text-neu-900" >
270+ { item . name }
271+ </ span >
272+ ) }
273+ </ li >
274+ )
275+ } ) }
261276 </ ul >
262277 </ div >
263278 )
0 commit comments