Skip to content

Commit ce348bd

Browse files
feat: tooltip docs
1 parent 4aaa758 commit ce348bd

File tree

7 files changed

+120
-31
lines changed

7 files changed

+120
-31
lines changed

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

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ To read more about the popover API you can check it out on:
431431
},
432432
{
433433
name: 'floating',
434-
type: 'boolean',
434+
type: 'boolean | TPlacement',
435435
description: 'Enables extra JavaScript behavior for floating elements.',
436436
},
437437
{
@@ -450,24 +450,6 @@ To read more about the popover API you can check it out on:
450450
type: 'number',
451451
description: 'The space between the floating element and the anchored element.',
452452
},
453-
{
454-
name: 'placement',
455-
type: 'union',
456-
info: ` | 'top'
457-
| 'top-start'
458-
| 'top-end'
459-
| 'right'
460-
| 'right-start'
461-
| 'right-end'
462-
| 'bottom'
463-
| 'bottom-start'
464-
| 'bottom-end'
465-
| 'left'
466-
| 'left-start'
467-
| 'left-end';`,
468-
description:
469-
'Flips the placement of the popover when it starts to collide with the boundaries.',
470-
},
471453
{
472454
name: '[popover]',
473455
type: 'selector',
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import { component$ } from '@builder.io/qwik';
1+
import { component$, useStyles$ } from '@builder.io/qwik';
22
import { Tooltip } from '@qwik-ui/headless';
33

44
export default component$(() => {
5+
useStyles$(styles);
6+
57
return (
68
<Tooltip.Root>
7-
<Tooltip.Trigger>Hover over me</Tooltip.Trigger>
8-
<Tooltip.Content>I'm a tooltip!</Tooltip.Content>
9+
<Tooltip.Trigger class="tooltip-trigger">Hover over me</Tooltip.Trigger>
10+
<Tooltip.Content class="tooltip-content">I'm a tooltip!</Tooltip.Content>
911
</Tooltip.Root>
1012
);
1113
});
14+
15+
// internal
16+
import styles from '../snippets/tooltip.css?inline';

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,81 @@ title: Qwik UI | Tooltip
44

55
# Tooltip
66

7+
A popup that shows information when an element is focused or hovered over.
8+
79
<Showcase name="hero" />
10+
11+
## ✨ Features
12+
13+
<FeatureList
14+
features={[
15+
'Above the rest of the page',
16+
'Hover and non-hover behavior',
17+
'Close with escape',
18+
]}
19+
/>
20+
21+
## Building blocks
22+
23+
```tsx
24+
import { component$ } from '@builder.io/qwik';
25+
import { Tooltip } from '@qwik-ui/headless';
26+
27+
export default component$(() => {
28+
return (
29+
<Tooltip.Root>
30+
<Tooltip.Trigger>Trigger</Tooltip.Trigger>
31+
<Tooltip.Panel>Panel</Tooltip.Panel>
32+
</Tooltip.Root>
33+
);
34+
});
35+
```
36+
37+
### 🎨 Anatomy
38+
39+
<AnatomyTable
40+
propDescriptors={[
41+
{
42+
name: 'Tooltip.Root',
43+
description: 'The parent container for the tooltip trigger and panel.',
44+
},
45+
{
46+
name: 'Tooltip.Trigger',
47+
description: 'A button that opens the tooltip when interacted with.',
48+
},
49+
{
50+
name: 'Tooltip.Panel',
51+
description: `An HTML Element that is above other content on the page.`,
52+
},
53+
]}
54+
/>
55+
56+
## API
57+
58+
### Tooltip Root
59+
60+
<APITable
61+
propDescriptors={[
62+
{
63+
name: 'hover',
64+
type: 'boolean',
65+
description: 'Disables hover behavior.',
66+
},
67+
{
68+
name: 'flip',
69+
type: 'boolean',
70+
description:
71+
'Flips the placement of the tooltip when it starts to collide with the boundaries.',
72+
},
73+
{
74+
name: 'gutter',
75+
type: 'number',
76+
description: 'The space between the floating element and the anchored element.',
77+
},
78+
{
79+
name: 'floating',
80+
type: 'string',
81+
description: 'The floating position of the tooltip.',
82+
},
83+
]}
84+
/>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.tooltip-trigger {
2+
border-radius: var(--border-radius);
3+
border: 2px dotted hsla(var(--foreground));
4+
background-color: hsl(var(--background));
5+
color: hsl(var(--foreground));
6+
padding: 0.5rem;
7+
margin-bottom: 0.5rem;
8+
}
9+
10+
.tooltip-trigger:hover {
11+
background-color: hsla(var(--primary) / 0.08);
12+
}
13+
14+
.tooltip-content {
15+
border-radius: var(--border-radius);
16+
border: 2px dotted hsla(var(--primary));
17+
background: hsla(var(--tooltip));
18+
color: hsl(var(--foreground));
19+
padding: 0.5rem;
20+
box-shadow:
21+
0 4px 6px -1px rgba(0, 0, 0, 0.1),
22+
0 2px 4px -1px rgba(0, 0, 0, 0.06);
23+
}

packages/kit-headless/src/components/tooltip/tooltip-content.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Slot, component$ } from '@builder.io/qwik';
1+
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
22
import { HPopoverPanel } from '../popover/popover-panel';
33

4-
export const HTooltipContent = component$(() => {
4+
export const HTooltipContent = component$((props: PropsOf<typeof HPopoverPanel>) => {
55
return (
6-
<HPopoverPanel>
6+
<HPopoverPanel {...props}>
77
<Slot />
88
</HPopoverPanel>
99
);

packages/kit-headless/src/components/tooltip/tooltip-root.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { Slot, component$ } from '@builder.io/qwik';
1+
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
22
import { HPopoverRoot } from '../popover/popover-root';
33

4-
export const HTooltipRoot = component$(() => {
4+
export const HTooltipRoot = component$((props: PropsOf<typeof HPopoverRoot>) => {
5+
const { hover = true, floating = 'top', ...rest } = props;
6+
57
return (
6-
<HPopoverRoot hover>
8+
<HPopoverRoot hover={hover} floating={floating} {...rest}>
79
<Slot />
810
</HPopoverRoot>
911
);

packages/kit-headless/src/components/tooltip/tooltip-trigger.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Slot, component$ } from '@builder.io/qwik';
1+
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
22
import { HPopoverTrigger } from '../popover/popover-trigger';
33

4-
export const HTooltipTrigger = component$(() => {
4+
export const HTooltipTrigger = component$((props: PropsOf<typeof HPopoverTrigger>) => {
55
return (
6-
<HPopoverTrigger>
6+
<HPopoverTrigger {...props}>
77
<Slot />
88
</HPopoverTrigger>
99
);

0 commit comments

Comments
 (0)