Skip to content

Align checkbox to architecture goals#193

Merged
lifeiscontent merged 2 commits into
mainfrom
align/checkbox
Jun 24, 2026
Merged

Align checkbox to architecture goals#193
lifeiscontent merged 2 commits into
mainfrom
align/checkbox

Conversation

@lifeiscontent

Copy link
Copy Markdown
Collaborator

Closes #123

What the spec says

Based on bhaveshraja's design comment on #123:

Always the same (baked in): box size, checkmark style, border-radius, transition, focus ring, indeterminate dash, label-to-box gap, full-row click target, disabled opacity.

Adjustable (caller-controlled): checked/unchecked/indeterminate state, label text, disabled, error/danger tone, with-or-without label.

Architecture changes

  • variants.tsxvariants.ts: the file contained no JSX; every other ui/*/variants file uses .ts. Renamed to match.
  • checkboxIndicatorVariants added to variants.ts: CheckboxIndicator was applying className="flex items-center justify-center" as a hardcoded string literal. It now calls checkboxIndicatorVariants() from the variants file — consistent with the rule that all className composition lives in cva, not in component files.
  • checkboxLabelVariants and checkboxInlineStartNodeVariants added to variants.ts: the components-tier Checkbox was using cx(...) directly to build the label wrapper's className (conditional cursor + hover background) and the inline-start icon slot's className. Both inline cx calls and the nodeSlotClass reference are now replaced by cva exports in variants.ts. The disabled boolean is a cva variant (true/false) so the conditional is expressed declaratively.
  • cx and nodeSlotClass imports removed from components/checkbox/checkbox.tsx: no component file now imports cx from class-variance-authority or accesses internal helpers directly — those belong in the variants layer.

No visual changes. No prop API changes. Stories do not need updating.

Needs design approval from @bhaveshraja before merge.

@github-actions

Copy link
Copy Markdown

📚 Storybook preview: https://pr-193-propel-storybook.vamsi-906.workers.dev

- Rename variants.tsx → variants.ts (no JSX in the file; matches every other ui/*/variants.ts)
- Add checkboxIndicatorVariants cva and use it in CheckboxIndicator (was a hardcoded className string)
- Add checkboxLabelVariants and checkboxInlineStartNodeVariants in variants.ts; use them in the components-tier Checkbox, removing the direct cx() calls there
- Move the disabled cursor/hover toggle from an inline ternary into a cva `disabled` variant

All styling now lives in variants.ts; component .tsx files only call xVariants().
…ts-tier styling

The components-tier Checkbox was rendering a raw <label> and <span> with classNames
pulled from the ui variants (checkboxLabelVariants, checkboxInlineStartNodeVariants) —
styling that does not belong in components/. Extract those into single-element ui parts
(CheckboxLabel, CheckboxInlineStartNode) so the composition only assembles parts.

Also make CheckboxIndicator a node-slot that sizes its glyph child via --node-size, and
drop the baked size off CheckboxGlyph (it now renders a bare icon).
@lifeiscontent lifeiscontent merged commit 30e231e into main Jun 24, 2026
2 checks passed
@lifeiscontent lifeiscontent deleted the align/checkbox branch June 24, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checkbox: what should always look the same, and what should be adjustable?

1 participant