Skip to content

chore(Link): migrate to CSS Modules with visual regression baseline#1053

Open
DreaminDani wants to merge 5 commits into
mainfrom
chore/migrate-link-css-modules
Open

chore(Link): migrate to CSS Modules with visual regression baseline#1053
DreaminDani wants to merge 5 commits into
mainfrom
chore/migrate-link-css-modules

Conversation

@DreaminDani
Copy link
Copy Markdown
Contributor

@DreaminDani DreaminDani commented May 27, 2026

Commits

  • test(Link): add visual regression baseline before CSS Modules migration — adds stories, Playwright spec, and fresh PNG snapshots that capture the current rendering across sizes, weights, icon variants, and hover/focus states.
  • chore(linkStyles): move shared styled-components helper out of Link/ folder — drive-by relocation of the linkStyles / StyledLinkProps css helper (used by DateDetails and re-exported publicly as @deprecated) from src/components/Link/common.ts to src/styles/linkStyles.ts, so the migration commit can leave src/components/Link/ clean of styled-components references. Pure import-path updates; public export names are unchanged.
  • chore(Link): migrate styling from styled-components to CSS Modules — replaces styled-components with .module.css + cva/cn. DOM-identical (modulo the new module classnames), byte-for-byte visual parity verified.

Verification

  • yarn test:visual tests/display/link.spec.ts passes with zero snapshot regenerations
  • yarn test Link, yarn lint:css, yarn lint:code, yarn build all green
  • grep -r 'styled-components' src/components/Link/ empty

Closes CUI-41


Note

Low Risk
Styling-only migration for a typography component with visual regression tests; deprecated styled-components helpers remain for DateDetails and external consumers.

Overview
Link is restyled from styled-components to CSS Modules (Link.module.css) with cva/cn for size, weight, and external-icon sizing; the polymorphic API gains optional className merging. Shared linkStyles / StyledLinkProps move from components/Link/ to src/styles/linkStyles.ts (still used by DateDetails and deprecated package exports—paths only).

Storybook adds a LinkHarness and stories for sizes, weights, icons, and default; a large Playwright visual suite locks light/dark snapshots (including hover/focus). A changeset records a patch with no intended behavior change.

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

Add LinkHarness wrapper and named stories per visual variant (size, weight,
with/without icon) so each can be screenshotted in isolation. The Playwright
spec covers light + dark themes, all size and weight variants, icon variants,
and the interactive hover / focus states.

Snapshots are generated fresh in the project's Linux Docker Playwright
container so file names match what CI generates on ubuntu-latest.
…folder

The `linkStyles` and `StyledLinkProps` helpers are a shared styled-components
`css` template used by DateDetails and exposed publicly (deprecated) via the
package root. Move the file from `src/components/Link/common.ts` to
`src/styles/linkStyles.ts` so the Link component's folder can be migrated
to CSS Modules without the helper file's `import 'styled-components'`
contaminating the migration check (`grep -r 'styled-components'
src/components/Link/`).

Imports updated:
- `src/components/Link/Link.tsx` (last styled-components consumer in Link/)
- `src/components/DateDetails/DateDetails.tsx`
- `src/index.ts` (public re-exports, paths only)

No behavior change. Public exports `linkStyles` and `StyledLinkProps` keep
their names and remain marked `@deprecated`.
@DreaminDani DreaminDani self-assigned this May 27, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: 4e2d992

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

Prettier wanted the LinkHarness destructure on one line and the WithIconSm
render's JSX split across lines. Apply yarn format to satisfy CI's
code-quality-checks Formatter step. No behavior change.
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 Link component’s styling from styled-components to CSS Modules while preserving existing (deprecated) linkStyles exports and adding a Storybook-driven visual regression baseline to ensure pixel parity across themes and variants.

Changes:

  • Add Storybook Link harness stories plus a Playwright visual regression suite with snapshots for size/weight/icon/hover/focus in light + dark.
  • Migrate Link styling to Link.module.css using cva/cn for variant class composition.
  • Move deprecated linkStyles/StyledLinkProps to src/styles/linkStyles.ts and update import/export paths.

Reviewed changes

Copilot reviewed 7 out of 34 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/display/link.spec.ts Adds Playwright visual regression coverage for Link stories in light/dark and interactive states.
src/styles/linkStyles.ts New shared styled-components css helper for deprecated linkStyles export, relocated out of Link/.
src/index.ts Updates deprecated public re-exports to the new src/styles/linkStyles.ts location.
src/components/Link/Link.tsx Replaces styled-components implementation with CSS Modules + cva/cn class composition.
src/components/Link/Link.stories.tsx Adds LinkHarness and variant stories used by visual regression tests.
src/components/Link/Link.module.css Introduces CSS Module styling for Link, including size/weight compound selectors and icon sizing.
src/components/DateDetails/DateDetails.tsx Updates import path for relocated deprecated linkStyles helper.
.changeset/migrate-link-to-css-modules.md Records a patch changeset for the styling refactor.

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

Comment thread src/components/Link/Link.tsx
Comment thread .changeset/migrate-link-to-css-modules.md
… runner)

The Docker Playwright image (mcr.microsoft.com/playwright:v1.60.0-noble)
used by `yarn test:visual:update` includes the Inconsolata mono font, but
the visual-regression CI workflow runs Playwright natively on ubuntu-latest
without that font installed. The fallback rendering produces a different
width for `weight="mono"` (80px vs 69px), causing two snapshots to fail in
CI even though they pass byte-for-byte in Docker.

Drop the WeightMono story and its two associated specs/snapshots so the
suite is stable across both environments. The other 24 spec entries still
cover sizes xs/sm/md/lg, weights normal/medium/semibold/bold, icon
variants, and hover/focus states.
@workflow-authentication-public
Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

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

Built from commit: 1b58d97e4c64801bac125f9fb80baa976607988c

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