Skip to content

Commit 91d7681

Browse files
Feat/toggle (#192)
* feat: initial toggle impl * fix: tsconfig and toggle root * feat: toggle + indicator * feat: tests * feat: correct examples * fix: examples * update * fix: build * feat: move everything to utils package * fix: types * feat: final test * fix: hmr and initial monorepo docs * fix: format * feat: update for vitest * update docs
1 parent 8734db6 commit 91d7681

File tree

187 files changed

+934
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+934
-97
lines changed

CONTRIBUTING.md

-27
This file was deleted.

apps/docs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@kunai-consulting/code-notate": "0.0.2",
3030
"@kunai-consulting/code-notate-core": "0.0.2",
3131
"@kunai-consulting/qwik": "workspace:*",
32+
"@kunai-consulting/qwik-utils": "workspace:*",
3233
"@qwik-ui/headless": "^0.6.4",
3334
"@qwikest/icons": "^0.0.13",
3435
"@tailwindcss/vite": "^4.1.3",
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"1.2.0","languages":{"en-us":{"hash":"en-us_d75dd384268ca","wasm":"en-us","page_count":35}}}
1+
{"version":"1.2.0","languages":{"en-us":{"hash":"en-us_14c018bb95deb","wasm":"en-us","page_count":37}}}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

