chore(GenericLabel): migrate to CSS Modules with visual regression baseline#1048
chore(GenericLabel): migrate to CSS Modules with visual regression baseline#1048DreaminDani wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: 15c70fc 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 |
There was a problem hiding this comment.
Pull request overview
This PR adds visual-regression coverage for GenericLabel and then migrates its styling from styled-components to CSS Modules, preserving the component’s rendered output while enabling class-based variant styling via cva/cn.
Changes:
- Added Storybook stories plus a Playwright visual regression suite (light + system-dark, including hover/focus-within) for
GenericLabel. - Replaced
styled-componentslabel styling withGenericLabel.module.cssandcva-based variants, withclassNamemerging support. - Added a patch changeset documenting the no-behavior-change migration.
Reviewed changes
Copilot reviewed 5 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/utils/generic-label.spec.ts |
Adds Playwright visual snapshots for default/disabled/hover/focus-within in light and system-dark themes. |
src/components/GenericLabel/GenericLabel.tsx |
Swaps styled-component implementation for CSS Modules + cva variants and className merging. |
src/components/GenericLabel/GenericLabel.stories.tsx |
Adds dedicated Default and Disabled stories used by the visual regression tests. |
src/components/GenericLabel/GenericLabel.module.css |
Introduces CSS Module styles mirroring the prior styled-components states (default/hover/focus/disabled). |
.changeset/migrate-generic-label-to-css-modules.md |
Records the styling migration as a patch changeset entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Form Field generic label | ||
| <input | ||
| id="disabled-input" | ||
| defaultValue="value" |
Address Copilot's standing review feedback on the migration PRs: tests/utils/ is reserved for shared helpers like getStoryUrl; component specs belong in component-family folders. Migration skill updated in PR #1049 to codify this for future migrations. Visual regression remains byte-for-byte: 8/8 snapshots match without regeneration.
Address Copilot review feedback on PR #1048: the Disabled story labelled itself "Disabled" but only the GenericLabel had the disabled prop set; the nested input was still interactive. Pass `disabled` to the input too so the story represents a fully-disabled field, matching the story's name. The two disabled-state snapshots are regenerated to reflect the native disabled input rendering (greyed background, no caret). The other six snapshots (default, hover, focus-within in both themes) remain byte-for-byte unchanged.
Storybook Preview Deployed✅ Preview URL: https://click-nwd9qm0rd-clickhouse.vercel.app Built from commit: |
Commits
test(GenericLabel): add visual regression baseline before CSS Modules migration— adds stories, Playwright spec, and fresh PNG snapshots that capture the current rendering.chore(GenericLabel): 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/generic-label.spec.tspasses with zero snapshot regenerationsyarn lint:css,yarn lint:code,yarn buildall greengrep -r 'styled-components' src/components/GenericLabel/emptyCloses CUI-32
Note
Low Risk
Scoped styling migration on a single form label component with parity-focused CSS and new visual tests; no auth, data, or API contract changes beyond optional className merging.
Overview
GenericLabel is refactored from styled-components to CSS Modules (
GenericLabel.module.css) withcva/cnfor the disabled modifier and optionalclassName, while keeping the same label semantics and design-token-driven default/hover/focus/disabled styling (disabled still suppresses interactive hover/focus styling).Storybook gains Default and Disabled examples for stable visual checks, and a new Playwright suite (
tests/display/generic-label.spec.ts) snapshots default, disabled, hover, and focus-within in light and dark themes. A changeset records a patch-level, no-behavior-change release note for@clickhouse/click-ui.Reviewed by Cursor Bugbot for commit 15c70fc. Bugbot is set up for automated code reviews on this repo. Configure here.