|
| 1 | +import { Slot, component$, useId } from '@builder.io/qwik'; |
| 2 | +import { |
| 3 | + Root, |
| 4 | + Label, |
| 5 | + Trigger, |
| 6 | + Value, |
| 7 | + Marker, |
| 8 | + ListBox, |
| 9 | + Option, |
| 10 | + Group, |
| 11 | +} from '@qwik-ui/headless'; |
| 12 | +import { PreviewCodeExample } from 'apps/website/src/components/preview-code-example/preview-code-example'; |
| 13 | + |
| 14 | +export const Example01 = component$(() => { |
| 15 | + return ( |
| 16 | + <PreviewCodeExample> |
| 17 | + <div q:slot="actualComponent"> |
| 18 | + <Root> |
| 19 | + <Label class="text-black dark:text-white"> |
| 20 | + Lorem ipsum dolor sit amet |
| 21 | + </Label> |
| 22 | + <Trigger class="flex justify-between items-center border-slate-200 dark:border-gray-600 border-[1px] p-4"> |
| 23 | + <Value placeholder="Select an option! ⚡" /> |
| 24 | + <Marker 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="currentColor" |
| 30 | + stroke-width="2" |
| 31 | + stroke-linecap="round" |
| 32 | + stroke-linejoin="round" |
| 33 | + > |
| 34 | + <polyline points="6 9 12 15 18 9"></polyline> |
| 35 | + </svg> |
| 36 | + </Marker> |
| 37 | + </Trigger> |
| 38 | + <ListBox class="bg-slate-100 dark:bg-gray-700 border-slate-200 dark:border-gray-600 border-[1px]"> |
| 39 | + <Option value="🚀 Qwik" class="p-4" /> |
| 40 | + <Group class="p-4"> |
| 41 | + <Label class="p-4">Fruits</Label> |
| 42 | + {[ |
| 43 | + { value: '🍎 Apple', disabled: false }, |
| 44 | + { value: '🍌 Banana', disabled: false }, |
| 45 | + { value: '🍒 Cherry', disabled: false }, |
| 46 | + { value: '🐲 Dragonfruit', disabled: true }, |
| 47 | + ].map((option) => { |
| 48 | + return ( |
| 49 | + <Option |
| 50 | + key={useId()} |
| 51 | + value={option.value} |
| 52 | + disabled={option.disabled} |
| 53 | + class="aria-disabled:text-red-500 aria-disabled:cursor-not-allowed hover:bg-slate-300 dark:hover:bg-gray-600 p-4" |
| 54 | + /> |
| 55 | + ); |
| 56 | + })} |
| 57 | + </Group> |
| 58 | + </ListBox> |
| 59 | + </Root> |
| 60 | + </div> |
| 61 | + |
| 62 | + <div q:slot="codeExample"> |
| 63 | + <Slot /> |
| 64 | + </div> |
| 65 | + </PreviewCodeExample> |
| 66 | + ); |
| 67 | +}); |
| 68 | + |
| 69 | +export const Example02 = component$(() => { |
| 70 | + return ( |
| 71 | + <PreviewCodeExample> |
| 72 | + <div q:slot="actualComponent"> |
| 73 | + <Root> |
| 74 | + <Trigger class="flex justify-between items-center border-slate-200 dark:border-gray-600 border-[1px] p-4"> |
| 75 | + <Value placeholder="Home" /> |
| 76 | + <Marker class="w-6 h-6"> |
| 77 | + <svg |
| 78 | + xmlns="http://www.w3.org/2000/svg" |
| 79 | + viewBox="0 0 24 24" |
| 80 | + fill="none" |
| 81 | + stroke="currentColor" |
| 82 | + stroke-width="2" |
| 83 | + stroke-linecap="round" |
| 84 | + stroke-linejoin="round" |
| 85 | + > |
| 86 | + <polyline points="6 9 12 15 18 9"></polyline> |
| 87 | + </svg> |
| 88 | + </Marker> |
| 89 | + </Trigger> |
| 90 | + <ListBox class="bg-slate-100 dark:bg-gray-700 border-slate-200 dark:border-gray-600 border-[1px]"> |
| 91 | + <Option value="Orders" class="p-4" /> |
| 92 | + <Option value="Settings" class="p-4" /> |
| 93 | + <Option value="Contact us" class="p-4" /> |
| 94 | + </ListBox> |
| 95 | + </Root> |
| 96 | + </div> |
| 97 | + |
| 98 | + <div q:slot="codeExample"> |
| 99 | + <Slot /> |
| 100 | + </div> |
| 101 | + </PreviewCodeExample> |
| 102 | + ); |
| 103 | +}); |
0 commit comments