chore(Label): migrate to CSS Modules with visual regression baseline#1047
Open
DreaminDani wants to merge 6 commits into
Open
chore(Label): migrate to CSS Modules with visual regression baseline#1047DreaminDani wants to merge 6 commits into
DreaminDani wants to merge 6 commits into
Conversation
🦋 Changeset detectedLatest commit: 63b414a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The previous assertion relied on styled-components injecting the
default label color (rgb(179, 182, 189)) into the jsdom stylesheet at
render time. Now that Label uses CSS Modules, jsdom does not load the
`.label { color: var(--click-field-color-label-default) }` rule, and
the computed color falls back to canvastext.
The test's actual intent is to verify that no `labelColor` override is
applied when the prop is unset. Assert that directly via the absence of
an inline color style. Default-color rendering is covered by visual
regression in tests/display/label.spec.ts.
The second test (custom labelColor) is unchanged: the InputWrapper's
StyledLabel wrapper is still styled-components and continues to inject
its color rule into jsdom.
…ilures
- Prettier wants the Label component destructure on one line; reformat
to match.
- The earlier `getAttribute('style')` assertion returned `null` when no
style attribute was present, which `.not.toContain('color')` rejected.
Use `element.style.color` instead, which returns `''` for "no inline
color set" — the actual semantic we want to verify.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ea67c42. Configure here.
…olor still wins Bugbot flagged that the new .label.label_error and .label.label_disabled compound selectors raised modifier specificity to 0-2-0, while the original styled-components emitted state rules at single-class 0-1-0. InputWrapper's StyledLabel applies the `labelColor` override via a styled-components-generated single-class selector (0-1-0). In the original, `labelColor` won by cascade order; with the compound selectors it was silently overridden whenever error or disabled was active. Refactor the pseudo-class rules to use :where(), which contributes zero specificity, and drop the .label.label_modifier compound form for single-class .label_error / .label_disabled. The modifiers now sit at 0-1-0 — tied with StyledLabel's labelColor but losing on source order, which restores the original behavior where labelColor always wins. Label-in-isolation rendering is unchanged: 10/10 visual snapshots match byte-for-byte. The fix is observable only in combination with InputWrapper, which isn't covered by Label's own spec.
Contributor
Storybook Preview Deployed✅ Preview URL: https://click-p68wuoht6-clickhouse.vercel.app Built from commit: |
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.

Commits
test(Label): add visual regression baseline before CSS Modules migration— adds stories, Playwright spec, and fresh PNG snapshots that capture the current rendering.chore(Label): migrate styling from styled-components to CSS Modules— replaces styled-components with.module.css+cva/cn. DOM-identical, byte-for-byte visual parity verified.Verification
yarn test:visual tests/utils/label.spec.tspasses with zero snapshot regenerationsyarn test Label,yarn lint:css,yarn lint:code,yarn buildall greengrep -r 'styled-components' src/components/Label/emptyCloses CUI-40
Note
Low Risk
Styling refactor with explicit specificity safeguards and new visual tests; no auth, data, or API surface changes.
Overview
Label styling moves from styled-components to CSS Modules (
Label.module.css) withcva/cnforerroranddisabled, plus optionalclassName. Design tokens are expressed as CSS variables;:where()on hover/focus rules keeps specificity aligned with the old setup soInputWrapper’slabelColoroverride still wins when it should.Storybook adds a
label-harnessand Default / Disabled / Error stories. Playwright snapshots cover light/dark variants and hover/focus-within.TextFieldlabel-color tests no longer assert computed theme colors in jsdom (CSS modules aren’t loaded there); they still checklabelColorinline override behavior.Patch changeset only; intended no visual/behavior change.
Reviewed by Cursor Bugbot for commit 63b414a. Bugbot is set up for automated code reviews on this repo. Configure here.