Skip to content

chore(Spacer): migrate to CSS Modules with visual regression baseline#1045

Open
DreaminDani wants to merge 3 commits into
mainfrom
chore/migrate-spacer-css-modules
Open

chore(Spacer): migrate to CSS Modules with visual regression baseline#1045
DreaminDani wants to merge 3 commits into
mainfrom
chore/migrate-spacer-css-modules

Conversation

@DreaminDani
Copy link
Copy Markdown
Contributor

@DreaminDani DreaminDani commented May 27, 2026

Commits

  • test(Spacer): add visual regression baseline before CSS Modules migration — adds stories, Playwright spec, and fresh PNG snapshots that capture the current rendering.
  • chore(Spacer): 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/spacer.spec.ts passes with zero snapshot regenerations
  • yarn test Spacer, yarn lint:css, yarn lint:code, yarn build all green
  • grep -r 'styled-components' src/components/Spacer/ empty

Closes CUI-55


Note

Low Risk
Styling-only refactor of a layout helper with explicit visual regression coverage; no API or security-sensitive logic changes.

Overview
Spacer moves off styled-components onto CSS Modules with the same design tokens (--click-spacer-*), cva/cn, and default size md—intended as a no-behavior visual parity swap.

Storybook gains a SpacerHarness and per-size stories for regression testing. A new Playwright suite snapshots each size in light and dark themes. A changeset records a patch release for @clickhouse/click-ui.

Reviewed by Cursor Bugbot for commit b3e2657. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: b3e2657

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui Patch

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Spacer display component from styled-components to CSS Modules while adding visual regression coverage to ensure byte-for-byte rendering parity.

Changes:

  • Added Storybook stories + a harness for consistent Spacer visual snapshots across all size variants.
  • Introduced a Playwright visual regression suite with baseline snapshots for light and dark rendering.
  • Replaced styled-components styling with Spacer.module.css using cva/cn class variants, plus a changeset for the patch release.

Reviewed changes

Copilot reviewed 5 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/utils/spacer.spec.ts Adds Playwright visual regression tests for Spacer sizes in light/dark themes.
src/components/Spacer/Spacer.tsx Switches Spacer implementation to CSS Modules + cva size variants.
src/components/Spacer/Spacer.stories.tsx Adds SpacerHarness and per-size stories used by visual regression tests.
src/components/Spacer/Spacer.module.css Introduces CSS Module classes mapping size variants to theme token CSS variables.
.changeset/migrate-spacer-to-css-modules.md Records a patch changeset for the Spacer refactor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/display/spacer.spec.ts
Comment thread src/components/Spacer/Spacer.module.css
- Move tests/utils/spacer.spec.ts to tests/display/ (and matching snapshots).
  tests/utils/ is reserved for shared helpers like getStoryUrl; component
  specs belong in component-family folders, matching tests/buttons/ and
  tests/cards/.
- Drop redundant `padding` from `.spacer` base class. The size variant is
  always applied via cva's `defaultVariants: { size: 'md' }`, so the
  duplicate value would have drifted over time.

Visual regression remains byte-for-byte: 14/14 snapshots match without
regeneration.
@workflow-authentication-public
Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

✅ Preview URL: https://click-1kqvfynr3-clickhouse.vercel.app

Built from commit: 1625ec18f2b29d5999c0eb46308e9a6b746b557f

DreaminDani added a commit that referenced this pull request May 27, 2026
Match the convention established in PRs #1045, #1046, #1048, and
#1050 and codified in the migration skill: tests/utils/ is reserved
for shared helpers like getStoryUrl, primitives go in tests/display/.

Visual regression remains byte-for-byte: 10/10 snapshots match without
regeneration.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants