Center the indeterminate checkbox mark (#376) - #437
Merged
Conversation
The checked and indeterminate marks shared the icon slot's `mt: '1px'`, an optical correction shaped for the lucide Check glyph, whose stroke sits above the middle of its viewBox. The Minus bar is already on that centre line, so the shared nudge pushed it 0.5px below the box's centre at every size (a flex-centred item with a 1px top margin shifts by half the margin). Replace the `isChecked` variant, which collapsed both marked states, with a three-state `mark` variant. Both marked states still paint the same filled box; only `check` carries the nudge. Measured in headless Chromium against Storybook, comparing the glyph's painted bounding box to the box's centre at sm/md/lg: indeterminate goes from +0.5px to 0px, checked stays at +0.083px. Claude-Session: https://claude.ai/code/session_01XFkkvUQfynGRedEYDNxKoY
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Fixes #376.
What was wrong
CheckboxInput's checked and indeterminate marks render through one recipe slot, and that slot carriedmt: '1px'unconditionally. The nudge is an optical correction shaped for the lucideCheckglyph, whose stroke sits above the middle of its 24×24 viewBox. TheMinusbar is already on that centre line, so it inherited a correction it never needed.The
isCheckedvariant collapsed both states (isChecked: isCheckedOrIndeterminate), so there was no seam to hang a per-glyph rule on.The shift is 0.5px, not the full 1px: the icon is centred by the box's flex layout, and a top margin on a flex-centred item only moves it by half the margin (
(H − h − 1) / 2 + 1).Changes
isCheckedbecomes a three-statemarkvariant (none/check/indeterminate). Both marked states still paint the same filled box — that's shared through a localmarkedBoxconstant — but onlycheckcarries the nudge.1pxliteral stays. It's the smallest thing the design needs and the spacing scale bottoms out at0.5(2px), so there's no token that fits; it now sits next to a comment explaining which glyph it belongs to.ColorSwatchPicker.recipe.ts:62has the same literal, but that recipe only ever rendersCheck, so its nudge is on the right glyph and is left alone.Verified in a browser
Measured in headless Chromium against Storybook — the painted bounding box of the glyph's
<path>against the box's border-box centre, at every size:sm/md/lg)sm/md/lg)The red marks are the box's true vertical centre, placed from the measured geometry (verified to land within 0.008px of it). Full-width in the overview; ticks only in the magnified row so nothing covers the glyph.
Tests
Two regression tests in
CheckboxInput.test.tsx:silver-mt_1pxand the indeterminate mark does not — fails onmain, where the Minus glyph renders with that class;isChecked→markrefactor.Full suite green (3179 tests), lint and typecheck clean.
Note: the screenshot is hosted on a throwaway
screenshots/issue-376branch — safe to delete once this is reviewed.https://claude.ai/code/session_01XFkkvUQfynGRedEYDNxKoY