apps/docs/src/docs-widgets/sidebar/sidebar.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const Sidebar = component$((props: PropsOf<"nav">) => {
2525
{ id: "/base/checkbox", label: "Checkbox" },
2626
{ id: "/base/checklist", label: "Checklist" },
2727
{ id: "/base/otp", label: "OTP" },
28-
{ id: "/base/popover", label: "Popover" },
2928
{ id: "/base/radio-group", label: "Radio Group" },
3029
{ id: "/base/slider", label: "Slider" },
3130
{ id: "/base/switch", label: "Switch" }
@@ -37,15 +36,17 @@ export const Sidebar = component$((props: PropsOf<"nav">) => {
3736
children: [
3837
{ id: "/base/resizable", label: "Resizable" },
3938
{ id: "/base/scroll-area", label: "Scroll Area" },
40-
{ id: "/base/tree", label: "Tree" }
39+
{ id: "/base/tree", label: "Tree" },
40+
{ id: "/base/popover", label: "Popover" }
4141
]
4242
},
4343
{
4444
id: "/base/selection",
4545
label: "Selection Components",
4646
children: [
4747
{ id: "/base/calendar", label: "Calendar" },
48-
{ id: "/base/pagination", label: "Pagination" }
48+
{ id: "/base/pagination", label: "Pagination" },
49+
{ id: "/base/toggle", label: "Toggle" }
4950
]
5051
},
5152
{
@@ -88,7 +89,8 @@ export const Sidebar = component$((props: PropsOf<"nav">) => {
8889
{ id: "/contributing/indexing", label: "Indexing" },
8990
{ id: "/contributing/events", label: "Events" },
9091
{ id: "/contributing/testing", label: "Testing" },
91-
{ id: "/contributing/styling", label: "Styling" }
92+
{ id: "/contributing/styling", label: "Styling" },
93+
{ id: "/contributing/monorepo", label: "Monorepo" }
9294
]
9395
},
9496
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { $, component$, useSignal, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik";
3+
import { LuThumbsUp } from "@qwikest/icons/lucide";
4+
import styles from "./toggle.css?inline";
5+
6+
export default component$(() => {
7+
useStyles$(styles);
8+
const countSig = useSignal(0);
9+
10+
const handleChange = $(() => {
11+
countSig.value++;
12+
});
13+
14+
return (
15+
<div>
16+
<Toggle.Root class="toggle-root" aria-label="Toggle Like" onChange$={handleChange}>
17+
<LuThumbsUp />
18+
</Toggle.Root>
19+
<p>Count: {countSig.value}</p>
20+
</div>
21+
);
22+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { component$, useSignal, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik";
3+
import { LuStar } from "@qwikest/icons/lucide";
4+
import styles from "./toggle.css?inline";
5+
6+
export default component$(() => {
7+
useStyles$(styles);
8+
const showToggleSig = useSignal(false);
9+
10+
return (
11+
<div>
12+
<button type="button" onClick$={() => (showToggleSig.value = true)}>
13+
Render Toggle
14+
</button>
15+
16+
{showToggleSig.value && (
17+
<Toggle.Root class="toggle-root" aria-label="Toggle Favourite">
18+
<LuStar />
19+
</Toggle.Root>
20+
)}
21+
</div>
22+
);
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik";
3+
import { LuItalic } from "@qwikest/icons/lucide";
4+
import styles from "./toggle.css?inline";
5+
6+
export default component$(() => {
7+
useStyles$(styles);
8+
9+
return (
10+
<Toggle.Root class="toggle-root" aria-label="Toggle Italic (disabled)" disabled>
11+
<LuItalic />
12+
</Toggle.Root>
13+
);
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik";
3+
import { LuBold } from "@qwikest/icons/lucide";
4+
import styles from "./toggle.css?inline";
5+
6+
export default component$(() => {
7+
useStyles$(styles);
8+
9+
return (
10+
<Toggle.Root class="toggle-root" aria-label="Toggle Bold">
11+
<LuBold />
12+
</Toggle.Root>
13+
);
14+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { component$, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik"; // Adjust import path
3+
import styles from "./toggle.css?inline";
4+
5+
export default component$(() => {
6+
useStyles$(styles);
7+
8+
return (
9+
<Toggle.Root class="toggle-root" aria-label="Toggle State">
10+
<Toggle.Indicator class="toggle-indicator" fallback={<span>Is Off</span>}>
11+
<span>Is On</span>
12+
</Toggle.Indicator>
13+
</Toggle.Root>
14+
);
15+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { component$, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik";
3+
import { LuVolume2, LuVolumeX } from "@qwikest/icons/lucide";
4+
import styles from "./toggle.css?inline";
5+
6+
/**
7+
* Wrapper component needed because Qwikest icons uses inline components, and you cannot serialize them through props. Once we have Qwik icons library this wrapper component will not be needed.
8+
*/
9+
export const VolumeComp = component$(() => {
10+
return <LuVolumeX />;
11+
});
12+
13+
export default component$(() => {
14+
useStyles$(styles);
15+
16+
return (
17+
<Toggle.Root class="toggle-root" aria-label="Toggle Mute" pressed={true}>
18+
<Toggle.Indicator class="toggle-indicator" fallback={<VolumeComp />}>
19+
<LuVolume2 />
20+
</Toggle.Indicator>
21+
</Toggle.Root>
22+
);
23+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { component$, useSignal, useStyles$ } from "@builder.io/qwik";
2+
import { Toggle } from "@kunai-consulting/qwik";
3+
import { LuVolume2, LuVolumeX } from "@qwikest/icons/lucide";
4+
import styles from "./toggle.css?inline";
5+
6+
/**
7+
* Wrapper component needed because Qwikest icons uses inline components, and you cannot serialize them through props. Once we have Qwik icons library this wrapper component will not be needed.
8+
*/
9+
export const VolumeComp = component$(() => {
10+
return <LuVolumeX />;
11+
});
12+
13+
export default component$(() => {
14+
useStyles$(styles);
15+
const isPressedSig = useSignal(true);
16+
17+
return (
18+
<div>
19+
<Toggle.Root
20+
class="toggle-root"
21+
aria-label="Toggle Mute"
22+
bind:pressed={isPressedSig}
23+
>
24+
<Toggle.Indicator class="toggle-indicator" fallback={<VolumeComp />}>
25+
<LuVolume2 />
26+
</Toggle.Indicator>
27+
</Toggle.Root>
28+
29+
<button
30+
type="button"
31+
onClick$={() => {
32+
isPressedSig.value = !isPressedSig.value;
33+
}}
34+
>
35+
Toggle Signal
36+
</button>
37+
38+
<p>Bound Signal: {isPressedSig.value.toString()}</p>
39+
</div>
40+
);
41+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.toggle-root {
2+
display: inline-flex;
3+
align-items: center;
4+
justify-content: center;
5+
padding: 8px 12px;
6+
border-radius: 6px;
7+
border: 1px solid gray;
8+
background-color: #f0f0f0;
9+
color: #333;
10+
cursor: pointer;
11+
transition: background-color 0.2s ease;
12+
}
13+
14+
.toggle-root:focus-visible {
15+
outline: 2px solid dodgerblue;
16+
outline-offset: 2px;
17+
}
18+
19+
.toggle-root[data-disabled] {
20+
opacity: 0.5;
21+
cursor: not-allowed;
22+
background-color: #e0e0e0;
23+
border-color: #cccccc;
24+
}
25+
26+
.toggle-root[data-pressed] {
27+
background-color: #0a4d70;
28+
border-color: #083a5a;
29+
color: white;
30+
}

apps/docs/src/routes/contributing/indexing/examples/the-fix.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
useContextProvider,
88
useSignal
99
} from "@builder.io/qwik";
10-
import { Render, getNextIndex, resetIndexes, withAsChild } from "@kunai-consulting/qwik";
10+
import { Render, withAsChild } from "@kunai-consulting/qwik";
11+
import { getNextIndex, resetIndexes } from "@kunai-consulting/qwik-utils";
1112

1213
export default component$(() => {
1314
const isRenderedSig = useSignal(false);

apps/docs/src/routes/contributing/indexing/examples/wrapped.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
useContextProvider,
88
useSignal
99
} from "@builder.io/qwik";
10-
import { Render, getNextIndex, resetIndexes, withAsChild } from "@kunai-consulting/qwik";
10+
import { Render, withAsChild } from "@kunai-consulting/qwik";
11+
import { getNextIndex, resetIndexes } from "@kunai-consulting/qwik-utils";
1112

1213
export default component$(() => {
1314
const isRenderedSig = useSignal(false);

0 commit comments

Comments
 (0)