Skip to content

Commit ac59001

Browse files
feat(docs): docs fixes
1 parent 332db33 commit ac59001

File tree

6 files changed

+56
-51
lines changed

6 files changed

+56
-51
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export const DynamicAccordion = component$(
630630
</label>
631631
</div>
632632

633-
<AccordionRoot class="text-white bg-slate-700 rounded-sm border-slate-600 border-[1px] box-border w-[min(400px,_100%)]">
633+
<AccordionRoot class="text-white bg-slate-700 rounded-sm border-slate-600 border-[1px] border-t-0 box-border w-[min(400px,_100%)]">
634634
{itemStore.map(({ label, id }, index) => {
635635
return (
636636
<AccordionItem id={`${id}`} key={id}>

apps/website/src/routes/docs/headless/(components)/tabs/index.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
.tabs-example [role='tab'] {
22
width: 250px;
3-
background: var(--qwikui-slate-300);
4-
color: var(--qwikui-slate-950);
3+
background: var(--qwikui-slate-500);
4+
color: white;
55
}
66

77
.tabs-example [role='tab'][disabled] {
8-
color: var(--qwikui-slate-500);
8+
color: var(--qwikui-slate-400);
9+
background: var(--qwikui-slate-600);
910
}
1011

1112
.tabs-example [role='tab'].selected {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { $, Slot, component$ } from '@builder.io/qwik';
1+
import { Slot, component$ } from '@builder.io/qwik';
22
import { Toggle } from '@qwik-ui/primitives';
33
import { PreviewCodeExample } from '../../../_components/preview-code-example/preview-code-example';
44

55
export const Example01 = component$(() => {
66
return (
77
<PreviewCodeExample>
88
<div q:slot="actualComponent">
9-
<Toggle pressed onClick$={$(() => console.log('Toggle'))} />
9+
<Toggle pressed={true} onClick$={() => console.log('Toggle')} />
1010
</div>
1111

1212
<div q:slot="codeExample">

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ export const MainExample = component$(() => {
88
<PreviewCodeExample>
99
<div q:slot="actualComponent">
1010
<Tooltip
11+
offset={8}
1112
content="I'm a tooltip!"
12-
class="bg-slate-200 dark:bg-gray-900 p-4 rounded-xl"
13+
class="bg-slate-800 p-4 rounded-xl text-white border-2 border-slate-400 shadow-dark-medium"
1314
>
14-
Hover over me!
15+
<span class="text-white">Hover over me!</span>
1516
</Tooltip>
1617
</div>
1718
<div q:slot="codeExample">
@@ -27,9 +28,13 @@ export const Example1 = component$(() => {
2728
<div q:slot="actualComponent">
2829
<Tooltip
2930
content="Clicking this icon takes you to Qwik UI's GitHub repository!"
30-
class="bg-slate-200 dark:bg-gray-900 p-4 rounded-xl"
31+
class="bg-slate-800 p-4 rounded-xl text-white border-2 border-slate-400 shadow-dark-medium"
32+
offset={8}
3133
>
32-
<a href="https://github.com/qwikifiers/qwik-ui" class="mx-auto">
34+
<a
35+
href="https://github.com/qwikifiers/qwik-ui"
36+
class="block border-none text-white"
37+
>
3338
<GitHubIcon />
3439
</a>
3540
</Tooltip>

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,26 @@ import {
88
useSignal,
99
useStylesScoped$,
1010
} from '@builder.io/qwik';
11-
import { computePosition, type ComputePositionConfig } from '@floating-ui/dom';
11+
import {
12+
offset as _offset,
13+
computePosition,
14+
type ComputePositionConfig,
15+
} from '@floating-ui/dom';
1216
import styles from './tooltip.css?inline';
1317

1418
export interface TooltipProps {
1519
class?: string;
1620
content: string;
1721
inline?: boolean;
1822
durationMs?: number;
23+
offset?: number;
1924
position?: ComputePositionConfig['placement'];
2025
}
2126

2227
type State = 'hidden' | 'positioned' | 'unpositioned' | 'closing';
2328

2429
export const Tooltip = component$(
25-
({ content, position = 'top', durationMs = 100, ...props }: TooltipProps) => {
30+
({ offset, content, position = 'top', durationMs = 100, ...props }: TooltipProps) => {
2631
useStylesScoped$(styles);
2732
const id = useId();
2833
const triggerAnchor = useSignal<HTMLElement>();
@@ -34,13 +39,16 @@ export const Tooltip = component$(
3439

3540
const update = $(async () => {
3641
const now = Date.now();
42+
const middleware = [_offset(offset)];
43+
3744
const hasMouseEnterDebounced = now - lastActivatedTimestamp.value >= 300;
3845
if (triggerAnchor.value && tooltipAnchor.value && hasMouseEnterDebounced) {
3946
const { x, y } = await computePosition(
4047
triggerAnchor.value,
4148
tooltipAnchor.value as HTMLElement,
4249
{
4350
placement: position,
51+
middleware,
4452
},
4553
);
4654
lastActivatedTimestamp.value = now;
Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,40 @@
1-
import { component$, PropFunction, QwikMouseEvent, useSignal } from '@builder.io/qwik';
1+
import { component$, useSignal, QwikIntrinsicElements } from '@builder.io/qwik';
22

33
export type ToggleProps = {
44
disabled?: boolean;
5-
/**
6-
* The controlled state of the toggle.
7-
*/
85
pressed?: boolean;
9-
/**
10-
* The state of the toggle when initially rendered. Use `defaultPressed`
11-
* if you do not need to control the state of the toggle.
12-
* @defaultValue false
13-
*/
146
defaultPressed?: boolean;
7+
} & QwikIntrinsicElements['input'];
158

16-
onClick$: PropFunction<(evt: QwikMouseEvent) => void>;
17-
};
18-
19-
export const Toggle = component$((props: ToggleProps) => {
20-
const {
21-
pressed: pressedProp,
22-
defaultPressed = false,
9+
export const Toggle = component$(
10+
({
2311
onClick$,
12+
pressed,
13+
defaultPressed = false,
2414
disabled,
2515
...toggleProps
26-
} = props;
27-
28-
const pressedState = useSignal(pressedProp || defaultPressed);
16+
}: ToggleProps) => {
17+
const pressedState = useSignal(pressed || defaultPressed);
2918

30-
return (
31-
<input
32-
type="checkbox"
33-
role="switch"
34-
aria-pressed={pressedState.value}
35-
data-state={pressedState.value ? 'on' : 'off'}
36-
data-disabled={disabled ? '' : undefined}
37-
checked={pressedState.value}
38-
onClick$={(event: QwikMouseEvent<HTMLInputElement>) => {
39-
if (!disabled) {
40-
pressedState.value = !pressedState.value;
41-
if (onClick$) {
42-
onClick$(event);
43-
}
44-
}
45-
}}
46-
{...toggleProps}
47-
/>
48-
);
49-
});
19+
// event handlers seem to break toggle when exported from qwik-ui primitive
20+
return (
21+
<input
22+
type="checkbox"
23+
role="switch"
24+
aria-pressed={pressedState.value}
25+
data-state={pressedState.value ? 'on' : 'off'}
26+
data-disabled={disabled ? '' : undefined}
27+
checked={pressedState.value}
28+
// onClick$={[
29+
// () => {
30+
// if (!disabled) {
31+
// pressedState.value = !pressedState.value;
32+
// }
33+
// },
34+
// onClick$,
35+
// ]}
36+
{...toggleProps}
37+
/>
38+
);
39+
},
40+
);

0 commit comments

Comments
 (0)