Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add headless checkbox #683

Merged
merged 95 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
6c50beb
FEAT: fixed tailwind config bug
TheMcnafaha Mar 22, 2024
10af9af
FEAT: working render of test
TheMcnafaha Mar 23, 2024
e3e486d
FIX: added test files to tailwind config
TheMcnafaha Mar 28, 2024
39aca37
FEAT: added tests for single checkbox behavior
TheMcnafaha Mar 28, 2024
2638e11
FIX: better tailwind config
TheMcnafaha Mar 28, 2024
6e1fcac
FEAT: added test for default checkbox
TheMcnafaha Mar 28, 2024
3746b46
FEAT: test for checklist renders
TheMcnafaha Mar 28, 2024
c68c49b
FEAT: better test driver
TheMcnafaha Mar 29, 2024
c61889c
FEAT: better getCheckbox driver method
TheMcnafaha Mar 29, 2024
06f14b5
FEAT: added tests to checklist
TheMcnafaha Mar 29, 2024
848a395
FEAT: buggy hellish halfworking checklist context JSX hack
TheMcnafaha Mar 30, 2024
efcc706
FIX: removed bug that creates multiple sigs on checklist's context
TheMcnafaha Mar 30, 2024
433b338
FEAT: refactored checklistContext to use a sig
TheMcnafaha Mar 30, 2024
d8c3d29
FIX: removed circular muation
TheMcnafaha Mar 30, 2024
40e9dec
FEAT: better context code structure, but still not good
TheMcnafaha Mar 30, 2024
af8a4c7
FEAT: working tricheckbox icon
TheMcnafaha Mar 31, 2024
14eeb05
FEAT: added checklist child-to-parent behavior
TheMcnafaha Mar 31, 2024
f375639
FEAT: split checkbox into 2 components to ease logic
TheMcnafaha Mar 31, 2024
3fdd48a
FEAT: added test for aria-controls
TheMcnafaha Apr 1, 2024
8ce69f6
FEAT: added more tests for aria-controls
TheMcnafaha Apr 2, 2024
571b8ff
FEAT: added functionality and tests for parent-child checklist behavior
TheMcnafaha Apr 2, 2024
6769747
FEAT: added final ids tests for aria-controls
TheMcnafaha Apr 2, 2024
83b490e
FEAT: added first test for controlled checklist
TheMcnafaha Apr 3, 2024
e599453
FIX: removed bug on checklist bool logic leading to wrong initial ari…
TheMcnafaha Apr 3, 2024
25b51aa
FEAT: added test for controlled checklist with all checked checkboxes
TheMcnafaha Apr 3, 2024
b83e329
FEAT: added test for controlled checklist with all unchecked checkboxes
TheMcnafaha Apr 3, 2024
f026302
FEAT: added test for controlled checklist with mixed status
TheMcnafaha Apr 3, 2024
63936d0
FEAT: improved checklist idArr logic
TheMcnafaha Apr 3, 2024
183bc96
FEAT: added code to make controlled checklist control children
TheMcnafaha Apr 3, 2024
43c472b
FIX: removed bug in checklist logic
TheMcnafaha Apr 3, 2024
7e5f2f8
FIX: removed duplicate state that was causing sync issues with indicator
TheMcnafaha Apr 3, 2024
043b65f
FIX: removed bug were a user-given checkbox id was overwritten
TheMcnafaha Apr 3, 2024
6edc06f
FEAT: added test for controlled checklist sig with a value of true
TheMcnafaha Apr 4, 2024
58b23d1
FEAT: replaced checkIcon for emoji instead of imgs for better perforance
TheMcnafaha Apr 7, 2024
3caea76
FEAT: added test to ensure proper handleling of IDs
TheMcnafaha Apr 10, 2024
bbdf241
FEAT: added solution, with test, that makes aria-controls use user-…
TheMcnafaha Apr 10, 2024
e08bcc4
FIX: removed all LSP errors
TheMcnafaha Apr 12, 2024
4244e27
FIX: removed most lint issues
TheMcnafaha Apr 14, 2024
348e302
FIX: removed lint use on using hooks wrong on checkbox
TheMcnafaha Apr 14, 2024
a2553bf
FEAT: simplfied the twostate checkbox
TheMcnafaha Apr 14, 2024
b9f05a0
FEAT: further simplfied the twostate checkbox
TheMcnafaha Apr 14, 2024
f2c753a
FEAT: simplified checklist's two-state checkbox
TheMcnafaha Apr 14, 2024
5e77927
FIX: rm unused import
TheMcnafaha Apr 14, 2024
0c7ba6e
FIX: removed last wrong use of hooks
TheMcnafaha Apr 14, 2024
c448d54
FEAT: bare-bones doc file
TheMcnafaha Apr 15, 2024
ea8e78d
FIX: better index.ts export file
TheMcnafaha Apr 16, 2024
f4390a9
FIX: removed import bug
TheMcnafaha Apr 16, 2024
17ec86c
FEAT: working prototype for checklist indicator
TheMcnafaha Apr 16, 2024
b81adb2
FEAT: removed debugin code
TheMcnafaha Apr 16, 2024
09aca20
FEAT: improved checklist indicator
TheMcnafaha Apr 16, 2024
1b9cb27
FIX: prefixed all test files with test- to avoid confussion with docs…
TheMcnafaha Apr 16, 2024
badede1
FIX: fixes tailwind classes not working on headless components
TheMcnafaha Apr 16, 2024
ddc79d0
FEAT: added first doc example
TheMcnafaha Apr 16, 2024
a37bacf
FEAT: added mouse tests for single two-state checkbox
TheMcnafaha Apr 17, 2024
490cba8
FEAT: refactored checkbox behavior into single component
TheMcnafaha Apr 17, 2024
93f947c
FEAT: applied refactor to second checkbox
TheMcnafaha Apr 17, 2024
e2ee8af
FEAT: refactored checklist sig behavior to one function
TheMcnafaha Apr 17, 2024
7f83ead
FEAT: added controlled checlist to mouse tests
TheMcnafaha Apr 17, 2024
10dedf2
FEAT: added render tests to checklist
TheMcnafaha Apr 17, 2024
a1f1392
FIX: added conditional to prevent reducing on empty array
TheMcnafaha Apr 17, 2024
6ce57f5
DOCS: added doc examples
TheMcnafaha Apr 17, 2024
a1a0ba9
FIX: renamed MyCheckbox component to Checkbox
TheMcnafaha Apr 29, 2024
8b9bc2c
FIX: better naming
TheMcnafaha Apr 30, 2024
20b33d1
FIX: remove unused file
TheMcnafaha May 1, 2024
2440c6e
FIX: props not being passed down correctly
TheMcnafaha May 1, 2024
41b15f4
FIX: removed debugging logs
TheMcnafaha May 1, 2024
13ae35f
feat: 1/2 to using dot.Notation
TheMcnafaha May 4, 2024
f44761b
feat: 80% template adapted to dot
TheMcnafaha May 4, 2024
51b609f
fix: added dot imports for checkbox
TheMcnafaha May 4, 2024
decc1ec
feat: 0 script for checklist indicator
TheMcnafaha May 4, 2024
edc8a41
feat: working single example with new dot notation
TheMcnafaha May 4, 2024
1d0f58f
fix: better naming for checklist
TheMcnafaha May 15, 2024
8bb41c4
fix: checkbox indicator follows dot notation
TheMcnafaha May 15, 2024
e55f6da
fix: typo of logic
TheMcnafaha May 15, 2024
ecd5088
fix: added roots
TheMcnafaha May 16, 2024
57694d4
fix: imports
TheMcnafaha May 16, 2024
8e31c2c
fix: better naming
TheMcnafaha May 17, 2024
09e2e9b
fix: api changes
TheMcnafaha May 17, 2024
d7bec0d
fix: updated examples to new api
TheMcnafaha May 17, 2024
2b40824
fix: rm bad imports
TheMcnafaha May 17, 2024
e6462e9
chore: merge conflicts & lint
TheMcnafaha May 19, 2024
5b14cc5
chore(checkbox): linting
TheMcnafaha May 22, 2024
634e5bc
fix(checkbox): indicator text present in aria text
TheMcnafaha May 23, 2024
7a85d9b
fix(checkbox): typos
TheMcnafaha May 25, 2024
d06426c
fix(checkbox): wrong edit
TheMcnafaha May 26, 2024
733d636
arrange code that looks more tidy
JerryWu1234 May 26, 2024
66f1fcf
fix(checkbox): better wording
TheMcnafaha May 28, 2024
659ebab
fix(checkbox): removed debugging from example
TheMcnafaha May 28, 2024
0f4895c
feat(checkbox): added draft docs
TheMcnafaha May 29, 2024
36df07a
fix(checkbox): changes checkBoxSig to checkboxSig
TheMcnafaha May 30, 2024
ed09dae
refactor(checbox&checklist): replaces checkboxSig for bind:checked
TheMcnafaha Jun 5, 2024
c8c94fd
fix(checkbox): updates types to bind syntax
TheMcnafaha Jun 5, 2024
6dcc66f
fix(docs/checkbox): finished documentation
TheMcnafaha Jun 7, 2024
639955f
fix(docs/checkbox): proper labeling and minor edit
TheMcnafaha Jun 8, 2024
5f9d1e4
Merge branch 'main' into add-headless-checkbox
thejackshelton Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/component-tests/tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
join(__dirname, 'src/**/*.{js,ts,jsx,tsx,mdx}'),
join(__dirname, '../website/src/**/*.{js,ts,jsx,tsx,mdx}'),
join(__dirname, '../../packages/kit-styled/src/**/*.{js,ts,jsx,tsx,mdx}'),
join(__dirname, '../../packages/kit-headless/src/**/*.{js,ts,jsx,tsx,mdx}'),
],
plugins: [
// PLUGIN-START
Expand Down
1 change: 1 addition & 0 deletions apps/website/src/_state/component-statuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const statusByComponent: ComponentKitsStatuses = {
Carousel: ComponentStatus.Draft,
Collapsible: ComponentStatus.Beta,
Combobox: ComponentStatus.Beta,
Checkbox: ComponentStatus.Beta,
Label: ComponentStatus.Draft,
Modal: ComponentStatus.Beta,
Pagination: ComponentStatus.Draft,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox } from '@qwik-ui/headless';
export default component$(() => {
const initialVal1 = false;
const controlledSig1 = useSignal(initialVal1);
const initialVal2 = true;
const controlledSig2 = useSignal(initialVal2);
return (
<>
<div class="flex gap-8">
<div class="flex flex-col gap-3">
<Checkbox.Root
bind:checked={controlledSig1}
id="test"
class="flex items-center gap-3 border-2 border-black p-2 "
>
<Checkbox.Indicator class="flex h-[25px] w-[25px] items-center justify-center bg-slate-600">
</Checkbox.Indicator>
Toggle Value
</Checkbox.Root>
<p>The initial value was: {`${initialVal1}`}</p>
<p>The current value is: {`${controlledSig1.value}`}</p>
</div>
<div class="flex flex-col gap-3">
<Checkbox.Root
bind:checked={controlledSig2}
id="test"
class="flex items-center gap-3 border-2 border-black p-2 "
>
<Checkbox.Indicator class="flex h-[25px] w-[25px] items-center justify-center bg-slate-600">
</Checkbox.Indicator>
Toggle Value
</Checkbox.Root>
<p>The initial value was: {`${initialVal2}`}</p>
<p>The current value is: {`${controlledSig2.value}`}</p>
</div>
</div>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { component$, useSignal } from '@builder.io/qwik';
import { Checkbox } from '@qwik-ui/headless';
export default component$(() => {
const initialVal1 = false;
const controlledSig1 = useSignal(initialVal1);
return (
<>
<div class="flex gap-8">
<div class="flex flex-col gap-3">
<Checkbox.Root
bind:checked={controlledSig1}
id="test"
class="flex items-center gap-3 border-2 border-black p-2 "
>
<Checkbox.Indicator class="flex h-[25px] w-[25px] items-center justify-center bg-slate-600">
</Checkbox.Indicator>
Toggle Value
</Checkbox.Root>
</div>
</div>
</>
);
});
14 changes: 14 additions & 0 deletions apps/website/src/routes/docs/headless/checkbox/examples/hero.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox } from '@qwik-ui/headless';
export default component$(() => {
return (
<>
<Checkbox.Root id="test" class="flex items-center gap-3 border-2 border-black p-2 ">
<Checkbox.Indicator class="flex h-[25px] w-[25px] items-center justify-center bg-slate-600">
</Checkbox.Indicator>
I have read the README
</Checkbox.Root>
</>
);
});
39 changes: 39 additions & 0 deletions apps/website/src/routes/docs/headless/checkbox/examples/pizza.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
const toppingNames = ['hot peppers', 'ham', 'pineaple', 'mushroom'];
const toppingImages = ['🌶️', '🍗', '🍍', '🍄'];
export default component$(() => {
return (
<>
<h3 id="pizza-toppings">Pizza toppings</h3>
<Checklist.Root ariaLabeledBy="pizza-toppings" class="flex flex-col gap-4">
<Checkbox.Root
class="flex items-center gap-3 border-2 border-black p-2"
checklist={true}
>
<Checklist.Indicator class="flex h-[25px] w-[25px] items-center justify-center bg-slate-600">
<div q:slot="true" id="true-img">
🍕
</div>

<div q:slot="mixed" id="mixed-img">
</div>
</Checklist.Indicator>
Pick all toppings
</Checkbox.Root>

{toppingNames.map((name, i) => {
return (
<Checkbox.Root class="ml-8 flex items-center gap-3 border-2 border-black p-2">
<Checkbox.Indicator class="flex h-[25px] w-[25px] items-center justify-center bg-slate-600">
{toppingImages[i]}
</Checkbox.Indicator>
{name}
</Checkbox.Root>
);
})}
</Checklist.Root>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
// TODO: add logic to handle user passed sigs with trues
// this test basically ensures that the sig passed to the checklist controlls trumps all its children
export default component$(() => {
const checklistSig = useSignal(false);
return (
<>
<h3 id="test123">Pick a cat</h3>
<Checklist.Root class="flex flex-col gap-3" ariaLabeledBy="test123">
<Checkbox.Root
class="flex items-center gap-3 bg-slate-900 text-white"
checklist={true}
bind:checked={checklistSig}
id="checklist"
>
<Checklist.Indicator class="w-fit">
<div q:slot="true" id="true-img">
</div>

<div q:slot="mixed" id="mixed-img">
</div>
</Checklist.Indicator>
<p>Controlls all</p>
</Checkbox.Root>
<Checkbox.Root
id="child-1"
class="flex items-center gap-3 bg-slate-900 pr-2 text-white"
>
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</Checkbox.Root>

<Checkbox.Root id="child-2" class="bg-slate-900 text-white">
<div class="flex items-center gap-3">
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>Im a true.tsx</p>
</div>
</Checkbox.Root>
</Checklist.Root>
<p>You signal is: </p>
<p id="signal-to-text">{`${checklistSig.value}`}</p>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
export default component$(() => {
const firstUserSig = useSignal(false);
const secondUserSig = useSignal(false);
return (
<>
<h3 id="test123">Pick a cat</h3>
<Checklist.Root class="flex flex-col gap-3" ariaLabeledBy="test123">
<Checkbox.Root
class="flex items-center gap-3 bg-slate-900 p-2 text-white"
checklist={true}
>
<Checkbox.Indicator class=" flex w-[80px] justify-center bg-white p-3">
</Checkbox.Indicator>
<p>Controlls all</p>
</Checkbox.Root>
<Checkbox.Root
bind:checked={firstUserSig}
class="flex items-center gap-3 bg-slate-900 pr-2 text-white"
>
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</Checkbox.Root>

<Checkbox.Root bind:checked={secondUserSig} class="bg-slate-900 text-white">
<div class="flex items-center gap-3">
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</div>
</Checkbox.Root>
</Checklist.Root>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
export default component$(() => {
const firstUserSig = useSignal(false);
const secondUserSig = useSignal(true);
return (
<>
<h3 id="test123">Pick a cat</h3>
<Checklist.Root class="flex flex-col gap-3" ariaLabeledBy="test123">
<Checkbox.Root
class="flex items-center gap-3 bg-slate-900 p-2 text-white"
checklist={true}
>
<Checklist.Indicator class="w-fit">
<div q:slot="true" id="true-img">
</div>
<div q:slot="mixed" id="mixed-img">
</div>
</Checklist.Indicator>
<p>Controlls all</p>
</Checkbox.Root>
<Checkbox.Root
bind:checked={firstUserSig}
class="flex items-center gap-3 bg-slate-900 pr-2 text-white"
>
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</Checkbox.Root>

<Checkbox.Root bind:checked={secondUserSig} class="bg-slate-900 text-white">
<div class="flex items-center gap-3">
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</div>
</Checkbox.Root>
</Checklist.Root>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
// this test basically ensures that the sig passed to the checklist controlls trumps all its children
export default component$(() => {
const checklistSig = useSignal(true);
return (
<>
<h3 id="test123">Pick a cat</h3>
<Checklist.Root class="flex flex-col gap-3" ariaLabeledBy="test123">
<Checkbox.Root
class="flex items-center gap-3 bg-slate-900 text-white"
checklist={true}
bind:checked={checklistSig}
id="checklist"
>
<Checklist.Indicator class="w-fit">
<div q:slot="true" id="true-img">
</div>

<div q:slot="mixed" id="mixed-img">
</div>
</Checklist.Indicator>
<p>Controlls all</p>
</Checkbox.Root>
<Checkbox.Root
id="child-1"
class="flex items-center gap-3 bg-slate-900 pr-2 text-white"
>
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</Checkbox.Root>

<Checkbox.Root id="child-2" class="bg-slate-900 text-white">
<div class="flex items-center gap-3">
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>Im a true.tsx</p>
</div>
</Checkbox.Root>
</Checklist.Root>
<p>You signal is: </p>
<p id="signal-to-text">{`${checklistSig.value}`}</p>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
export default component$(() => {
const firstUserSig = useSignal(true);
const secondUserSig = useSignal(true);
return (
<>
<h3 id="test123">Pick a cat</h3>
<Checklist.Root class="flex flex-col gap-3" ariaLabeledBy="test123">
<Checkbox.Root
class="flex items-center gap-3 bg-slate-900 p-2 text-white"
checklist={true}
>
<Checkbox.Indicator class=" flex w-[80px] justify-center bg-white p-3">
</Checkbox.Indicator>
<p>Controlls all</p>
</Checkbox.Root>
<Checkbox.Root
bind:checked={firstUserSig}
class="flex items-center gap-3 bg-slate-900 pr-2 text-white"
>
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</Checkbox.Root>

<Checkbox.Root bind:checked={secondUserSig} class="bg-slate-900 text-white">
<div class="flex items-center gap-3">
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</div>
</Checkbox.Root>
</Checklist.Root>
</>
);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { component$, useSignal, useStyles$ } from '@builder.io/qwik';
import { Checkbox, Checklist } from '@qwik-ui/headless';
export default component$(() => {
const firstUserSig = useSignal(true);
const secondUserSig = useSignal(true);
return (
<>
<h3 id="test123">Pick a cat</h3>
<Checklist.Root class="flex flex-col gap-3" ariaLabeledBy="test123">
<Checkbox.Root
class="flex items-center gap-3 bg-slate-900 p-2 text-white"
checklist={true}
>
<Checkbox.Indicator class=" flex w-[80px] justify-center bg-white p-3">
</Checkbox.Indicator>
<p>Controlls all</p>
</Checkbox.Root>
<Checkbox.Root
bind:checked={firstUserSig}
class="flex items-center gap-3 bg-slate-900 pr-2 text-white"
>
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</Checkbox.Root>

<Checkbox.Root class="bg-slate-900 text-white">
<div class="flex items-center gap-3">
<Checkbox.Indicator class="w-fit bg-slate-600">✅</Checkbox.Indicator>
<p>No other stuff is needed here</p>
</div>
</Checkbox.Root>
</Checklist.Root>
</>
);
});
Loading
Loading