Skip to content

chore(Tabs): migrate to CSS Modules with visual regression baseline#1084

Open
DreaminDani wants to merge 4 commits into
mainfrom
chore/migrate-tabs-css-modules
Open

chore(Tabs): migrate to CSS Modules with visual regression baseline#1084
DreaminDani wants to merge 4 commits into
mainfrom
chore/migrate-tabs-css-modules

Conversation

@DreaminDani

@DreaminDani DreaminDani commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Commits

  • test(Tabs): add visual regression baseline before CSS Modules migration — adds stories (Tabs + FullWidthTabs, including a fixed-width-trigger story), a Playwright spec, and fresh PNG snapshots that capture the current rendering.
  • chore(Tabs): migrate styling from styled-components to CSS Modules — replaces styled-components with .module.css + cn. DOM-identical, byte-for-byte visual parity verified.

Notes

  • Tabs.Trigger, Tabs.Content, and Tabs.TriggersList are now forwardRef wrappers around the Radix primitives, preserving className passthrough (the DateTimeRangePicker consumer wraps Tabs.TriggersList via styled(), which relies on className forwarding).
  • FullWidthTabs is a function component that forwards its className onto Tabs. Its Trigger keeps the optional width prop, emitted as an inline custom property so the fixed-width vs flex-grow branch matches the original exactly.
  • The original styled-components had two separate active+hover rules ([data-state='active']:hover setting font, and :hover[data-state='active'] setting border-bottom); stylelint normalizes these to one selector, so they are merged into a single rule with identical specificity and result.

Verification

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

Note

Low Risk
Styling-only refactor with explicit visual parity checks; main integration risk is subtle CSS or className forwarding regressions for styled wrappers.

Overview
Tabs and FullWidthTabs move off styled-components onto Tabs.module.css, using design tokens as CSS variables and cn() for class composition. Radix subcomponents (Trigger, Content, TriggersList) are now forwardRef wrappers so className still merges—needed for consumers like DateTimeRangePicker that wrap Tabs.TriggersList with styled().

FullWidthTabs becomes a thin wrapper around Tabs with module classes; optional trigger width is applied via --full-width-tabs-trigger-width and fixed vs grow modifiers instead of styled-component props.

Storybook gains harness decorators, shared story children, and extra variants (Default, FirstSelected, FixedWidthTrigger). A new Playwright spec (tests/display/tabs.spec.ts) snapshots light/dark layouts plus hover, focus, click, and keyboard behavior. Patch changeset documents no intended behavior change.

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

DreaminDani and others added 2 commits June 18, 2026 10:05
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@DreaminDani DreaminDani self-assigned this Jun 18, 2026
@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 35090f6

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Migrates the Tabs and FullWidthTabs components from styled-components to CSS Modules while adding Storybook + Playwright visual-regression coverage to lock in rendering parity.

Changes:

  • Added visual regression snapshots and a Playwright spec for Tabs variants + interactive states.
  • Replaced styled-components styles with Tabs.module.css and cn()-based class composition.
  • Updated Storybook stories to include fixed-size harnesses and additional variants (including fixed-width trigger coverage).

Reviewed changes

Copilot reviewed 6 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/display/tabs.spec.ts Adds Tabs/FullWidthTabs visual regression + basic interaction coverage via Playwright screenshots.
src/components/Tabs/Tabs.tsx Reworks Tabs primitives as forwardRef wrappers and swaps styling to CSS Modules + cn().
src/components/Tabs/Tabs.stories.tsx Adds a consistent harness decorator and new story variants used by visual tests.
src/components/Tabs/Tabs.module.css Introduces CSS Module styles equivalent to the prior styled-components rules.
src/components/Tabs/FullWidthTabs.stories.tsx Adds harness decorator and new variants, including a fixed-width trigger scenario.
.changeset/migrate-tabs-to-css-modules.md Records the migration as a patch-level changeset.

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

Comment thread tests/display/tabs.spec.ts
Comment thread src/components/Tabs/Tabs.tsx
DreaminDani and others added 2 commits June 18, 2026 11:01
Addresses PR review feedback by asserting which tab receives focus before
the screenshot, so failures are clearer if Storybook tab order changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Addresses PR review feedback using the Container 'as CSSProperties' convention for inline CSS custom properties instead of the awkward bracketed string-key cast. Pure typing/readability change with zero runtime or visual impact.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

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

Built from commit: 6de8709c5879daddcebe4e0e4833b74e8d1848d3

@DreaminDani DreaminDani requested a review from ariser June 18, 2026 17:17
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