Skip to content

Commit fccf147

Browse files
docs(popover & combobox): docs improvements
1 parent e3427db commit fccf147

File tree

7 files changed

+124
-89
lines changed

7 files changed

+124
-89
lines changed

apps/website/src/components/api-table/api-table.tsx

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { component$ } from '@builder.io/qwik';
2+
import { InfoPopup } from '../info-popup/info-popup';
23
type APITableProps = {
34
propDescriptors: {
45
name: string;
@@ -31,41 +32,12 @@ export const APITable = component$(({ propDescriptors }: APITableProps) => {
3132
</code>
3233
</td>
3334
<td class="py-3">
34-
<span class="flex items-center">
35+
<div class="flex items-center gap-2">
3536
<code class="rounded-md border border-b-2 px-2">
3637
{propDescriptor.type}
3738
</code>
38-
{propDescriptor.info && (
39-
// <Popover placement="top">
40-
// <PopoverContent>
41-
// <div class="shadow-light-medium bg-qwikui-blue-50 dark:shadow-dark-high text-md border-qwikui-blue-500 dark:border-qwikui-purple-500 dark:bg-qwikui-purple-100 mb-2 max-w-xs rounded-lg border-[1px] border-b-2 px-3 py-2 font-[500] text-slate-950 sm:w-max">
42-
// {propDescriptor?.info}
43-
// </div>
44-
// </PopoverContent>
45-
// <PopoverTrigger>
46-
// <div class="mx-2 mt-2 rounded-md rounded-xl p-1 hover:bg-slate-500 hover:bg-opacity-50">
47-
// <svg
48-
// width="15"
49-
// height="15"
50-
// viewBox="0 0 15 15"
51-
// fill="none"
52-
// xmlns="http://www.w3.org/2000/svg"
53-
// aria-hidden="true"
54-
// focusable="false"
55-
// >
56-
// <path
57-
// d="M7.49991 0.876892C3.84222 0.876892 0.877075 3.84204 0.877075 7.49972C0.877075 11.1574 3.84222 14.1226 7.49991 14.1226C11.1576 14.1226 14.1227 11.1574 14.1227 7.49972C14.1227 3.84204 11.1576 0.876892 7.49991 0.876892ZM1.82707 7.49972C1.82707 4.36671 4.36689 1.82689 7.49991 1.82689C10.6329 1.82689 13.1727 4.36671 13.1727 7.49972C13.1727 10.6327 10.6329 13.1726 7.49991 13.1726C4.36689 13.1726 1.82707 10.6327 1.82707 7.49972ZM8.24992 4.49999C8.24992 4.9142 7.91413 5.24999 7.49992 5.24999C7.08571 5.24999 6.74992 4.9142 6.74992 4.49999C6.74992 4.08577 7.08571 3.74999 7.49992 3.74999C7.91413 3.74999 8.24992 4.08577 8.24992 4.49999ZM6.00003 5.99999H6.50003H7.50003C7.77618 5.99999 8.00003 6.22384 8.00003 6.49999V9.99999H8.50003H9.00003V11H8.50003H7.50003H6.50003H6.00003V9.99999H6.50003H7.00003V6.99999H6.50003H6.00003V5.99999Z"
58-
// fill="currentColor"
59-
// fill-rule="evenodd"
60-
// clip-rule="evenodd"
61-
// ></path>
62-
// </svg>
63-
// </div>{' '}
64-
// </PopoverTrigger>
65-
// </Popover>
66-
<div>popover placeholder</div>
67-
)}
68-
</span>
39+
{propDescriptor.info && <InfoPopup info={propDescriptor.info} />}
40+
</div>
6941
</td>
7042
<td class="py-3 align-baseline">
7143
<div class="prose prose-sm prose-docs-table px-2">
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import { component$, useId, useSignal, useStyles$ } from '@builder.io/qwik';
2+
import { Popover, PopoverTrigger } from '@qwik-ui/headless';
3+
4+
type InfoProps = {
5+
info: string;
6+
};
7+
8+
export const InfoPopup = component$((props: InfoProps) => {
9+
const popoverTableId = useId();
10+
const triggerRef = useSignal<HTMLButtonElement>();
11+
const popoverRef = useSignal<HTMLElement>();
12+
13+
useStyles$(`
14+
.fade-info {
15+
transition: opacity 0.35s, display 0.35s, overlay 0.35s;
16+
transition-behavior: allow-discrete;
17+
opacity: 0;
18+
}
19+
20+
.popover-showing {
21+
opacity: 1;
22+
}
23+
24+
.popover-closing {
25+
opacity: 0;
26+
}
27+
`);
28+
29+
return (
30+
<>
31+
<PopoverTrigger
32+
ref={triggerRef}
33+
popoverTargetAction="show"
34+
popovertarget={popoverTableId}
35+
class="flex items-center justify-center"
36+
>
37+
<div class="rounded-full p-1 hover:bg-slate-300 hover:bg-opacity-50">
38+
<svg
39+
width="16"
40+
height="16"
41+
viewBox="0 0 15 15"
42+
fill="none"
43+
xmlns="http://www.w3.org/2000/svg"
44+
aria-hidden="true"
45+
focusable="false"
46+
>
47+
<path
48+
d="M7.49991 0.876892C3.84222 0.876892 0.877075 3.84204 0.877075 7.49972C0.877075 11.1574 3.84222 14.1226 7.49991 14.1226C11.1576 14.1226 14.1227 11.1574 14.1227 7.49972C14.1227 3.84204 11.1576 0.876892 7.49991 0.876892ZM1.82707 7.49972C1.82707 4.36671 4.36689 1.82689 7.49991 1.82689C10.6329 1.82689 13.1727 4.36671 13.1727 7.49972C13.1727 10.6327 10.6329 13.1726 7.49991 13.1726C4.36689 13.1726 1.82707 10.6327 1.82707 7.49972ZM8.24992 4.49999C8.24992 4.9142 7.91413 5.24999 7.49992 5.24999C7.08571 5.24999 6.74992 4.9142 6.74992 4.49999C6.74992 4.08577 7.08571 3.74999 7.49992 3.74999C7.91413 3.74999 8.24992 4.08577 8.24992 4.49999ZM6.00003 5.99999H6.50003H7.50003C7.77618 5.99999 8.00003 6.22384 8.00003 6.49999V9.99999H8.50003H9.00003V11H8.50003H7.50003H6.50003H6.00003V9.99999H6.50003H7.00003V6.99999H6.50003H6.00003V5.99999Z"
49+
fill="currentColor"
50+
fill-rule="evenodd"
51+
clip-rule="evenodd"
52+
></path>
53+
</svg>
54+
</div>
55+
</PopoverTrigger>
56+
57+
<Popover
58+
ref={popoverRef}
59+
anchorRef={triggerRef}
60+
floating={true}
61+
flip={false}
62+
placement="top"
63+
gutter={4}
64+
id={popoverTableId}
65+
class="fade-info listbox rounded-md bg-transparent"
66+
>
67+
<div class="shadow-light-medium bg-qwikui-blue-50 dark:shadow-dark-high text-md border-qwikui-blue-500 dark:border-qwikui-purple-500 dark:bg-qwikui-purple-100 bg-primary mb-2 max-w-xs rounded-lg border-[1px] border-b-2 px-3 py-2 font-[500] text-slate-950 sm:w-max">
68+
{props.info}
69+
</div>
70+
</Popover>
71+
</>
72+
);
73+
});

apps/website/src/routes/docs/headless/combobox/index.mdx

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: Qwik UI | Combobox
33
---
44

55
import { statusByComponent } from '~/_state/component-statuses';
6+
import { FeatureList } from '~/components/feature-list/feature-list';
67

78
<StatusBanner status={statusByComponent.headless.Combobox} />
89

@@ -25,14 +26,18 @@ Qwik UI's Combobox implementation follows the [WAI-Aria Combobox specifications]
2526

2627
## ✨ Features
2728

28-
- Full WAI-Aria compliance
29-
- Full keyboard navigation
30-
- Custom Autocomplete behavior
31-
- Custom filter functionality
32-
- Controlled or uncontrolled
33-
- Supports disabled options
34-
- Custom signal binds
35-
- Animatable, dynamic, and resumable
29+
<FeatureList
30+
features={[
31+
'Full WAI-Aria compliance',
32+
'Full keyboard navigation',
33+
'Custom Autocomplete behavior',
34+
'Custom filter functionality',
35+
'Controlled or uncontrolled',
36+
'Supports disabled options',
37+
'Custom signal binds',
38+
'Animatable, dynamic, and resumable',
39+
]}
40+
/>
3641

3742
<br />
3843

@@ -182,18 +187,6 @@ This can get tedious if certain custom behavior needs to be added, or the listbo
182187

183188
To disable this behavior, set `disableOnBlur={true}` on the Input.
184189

185-
## **Configuring the Listbox**
186-
187-
The `ComboboxListbox` component is designed for positioning elements that float and facilitating interactions with them. The listbox is highly configurable, here are some example use cases:
188-
189-
### Placement
190-
191-
To set the default position of the listbox, you can use the `placement` prop. In the example below, we've set placement to top. When the user opens the listbox, it will be above the input.
192-
193-
<Showcase name="placement" />
194-
195-
The default placement is **bottom**.
196-
197190
## Customizing State Signals
198191

199192
The Combobox component allows you to customize its state signals. This can be useful if you want to control or observe these states externally.
@@ -407,22 +400,9 @@ The Combobox component API provides a set of properties that allow you to custom
407400
]}
408401
/>
409402

410-
### ComboboxPortal
403+
### ComboboxPopover
411404

412-
<APITable
413-
propDescriptors={[
414-
{
415-
name: 'elementToTeleport',
416-
type: 'JSXNode',
417-
description: 'The children to be rendered inside the portal.',
418-
},
419-
{
420-
name: 'contextIds',
421-
type: 'Array<string>',
422-
description: 'An array of context ids to be passed to the portal.',
423-
},
424-
]}
425-
/>
405+
The Combobox Popover is a wrapper of [Qwik UI's popover component](../../../docs/headless/popover/). You can view the full API table at the bottom of the popover page.
426406

427407
### ComboboxListbox
428408

apps/website/src/routes/docs/headless/introduction/index.mdx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: Qwik UI | Introduction
44

55
import headlessHero from '../../../../../public/images/qwik-ui-headless-hero.webp';
66
import { Note } from '~/components/note/note';
7+
import { FeatureList } from '~/components/feature-list/feature-list';
78
import {
89
AccordionRoot,
910
AccordionItem,
@@ -66,6 +67,8 @@ This approach also encompasses future native APIs. Users of Qwik UI might find t
6667

6768
> For instance, [Qwik UI's popover component](https://github.com/qwikifiers/qwik-ui/pull/445) uses the native Popover API on supported browsers. The Anchor API is also incrementally adoptable.
6869
70+
Thanks to resumability, we do less work because there are less components to execute. With Qwik UI we build on top of that, providing the same functionality with less code needed to prefetch in the first place.
71+
6972
## Features
7073

7174
### Unstyled
@@ -94,13 +97,17 @@ Conversely, some packages offer great UX, but fall short when it comes to DX.
9497

9598
One of the benefits of Qwik is its ability to create performant applications without compromising on DX. Our goal is to extend this same balance of performance and ease-of-use to those utilizing Qwik UI components.
9699

97-
Some examples being:
98-
99-
- TypeScript support
100-
- Custom Signal Binds
101-
- Automatic entry and exit animations
102-
- SSR & SSG, SPA, and hybrid support
103-
- Fine-grained lazy loading
100+
#### Some examples being:
101+
102+
<FeatureList
103+
features={[
104+
'TypeScript support',
105+
'Custom Signal Binds',
106+
'Automatic entry and exit animations across browsers',
107+
'Works across environments / microfrontends',
108+
'Automatic performance optimization',
109+
]}
110+
/>
104111

105112
## Community Driven
106113

apps/website/src/routes/docs/headless/modal/index.mdx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import testImage from '../../../../../public/images/test-image.png';
77
import { statusByComponent } from '~/_state/component-statuses';
88

99
<StatusBanner status={statusByComponent.headless.Modal} />
10+
import {FeatureList} from '~/components/feature-list/feature-list';
1011

1112
# Modal
1213

@@ -31,14 +32,18 @@ Modals are used when an important choice needs to be made in the application. Th
3132

3233
## ✨ Features
3334

34-
- Follows the WAI ARIA Dialog & Alertdialog design patterns.
35-
- Managed focus order
36-
- Scroll locking
37-
- Closes on escape
38-
- Toggle backdrop dismiss
39-
- Animation support
40-
- Transition support
41-
- Backdrop animations
35+
<FeatureList
36+
features={[
37+
'Follows the WAI ARIA Dialog & Alertdialog design patterns.',
38+
'Managed focus order',
39+
'Scroll locking',
40+
'Closes on escape',
41+
'Toggle backdrop dismiss',
42+
'Animation support',
43+
'Transition support',
44+
'Backdrop animations',
45+
]}
46+
/>
4247

4348
## Building Blocks
4449

apps/website/src/routes/docs/headless/popover/examples/programmatic.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ export default component$(() => {
1717
Focus me and press the 'o' key!
1818
</button>
1919
<Popover
20-
onBeforeToggle$={() => {
21-
console.log('I before toggle!');
22-
}}
2320
id="programmatic-id"
2421
class="shadow-dark-medium rounded-md border-2 border-slate-300 bg-slate-800 px-3 py-1 opacity-0"
2522
>

apps/website/src/routes/docs/headless/popover/index.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ title: Qwik UI | Popover
55
import { statusByComponent } from '~/_state/component-statuses';
66
import { Note } from '~/components/note/note';
77
import { FeatureList } from '~/components/feature-list/feature-list';
8+
import { APITable } from '~/components/api-table/api-table';
89

910
<StatusBanner status={statusByComponent.headless.Popover} />
1011

@@ -206,14 +207,14 @@ We can also enable programmatic behavior with popovers. Qwik UI provides several
206207
name: 'showPopover()',
207208
description: 'Opens the popover.',
208209
},
209-
{
210-
name: 'togglePopover()',
211-
description: 'Toggles the popover between the open and closed state.',
212-
},
213210
{
214211
name: 'hidePopover()',
215212
description: 'Closes the popover.',
216213
},
214+
{
215+
name: 'togglePopover()',
216+
description: 'Toggles the popover between the open and closed state.',
217+
},
217218
]}
218219
/>
219220

0 commit comments

Comments
 (0)