Repository navigation
fix(theme): align the button recipe with Open Components - #374
Merged
Merged
Conversation
Meet the Open Components Button page's stylesheet rules in useButtonRecipe: label contrast in every state and theme, a color.focus ring, an underlined link variant, min-height sizing with wrapping labels, logical inline padding, a 44px touch hit area, hover only on devices that can hover, and disabled, pressed and loading styled from their attributes, with forced colors and more contrast handling. Add the recipe's tests, a contrast test, focus, pressed and loading stories, and an Accessibility section on the docs page.
Style aria-expanded like pressed, give each size a min-width matching its min-height, color and size the loading spinner from the button, and let the forced colors disabled rule outrank the dark theme's pressed rules.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Drop pointer-events: none from the disabled states, and put each button's resting colors back while it's disabled through trailing compound variants, so hover and press change nothing. Keep the pressed background on a disabled toggle in forced colors and turn loading buttons GrayText, as the reference CSS does. Give every border 3:1 against the page, set the label color in every hover block so an <a href> button keeps it over the global a:hover styles, and test the borders and the rule order.
The active modifier also emits &:focus:active, which outranked the disabled resets on a focused aria-disabled button, so add resets under &:aria-disabled:active in both themes. Raise the forced colors rules to (0,6,0) so they still outrank those resets, and correct the docs and changeset sentences that overstated the hover, border and disabled behaviour.
7 of 13 tasks
This branch was successfully deployed
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.
Description
Brings
useButtonRecipein line with the stylesheet rules of the Open Components Button page, without renaming or removing any color, variant, size, default or export.solidhovers darken (shade) instead of lightening,warningtakes a dark label, and the transparent variants use lighter levels in the dark theme. Every border keeps 3:1 against the page, sosubtle,neutralandwarningborders change level. A newbuttonContrast.test.tschecks all 540 label cases and 54 borders from the token values, plus the focus ring at 3:1. Hover blocks set the label color, so an<a href>button keeps it over the globala:hoveron hover-capable devices.@color.focus, 2px solid with a 2px offset. The&:focusblocks that copied the hover background are gone.min-heightandmin-widththrough spacing multipliers (24px atxs), labels can wrap (white-space: nowrapremoved), and&:any-pointer-coarse:beforegrows the hit area to 44 × 44px.aria-disabledmirrors:disabled,aria-pressedandaria-expandedmirror:active, anddata-loadingkeeps the size, keeps a disabled loading button at full opacity and centers a.spinnerchild over the hidden content. Disabled buttons no longer setpointer-events: none: they keep their cursor, clicks don't fall through, and trailing compound variants put their resting colors back, so hover and press change nothing.&:hover-capable:hover. In forced colors the ring isHighlight, disabled and loading areGrayText, pressed and expanded areHighlight/HighlightText(a disabled toggle keeps the background), andlinkgets a border.outlineandsubtleborders becomecurrentColorwithprefers-contrast: more. Horizontal padding ispadding-inline.Related issue
Part of the integration stack that aligns component styles with Open Components.
Type of change
Checklist
feat(theme): …)pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm testand everything passespnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/testsdist/,.styleframe/)mainand stays focused in scopeNotes / screenshots
pnpm testpasses except 8@styleframe/playgroundtests intest/theme.test.ts(localStorageis undefined), which fail the same way on the base branch.main, so it gets no CI of its own.lightanddarkcolors. They keep one look in both themes, so a transparent variant (outline,ghost,link) with a fixed label can't reach 4.5:1 on both a light and a dark page. The recipe treatslightas a color for dark surfaces anddarkas one for light surfaces, the contrast test checks them there, and the docs and the variants story say so. Theirlinkhovers, which turned the label white on light surfaces and dark on dark ones, now keep it readable.:root .button.button.button.buttonselectors (0,6,0) that outrank every state class and disabled reset. The more-contrast borders and the disabled resets are trailing compound variants, so their rules follow every rule they override; a test checks that order in the emitted CSS.<a href>button on a touch screen can still take the globala:hovercolor, because the link element'sa:hoverisn't inside@media (hover: hover)and this recipe may not add a bare&:hover.