11import { useMemo } from "react" ;
2+ import { ScrollArea } from "@/components/ui/scroll-area" ;
23import { colorForLabel } from "../lib/colors" ;
34import type { GraphData } from "../lib/types" ;
45
@@ -37,9 +38,9 @@ export function FilterPanel({
3738 } , [ data ] ) ;
3839
3940 return (
40- < div className = "px-4 py-3 border-b border-border/40 space-y-3 " >
41- { /* Header row */ }
42- < div className = "flex items-center justify-between" >
41+ < div className = "flex flex-col shrink-0 max-h-[45%] border-b border-border/40" >
42+ { /* Header row — always visible */ }
43+ < div className = "flex items-center justify-between px-4 pt-3 pb-2 shrink-0 " >
4344 < span className = "text-[11px] font-medium text-foreground/50 uppercase tracking-widest" >
4445 Filters
4546 </ span >
@@ -50,66 +51,77 @@ export function FilterPanel({
5051 </ div >
5152 </ div >
5253
53- { /* Node labels */ }
54- < div >
55- < p className = "text-[10px] text-foreground/30 mb-1.5" > Nodes</ p >
56- < div className = "flex flex-wrap gap-1" >
57- { labelCounts . map ( ( [ label , count ] ) => {
58- const on = enabledLabels . has ( label ) ;
59- const c = colorForLabel ( label ) ;
60- return (
61- < button
62- key = { label }
63- onClick = { ( ) => onToggleLabel ( label ) }
64- className = { `inline-flex items-center gap-1 px-1.5 py-[3px] rounded-md text-[10px] font-medium transition-all border ${
65- on ? "border-white/[0.08] bg-white/[0.04]" : "border-transparent opacity-25"
66- } `}
67- >
68- < span className = "w-[5px] h-[5px] rounded-full" style = { { backgroundColor : on ? c : "#444" } } />
69- < span style = { { color : on ? c : "#555" } } > { label } </ span >
70- < span className = "text-foreground/20 tabular-nums" > { count . toLocaleString ( ) } </ span >
71- </ button >
72- ) ;
73- } ) }
74- </ div >
75- </ div >
54+ { /* Scrollable filter groups */ }
55+ < ScrollArea className = "flex-1 min-h-0" >
56+ < div className = "px-4 pb-3 space-y-3" >
57+ { /* Node types */ }
58+ { labelCounts . length > 0 && (
59+ < div >
60+ < p className = "text-[10px] font-medium text-foreground/40 mb-1.5 uppercase tracking-wider" > Node types</ p >
61+ < div className = "flex flex-wrap gap-1" >
62+ { labelCounts . map ( ( [ label , count ] ) => {
63+ const on = enabledLabels . has ( label ) ;
64+ const c = colorForLabel ( label ) ;
65+ return (
66+ < button
67+ key = { label }
68+ onClick = { ( ) => onToggleLabel ( label ) }
69+ className = { `inline-flex items-center gap-1 px-1.5 py-[3px] rounded-md text-[10px] font-medium transition-all border ${
70+ on ? "border-white/[0.08] bg-white/[0.04]" : "border-transparent opacity-25"
71+ } `}
72+ >
73+ < span className = "w-[5px] h-[5px] rounded-full" style = { { backgroundColor : on ? c : "#444" } } />
74+ < span style = { { color : on ? c : "#555" } } > { label } </ span >
75+ < span className = "text-foreground/20 tabular-nums" > { count . toLocaleString ( ) } </ span >
76+ </ button >
77+ ) ;
78+ } ) }
79+ </ div >
80+ </ div >
81+ ) }
7682
77- { /* Edge types */ }
78- < div >
79- < p className = "text-[10px] text-foreground/30 mb-1.5" > Edges</ p >
80- < div className = "flex flex-wrap gap-1" >
81- { edgeTypeCounts . map ( ( [ type , count ] ) => {
82- const on = enabledEdgeTypes . has ( type ) ;
83- return (
84- < button
85- key = { type }
86- onClick = { ( ) => onToggleEdgeType ( type ) }
87- className = { `inline-flex items-center gap-1 px-1.5 py-[3px] rounded-md text-[10px] font-medium transition-all border ${
88- on ? "border-white/[0.06] bg-white/[0.03] text-foreground/60" : "border-transparent opacity-20 text-foreground/30"
89- } `}
90- >
91- { type . replace ( / _ / g, " " ) . toLowerCase ( ) }
92- < span className = "text-foreground/15 tabular-nums" > { count . toLocaleString ( ) } </ span >
93- </ button >
94- ) ;
95- } ) }
83+ { /* Relationships */ }
84+ { edgeTypeCounts . length > 0 && (
85+ < div >
86+ < p className = "text-[10px] font-medium text-foreground/40 mb-1.5 uppercase tracking-wider" > Relationships</ p >
87+ < div className = "flex flex-wrap gap-1" >
88+ { edgeTypeCounts . map ( ( [ type , count ] ) => {
89+ const on = enabledEdgeTypes . has ( type ) ;
90+ return (
91+ < button
92+ key = { type }
93+ onClick = { ( ) => onToggleEdgeType ( type ) }
94+ className = { `inline-flex items-center gap-1 px-1.5 py-[3px] rounded-md text-[10px] font-medium transition-all border ${
95+ on ? "border-white/[0.06] bg-white/[0.03] text-foreground/60" : "border-transparent opacity-20 text-foreground/30"
96+ } `}
97+ >
98+ { type . replace ( / _ / g, " " ) . toLowerCase ( ) }
99+ < span className = "text-foreground/15 tabular-nums" > { count . toLocaleString ( ) } </ span >
100+ </ button >
101+ ) ;
102+ } ) }
103+ </ div >
104+ </ div >
105+ ) }
96106 </ div >
97- </ div >
107+ </ ScrollArea >
98108
99- { /* Show labels toggle */ }
100- < button
101- onClick = { onToggleShowLabels }
102- className = { `inline-flex items-center gap-1.5 text-[11px] font-medium transition-all ${
103- showLabels ? "text-primary" : "text-foreground/30"
104- } `}
105- >
106- < span className = { `w-3.5 h-3.5 rounded border flex items-center justify-center transition-all ${
107- showLabels ? "border-primary bg-primary/20" : "border-foreground/15"
108- } `} >
109- { showLabels && < span className = "text-primary text-[9px]" > ✓</ span > }
110- </ span >
111- Show labels
112- </ button >
109+ { /* Display options — pinned footer */ }
110+ < div className = "px-4 py-2.5 border-t border-border/20 shrink-0" >
111+ < button
112+ onClick = { onToggleShowLabels }
113+ className = { `inline-flex items-center gap-1.5 text-[11px] font-medium transition-all ${
114+ showLabels ? "text-primary" : "text-foreground/30"
115+ } `}
116+ >
117+ < span className = { `w-3.5 h-3.5 rounded border flex items-center justify-center transition-all ${
118+ showLabels ? "border-primary bg-primary/20" : "border-foreground/15"
119+ } `} >
120+ { showLabels && < span className = "text-primary text-[9px]" > ✓</ span > }
121+ </ span >
122+ Show labels
123+ </ button >
124+ </ div >
113125 </ div >
114126 ) ;
115127}
0 commit comments