@@ -35,6 +35,8 @@ type HackathonsListProps = {
3535 onSearch ?: ( q : string ) => void ;
3636 onLoadMore ?: ( ) => void ;
3737 hasMore ?: boolean ;
38+ /** Navbar height in pixels to calculate available space (default: 56px) */
39+ navbarHeight ?: number ;
3840} ;
3941
4042function formatDate ( dateStr : string | undefined | null ) : string {
@@ -58,6 +60,7 @@ export default function HackathonsList({
5860 onSearch,
5961 onLoadMore,
6062 hasMore,
63+ navbarHeight = 56 ,
6164} : HackathonsListProps ) {
6265 const [ collapsed , setCollapsed ] = useState ( false ) ;
6366
@@ -120,9 +123,9 @@ export default function HackathonsList({
120123 if ( ! loading && ! filteredHackathons . length ) {
121124 return (
122125 < div
126+ style = { { height : `calc(100vh - ${ navbarHeight } px)` } }
123127 className = { [
124- 'rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-sm flex flex-col overflow-visible' ,
125- fullHeight && ! collapsed ? 'flex-1 min-h-0' : '' ,
128+ 'rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-sm flex flex-col overflow-hidden' ,
126129 ] . join ( ' ' ) }
127130 >
128131 { /* Header */ }
@@ -217,9 +220,9 @@ export default function HackathonsList({
217220
218221 return (
219222 < div
223+ style = { { height : collapsed ? 'auto' : `calc(100vh - ${ navbarHeight } px)` } }
220224 className = { [
221- 'rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-sm flex flex-col overflow-visible' ,
222- fullHeight && ! collapsed ? 'flex-1 min-h-0' : '' ,
225+ 'rounded-xl border border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 shadow-sm flex flex-col overflow-hidden' ,
223226 ] . join ( ' ' ) }
224227 >
225228 { /* Header */ }
@@ -352,17 +355,18 @@ export default function HackathonsList({
352355 ) : (
353356 < ul
354357 className = { [
355- 'overflow-y-auto divide-y divide-zinc-100 dark:divide-zinc-800' ,
356- fullHeight ? 'flex-1 min-h-0' : '' ,
358+ 'overflow-y-auto divide-y divide-zinc-100 dark:divide-zinc-800 flex-1' ,
357359 ] . join ( ' ' ) }
358- style = { ! fullHeight ? { maxHeight : '500px' } : { maxHeight : '500px' } }
359360 >
360361 { filteredHackathons . map ( ( hackathon ) => {
361362 const isSelected = hackathon . id === selectedId ;
362363 return (
363364 < li
364365 key = { hackathon . id }
365- onClick = { ( ) => onSelect ( hackathon ) }
366+ onClick = { ( ) => {
367+ onSelect ( hackathon ) ;
368+ setCollapsed ( true ) ;
369+ } }
366370 className = { [
367371 'flex items-center justify-between gap-3 px-4 py-3 cursor-pointer transition-colors group' ,
368372 isSelected
@@ -432,6 +436,7 @@ export default function HackathonsList({
432436 onClick = { ( e ) => {
433437 e . stopPropagation ( ) ;
434438 onSelect ( hackathon ) ;
439+ setCollapsed ( true ) ;
435440 } }
436441 className = "cursor-pointer flex items-center gap-2"
437442 >
0 commit comments