|
1 |
| -import { |
2 |
| - Combobox, |
3 |
| - ComboboxControl, |
4 |
| - ComboboxIcon, |
5 |
| - ComboboxInput, |
6 |
| - ComboboxLabel, |
7 |
| - ComboboxListbox, |
8 |
| - ComboboxOption, |
9 |
| - ComboboxPopover, |
10 |
| - ComboboxTrigger, |
11 |
| - ResolvedOption, |
12 |
| -} from '@qwik-ui/headless'; |
13 |
| - |
14 |
| -import { component$ } from '@builder.io/qwik'; |
| 1 | +import { component$, useSignal } from '@builder.io/qwik'; |
| 2 | +import { Popover, PopoverTrigger } from '@qwik-ui/headless'; |
15 | 3 |
|
16 | 4 | export default component$(() => {
|
17 |
| - const streets = [ |
18 |
| - 'Baker Street', |
19 |
| - 'Fleet Street', |
20 |
| - 'Wall Street', |
21 |
| - 'Broadway', |
22 |
| - 'Sunset Boulevard', |
23 |
| - 'Rodeo Drive', |
24 |
| - 'Abbey Road', |
25 |
| - ]; |
| 5 | + const triggerRef = useSignal<HTMLButtonElement>(); |
| 6 | + const popoverRef = useSignal<HTMLElement>(); |
26 | 7 |
|
27 | 8 | return (
|
28 |
| - <Combobox |
29 |
| - class="w-fit" |
30 |
| - options={streets} |
31 |
| - filter$={(value: string, options) => |
32 |
| - options.filter(({ option }) => { |
33 |
| - return option.toLowerCase().startsWith(value.toLowerCase()); |
34 |
| - }) |
35 |
| - } |
36 |
| - > |
37 |
| - <ComboboxLabel class="w-44 font-semibold text-white"> |
38 |
| - I'm between gutters! |
39 |
| - </ComboboxLabel> |
40 |
| - <ComboboxControl class="relative flex items-center rounded-base border-[1px] border-slate-400 bg-[#1f2532]"> |
41 |
| - <ComboboxInput |
42 |
| - class="px-d2 w-44 rounded-base bg-slate-900 px-2 pr-6 text-white placeholder:text-slate-500" |
43 |
| - placeholder="Wallaby Rd." |
44 |
| - /> |
45 |
| - <ComboboxTrigger class="group absolute right-0 h-6 w-6"> |
46 |
| - <ComboboxIcon class="stroke-white transition-transform duration-500 group-aria-expanded:-rotate-180" /> |
47 |
| - </ComboboxTrigger> |
48 |
| - </ComboboxControl> |
49 |
| - <ComboboxPopover gutter={24}> |
50 |
| - <ComboboxListbox |
51 |
| - class="w-44 rounded-base border-[1px] border-slate-400 bg-slate-900 px-4 py-2" |
52 |
| - optionRenderer$={(option: ResolvedOption, index: number) => ( |
53 |
| - <ComboboxOption |
54 |
| - key={option.key} |
55 |
| - class="group rounded-base border-2 border-transparent px-2 text-white hover:bg-slate-500 aria-disabled:text-slate-600 aria-disabled:hover:bg-slate-700 aria-selected:border-slate-200 aria-selected:bg-slate-500" |
56 |
| - index={index} |
57 |
| - resolved={option} |
58 |
| - > |
59 |
| - {option.label} |
60 |
| - </ComboboxOption> |
61 |
| - )} |
62 |
| - /> |
63 |
| - </ComboboxPopover> |
64 |
| - </Combobox> |
| 9 | + <> |
| 10 | + <div class="flex flex-col items-center justify-center gap-2"> |
| 11 | + <p>gutter of 40px!</p> |
| 12 | + <PopoverTrigger |
| 13 | + ref={triggerRef} |
| 14 | + popoverTargetAction="show" |
| 15 | + popovertarget="gutter-id" |
| 16 | + class="popover-trigger" |
| 17 | + > |
| 18 | + Click me |
| 19 | + </PopoverTrigger> |
| 20 | + </div> |
| 21 | + |
| 22 | + <Popover |
| 23 | + ref={popoverRef} |
| 24 | + anchorRef={triggerRef} |
| 25 | + floating={true} |
| 26 | + placement="top" |
| 27 | + gutter={40} |
| 28 | + id="gutter-id" |
| 29 | + class="popover listbox !p-4" |
| 30 | + > |
| 31 | + I am anchored to the trigger! |
| 32 | + </Popover> |
| 33 | + </> |
65 | 34 | );
|
66 | 35 | });
|
0 commit comments