Skip to content

Commit 3bbb2b3

Browse files
feat(select): bring in new select component
1 parent 8a0f1d2 commit 3bbb2b3

25 files changed

+597
-1261
lines changed

apps/website/src/routes/docs/headless/select/examples/fruits.tsx

Lines changed: 0 additions & 74 deletions
This file was deleted.
Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,33 @@
1-
import { component$ } from '@builder.io/qwik';
2-
import {
3-
SelectListBox,
4-
SelectMarker,
5-
SelectOption,
6-
SelectRoot,
7-
SelectTrigger,
8-
SelectValue,
9-
} from '@qwik-ui/headless';
1+
import { $, component$, useSignal, useTask$ } from '@builder.io/qwik';
2+
import { Select, SelectListbox, SelectOption, SelectTrigger } from '@qwik-ui/headless';
103

114
export default component$(() => {
12-
const fruitArray = [
13-
{ value: 'Apple 🍎', disabled: false },
14-
{ value: 'Banana 🍌', disabled: false },
15-
{ value: 'Cherry 🍒', disabled: false },
16-
{ value: 'Dragonfruit 🐲', disabled: true },
17-
];
5+
const mockUsers = ['Tim', 'Ryan', 'Jim'];
6+
const moreUsers = ['Carla', 'Rachel', 'Monica', 'Jessie', 'Abby'];
7+
8+
const usersSig = useSignal<string[]>([]);
9+
10+
useTask$(async () => {
11+
usersSig.value = mockUsers;
12+
});
13+
14+
const handleClick$ = $(() => {
15+
usersSig.value = [...usersSig.value, ...moreUsers];
16+
});
1817

1918
return (
20-
<>
21-
<div>
22-
<SelectRoot>
23-
<SelectTrigger class="group peer flex items-center justify-between rounded-md border p-4 px-8">
24-
<SelectValue placeholder="Select a fruit! 🍹" />
25-
<SelectMarker class="h-6 w-6">
26-
<svg
27-
xmlns="http://www.w3.org/2000/svg"
28-
viewBox="0 0 24 24"
29-
fill="none"
30-
stroke-width="2"
31-
class="stroke-foreground transition-transform duration-[450ms] group-aria-expanded:-rotate-180"
32-
stroke-linecap="round"
33-
stroke-linejoin="round"
34-
>
35-
<polyline points="6 9 12 15 18 9"></polyline>
36-
</svg>
37-
</SelectMarker>
38-
</SelectTrigger>
39-
<SelectListBox class="bg-background mt-2 rounded-md border">
40-
<SelectOption
41-
optionValue="Qwik 🚀 "
42-
class="hover:bg-accent focus:bg-accent p-4"
43-
>
44-
Qwik 🚀
45-
</SelectOption>
46-
{fruitArray.map((option) => {
47-
return (
48-
<SelectOption
49-
key={option.value}
50-
optionValue={option.value.toString()}
51-
disabled={option.disabled}
52-
class="hover:bg-accent aria-disabled:text-muted-foreground aria-disabled:bg-muted rounded-sm p-4 aria-disabled:cursor-not-allowed"
53-
>
54-
{option.value}
55-
</SelectOption>
56-
);
57-
})}
58-
</SelectListBox>
59-
</SelectRoot>
60-
</div>
61-
</>
19+
<div>
20+
<Select>
21+
<SelectTrigger>Trigger</SelectTrigger>
22+
<SelectListbox style={{ padding: '0px', margin: '0px', listStyle: 'none' }}>
23+
<SelectOption disabled>My option</SelectOption>
24+
{usersSig.value.map((user) => (
25+
<SelectOption key={user}>{user}</SelectOption>
26+
))}
27+
</SelectListbox>
28+
</Select>
29+
{/* somehow this adds more js on page load? / wakes up the framework? */}
30+
<button onClick$={handleClick$}>Add more!</button>
31+
</div>
6232
);
6333
});

apps/website/src/routes/docs/headless/select/examples/navbar-menu.tsx

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)