Skip to content

Commit 9af53ca

Browse files
committed
feat: add selectors for edam version and concepts
Includes necessary shadcn/ui components and its deps
1 parent d96f7c2 commit 9af53ca

File tree

6 files changed

+279
-0
lines changed

6 files changed

+279
-0
lines changed

bun.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@radix-ui/react-dropdown-menu": "^2.1.14",
14+
"@radix-ui/react-select": "^2.2.4",
1415
"@radix-ui/react-slot": "^1.2.2",
1516
"@tailwindcss/vite": "^4.1.5",
1617
"@tanstack/react-query": "^5.75.6",

src/components/app-header.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import edamLogo from "/edam-logo.png";
22
import { ThemeToggle } from "./theme-toggle";
33
import { Link } from "lucide-react";
44
import GitHub from "@/assets/svg/github";
5+
import { EdamVersionSelector } from "./edam-version-selector";
6+
import { EdamConceptSelector } from "./edam-concept-selector";
57

68
export function AppHeader() {
79
return (
@@ -33,6 +35,11 @@ export function AppHeader() {
3335
</li>
3436
</li>
3537
</ul>
38+
</div>
39+
<div className="flex flex-row gap-0">
40+
<EdamVersionSelector />
41+
<EdamConceptSelector />
42+
</div>
3643
<div className="ml-auto content-center">
3744
<ThemeToggle />
3845
</div>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import {
2+
Select,
3+
SelectContent,
4+
SelectGroup,
5+
SelectItem,
6+
SelectSeparator,
7+
SelectTrigger,
8+
SelectValue,
9+
} from "@/components/ui/select";
10+
import { useState } from "react";
11+
12+
export function EdamConceptSelector() {
13+
const [concept, setConcept] = useState<string>("All EDAM");
14+
return (
15+
<Select onValueChange={setConcept}>
16+
<SelectTrigger>
17+
<SelectValue placeholder={concept} />
18+
</SelectTrigger>
19+
<SelectContent>
20+
<SelectGroup>
21+
<SelectItem value="all">All EDAM</SelectItem>
22+
</SelectGroup>
23+
<SelectSeparator />
24+
<SelectGroup>
25+
<SelectItem value="data">Only Data</SelectItem>
26+
<SelectItem value="format">Only Format</SelectItem>
27+
<SelectItem value="operation">Only Operation</SelectItem>
28+
<SelectItem value="topic">Only Topic</SelectItem>
29+
</SelectGroup>
30+
<SelectSeparator />
31+
<SelectGroup>
32+
<SelectItem value="deprecated">Only Deprecated </SelectItem>
33+
<SelectItem value="all-deprecated">Only Deprecated </SelectItem>
34+
</SelectGroup>
35+
</SelectContent>
36+
</Select>
37+
);
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import {
2+
Select,
3+
SelectContent,
4+
SelectGroup,
5+
SelectItem,
6+
SelectSeparator,
7+
SelectTrigger,
8+
SelectValue,
9+
} from "@/components/ui/select";
10+
11+
const edamVersions = ["latest (unstable)", "1.25 (stable)", "1.24", "1.23"];
12+
13+
export function EdamVersionSelector() {
14+
return (
15+
<Select>
16+
<SelectTrigger>
17+
<SelectValue placeholder="1.25 (stable)" />
18+
</SelectTrigger>
19+
<SelectContent>
20+
<SelectGroup>
21+
{edamVersions.map((version) => (
22+
<SelectItem key={version} value={version}>
23+
{version}
24+
</SelectItem>
25+
))}
26+
</SelectGroup>
27+
<SelectSeparator />
28+
<SelectGroup>
29+
<SelectItem value="bioimaging">
30+
Fork BioImaging (latest, unstable)
31+
</SelectItem>
32+
<SelectItem value="geo">Frok Geo (latest, unstable)</SelectItem>
33+
</SelectGroup>
34+
<SelectSeparator />
35+
<SelectGroup>
36+
<SelectItem value="custom">Custom</SelectItem>
37+
</SelectGroup>
38+
</SelectContent>
39+
</Select>
40+
);
41+
}

src/components/ui/select.tsx

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import * as React from "react"
2+
import * as SelectPrimitive from "@radix-ui/react-select"
3+
import { CheckIcon, ChevronDownIcon, ChevronUpIcon } from "lucide-react"
4+
5+
import { cn } from "@/lib/utils"
6+
7+
function Select({
8+
...props
9+
}: React.ComponentProps<typeof SelectPrimitive.Root>) {
10+
return <SelectPrimitive.Root data-slot="select" {...props} />
11+
}
12+
13+
function SelectGroup({
14+
...props
15+
}: React.ComponentProps<typeof SelectPrimitive.Group>) {
16+
return <SelectPrimitive.Group data-slot="select-group" {...props} />
17+
}
18+
19+
function SelectValue({
20+
...props
21+
}: React.ComponentProps<typeof SelectPrimitive.Value>) {
22+
return <SelectPrimitive.Value data-slot="select-value" {...props} />
23+
}
24+
25+
function SelectTrigger({
26+
className,
27+
size = "default",
28+
children,
29+
...props
30+
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
31+
size?: "sm" | "default"
32+
}) {
33+
return (
34+
<SelectPrimitive.Trigger
35+
data-slot="select-trigger"
36+
data-size={size}
37+
className={cn(
38+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
39+
className
40+
)}
41+
{...props}
42+
>
43+
{children}
44+
<SelectPrimitive.Icon asChild>
45+
<ChevronDownIcon className="size-4 opacity-50" />
46+
</SelectPrimitive.Icon>
47+
</SelectPrimitive.Trigger>
48+
)
49+
}
50+
51+
function SelectContent({
52+
className,
53+
children,
54+
position = "popper",
55+
...props
56+
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
57+
return (
58+
<SelectPrimitive.Portal>
59+
<SelectPrimitive.Content
60+
data-slot="select-content"
61+
className={cn(
62+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
63+
position === "popper" &&
64+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
65+
className
66+
)}
67+
position={position}
68+
{...props}
69+
>
70+
<SelectScrollUpButton />
71+
<SelectPrimitive.Viewport
72+
className={cn(
73+
"p-1",
74+
position === "popper" &&
75+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
76+
)}
77+
>
78+
{children}
79+
</SelectPrimitive.Viewport>
80+
<SelectScrollDownButton />
81+
</SelectPrimitive.Content>
82+
</SelectPrimitive.Portal>
83+
)
84+
}
85+
86+
function SelectLabel({
87+
className,
88+
...props
89+
}: React.ComponentProps<typeof SelectPrimitive.Label>) {
90+
return (
91+
<SelectPrimitive.Label
92+
data-slot="select-label"
93+
className={cn("text-muted-foreground px-2 py-1.5 text-xs", className)}
94+
{...props}
95+
/>
96+
)
97+
}
98+
99+
function SelectItem({
100+
className,
101+
children,
102+
...props
103+
}: React.ComponentProps<typeof SelectPrimitive.Item>) {
104+
return (
105+
<SelectPrimitive.Item
106+
data-slot="select-item"
107+
className={cn(
108+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
109+
className
110+
)}
111+
{...props}
112+
>
113+
<span className="absolute right-2 flex size-3.5 items-center justify-center">
114+
<SelectPrimitive.ItemIndicator>
115+
<CheckIcon className="size-4" />
116+
</SelectPrimitive.ItemIndicator>
117+
</span>
118+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
119+
</SelectPrimitive.Item>
120+
)
121+
}
122+
123+
function SelectSeparator({
124+
className,
125+
...props
126+
}: React.ComponentProps<typeof SelectPrimitive.Separator>) {
127+
return (
128+
<SelectPrimitive.Separator
129+
data-slot="select-separator"
130+
className={cn("bg-border pointer-events-none -mx-1 my-1 h-px", className)}
131+
{...props}
132+
/>
133+
)
134+
}
135+
136+
function SelectScrollUpButton({
137+
className,
138+
...props
139+
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>) {
140+
return (
141+
<SelectPrimitive.ScrollUpButton
142+
data-slot="select-scroll-up-button"
143+
className={cn(
144+
"flex cursor-default items-center justify-center py-1",
145+
className
146+
)}
147+
{...props}
148+
>
149+
<ChevronUpIcon className="size-4" />
150+
</SelectPrimitive.ScrollUpButton>
151+
)
152+
}
153+
154+
function SelectScrollDownButton({
155+
className,
156+
...props
157+
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>) {
158+
return (
159+
<SelectPrimitive.ScrollDownButton
160+
data-slot="select-scroll-down-button"
161+
className={cn(
162+
"flex cursor-default items-center justify-center py-1",
163+
className
164+
)}
165+
{...props}
166+
>
167+
<ChevronDownIcon className="size-4" />
168+
</SelectPrimitive.ScrollDownButton>
169+
)
170+
}
171+
172+
export {
173+
Select,
174+
SelectContent,
175+
SelectGroup,
176+
SelectItem,
177+
SelectLabel,
178+
SelectScrollDownButton,
179+
SelectScrollUpButton,
180+
SelectSeparator,
181+
SelectTrigger,
182+
SelectValue,
183+
}

0 commit comments

Comments
 (0)