Skip to content

Commit 009be72

Browse files
feat(Select): add preliminary required behaviour
Co-authored-by: Jack Shelton <[email protected]>
1 parent 79b4b5f commit 009be72

File tree

28 files changed

+348
-576
lines changed

28 files changed

+348
-576
lines changed

apps/website/src/routes/docs/headless/(components)/select/examples.tsx

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,57 @@ export const Example01 = component$(() => {
1515
return (
1616
<PreviewCodeExample>
1717
<div q:slot="actualComponent">
18-
<SelectRoot>
19-
<SelectLabel class=" font-semibold ml-2 text-[#333333] dark:text-white">
20-
Qwik Fruits
21-
</SelectLabel>
22-
<SelectTrigger class="flex justify-between items-center px-8 bg-[#1f2532] border-[#7d95b3] border-[1px] rounded-md p-4 group peer">
23-
<SelectValue placeholder="Select a fruit! 🍹" class="text-white" />
24-
<SelectMarker class="w-6 h-6">
25-
<svg
26-
xmlns="http://www.w3.org/2000/svg"
27-
viewBox="0 0 24 24"
28-
fill="none"
29-
stroke-width="2"
30-
class="stroke-white group-aria-expanded:-rotate-180 transition-transform duration-[450ms]"
31-
stroke-linecap="round"
32-
stroke-linejoin="round"
33-
>
34-
<polyline points="6 9 12 15 18 9"></polyline>
35-
</svg>
36-
</SelectMarker>
37-
</SelectTrigger>
38-
<SelectListBox class="bg-[#1f2532] border-[#7d95b3] mt-2 border-[1px] rounded-md text-white">
39-
<SelectOption
40-
value="🚀 Qwik"
41-
class="p-4 hover:bg-[#496080] focus:bg-[#496080]"
42-
/>
43-
<SelectGroup class="p-4">
44-
<SelectLabel class="p-4">Fruits</SelectLabel>
45-
{[
46-
{ value: '🍎 Apple', disabled: false },
47-
{ value: '🍌 Banana', disabled: false },
48-
{ value: '🍒 Cherry', disabled: false },
49-
{ value: '🐲 Dragonfruit', disabled: true },
50-
].map((option) => {
51-
return (
52-
<SelectOption
53-
key={option.value}
54-
value={option.value}
55-
disabled={option.disabled}
56-
class="hover:bg-[#496080] focus:bg-[#496080] aria-disabled:text-red-500 aria-disabled:cursor-not-allowed rounded-sm p-4"
57-
/>
58-
);
59-
})}
60-
</SelectGroup>
61-
</SelectListBox>
62-
</SelectRoot>
18+
<form>
19+
<SelectRoot required>
20+
<SelectLabel class=" font-semibold ml-2 text-[#333333] dark:text-white">
21+
Qwik Fruits
22+
</SelectLabel>
23+
<SelectTrigger class="flex justify-between items-center px-8 bg-[#1f2532] border-[#7d95b3] border-[1px] rounded-md p-4 group peer">
24+
<SelectValue
25+
placeholder="Select a fruit! 🍹"
26+
class="text-white"
27+
/>
28+
<SelectMarker class="w-6 h-6">
29+
<svg
30+
xmlns="http://www.w3.org/2000/svg"
31+
viewBox="0 0 24 24"
32+
fill="none"
33+
stroke-width="2"
34+
class="stroke-white group-aria-expanded:-rotate-180 transition-transform duration-[450ms]"
35+
stroke-linecap="round"
36+
stroke-linejoin="round"
37+
>
38+
<polyline points="6 9 12 15 18 9"></polyline>
39+
</svg>
40+
</SelectMarker>
41+
</SelectTrigger>
42+
<SelectListBox class="bg-[#1f2532] border-[#7d95b3] mt-2 border-[1px] rounded-md text-white">
43+
<SelectOption
44+
optionValue="🚀 Qwik"
45+
class="p-4 hover:bg-[#496080] focus:bg-[#496080]"
46+
/>
47+
<SelectGroup class="p-4">
48+
<SelectLabel class="p-4">Fruits</SelectLabel>
49+
{[
50+
{ value: '🍎 Apple', disabled: false },
51+
{ value: '🍌 Banana', disabled: false },
52+
{ value: '🍒 Cherry', disabled: false },
53+
{ value: '🐲 Dragonfruit', disabled: true },
54+
].map((option) => {
55+
return (
56+
<SelectOption
57+
key={option.value}
58+
optionValue={option.value}
59+
disabled={option.disabled}
60+
class="hover:bg-[#496080] focus:bg-[#496080] aria-disabled:text-red-500 aria-disabled:cursor-not-allowed rounded-sm p-4"
61+
/>
62+
);
63+
})}
64+
</SelectGroup>
65+
</SelectListBox>
66+
</SelectRoot>
67+
<button>Submit</button>
68+
</form>
6369
</div>
6470

6571
<div q:slot="codeExample">
@@ -94,9 +100,9 @@ export const Example02 = component$(() => {
94100
</SelectMarker>
95101
</SelectTrigger>
96102
<SelectListBox class="bg-slate-100 dark:bg-gray-700 border-slate-200 dark:border-gray-600 border-[1px]">
97-
<SelectOption value="Orders" class="p-4" />
98-
<SelectOption value="Settings" class="p-4" />
99-
<SelectOption value="Contact us" class="p-4" />
103+
<SelectOption optionValue="Orders" class="p-4" />
104+
<SelectOption optionValue="Settings" class="p-4" />
105+
<SelectOption optionValue="Contact us" class="p-4" />
100106
</SelectListBox>
101107
</SelectRoot>
102108
</div>

0 commit comments

Comments
 (0)