Align checkbox to architecture goals#193
Merged
Merged
Conversation
|
📚 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).
31d4f9a to
979f7df
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tsx→variants.ts: the file contained no JSX; every otherui/*/variantsfile uses.ts. Renamed to match.checkboxIndicatorVariantsadded tovariants.ts:CheckboxIndicatorwas applyingclassName="flex items-center justify-center"as a hardcoded string literal. It now callscheckboxIndicatorVariants()from the variants file — consistent with the rule that all className composition lives incva, not in component files.checkboxLabelVariantsandcheckboxInlineStartNodeVariantsadded tovariants.ts: the components-tierCheckboxwas usingcx(...)directly to build the label wrapper's className (conditional cursor + hover background) and the inline-start icon slot's className. Both inlinecxcalls and thenodeSlotClassreference are now replaced by cva exports invariants.ts. Thedisabledboolean is a cva variant (true/false) so the conditional is expressed declaratively.cxandnodeSlotClassimports removed fromcomponents/checkbox/checkbox.tsx: no component file now importscxfromclass-variance-authorityor 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.