Skip to content

Commit 8ea4291

Browse files
committed
feat(graph-ui): scrollable filter panel with clearer grouping
Cap the filter panel height and move the node and edge chips into a scroll area so a long type list no longer pushes the folder tree off screen. Regroup the chips under Node types and Relationships, pin the show-labels toggle as a footer, and add a Folders heading (en and zh) above the folder tree so the section is clearly labelled. Signed-off-by: Zadak <rarepops@protonmail.com>
1 parent 54efcef commit 8ea4291

3 files changed

Lines changed: 80 additions & 61 deletions

File tree

Lines changed: 72 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useMemo } from "react";
2+
import { ScrollArea } from "@/components/ui/scroll-area";
23
import { colorForLabel } from "../lib/colors";
34
import 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
}

‎graph-ui/src/components/Sidebar.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ export function Sidebar({ nodes, onSelectPath, selectedPath }: SidebarProps) {
120120

121121
return (
122122
<div className="flex flex-col flex-1 min-h-0">
123-
<div className="px-3 py-2.5 border-b border-border/30">
123+
<div className="px-4 pt-3 pb-2 shrink-0">
124+
<span className="text-[11px] font-medium text-foreground/50 uppercase tracking-widest">
125+
{t.graph.folders}
126+
</span>
127+
</div>
128+
<div className="px-3 pb-2.5 border-b border-border/30 shrink-0">
124129
<div className="relative">
125130
<input
126131
type="text"

‎graph-ui/src/lib/i18n.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const messages = {
2323
selectedLabel: "Graph",
2424
search: "Search...",
2525
clearSelection: "Clear selection",
26+
folders: "Folders",
2627
},
2728
projects: {
2829
indexedProjects: "Indexed Projects",
@@ -95,6 +96,7 @@ export const messages = {
9596
selectedLabel: "图谱",
9697
search: "搜索...",
9798
clearSelection: "清除选择",
99+
folders: "目录",
98100
},
99101
projects: {
100102
indexedProjects: "已索引项目",

0 commit comments

Comments
 (0)