Skip to content

chore(IconButton): migrate to CSS Modules with visual regression baseline#1036

Open
DreaminDani wants to merge 2 commits into
mainfrom
chore/migrate-iconbutton-css-modules
Open

chore(IconButton): migrate to CSS Modules with visual regression baseline#1036
DreaminDani wants to merge 2 commits into
mainfrom
chore/migrate-iconbutton-css-modules

Conversation

@DreaminDani
Copy link
Copy Markdown
Contributor

@DreaminDani DreaminDani commented May 19, 2026

Summary

Migrates IconButton from styled-components to CSS Modules (cva + cn), following the procedure established by ButtonGroup (PR #1034) and codified in the component-css-modules-migration skill.

Two commits, each green on its own:

  • test(IconButton): add visual regression baseline before CSS Modules migration — extends the stories with one named story per visual variant (each of the 5 types, both small sizes, disabled) and adds tests/buttons/iconbutton.spec.ts. Snapshots are generated against the existing styled-components rendering.
  • chore(IconButton): migrate styling from styled-components to CSS Modules — adds IconButton.module.css, rewrites IconButton.tsx with cva + cn, and re-asserts the baseline snapshots byte-for-byte with zero regenerations. DOM attributes (role="button", aria-label={iconName}, disabled) and forwardRef / displayName are preserved.

The migration is a pure styling refactor — no a11y refinements, no type changes, no consumer updates.

Judgment call to flag

The design tokens for IconButton use camelCase segments (--click-button-iconButton-*) — this is the first time a CSS Modules migration has had to reference them from a .module.css file. The repo's stylelint custom-property-pattern rule (inherited from stylelint-config-standard) expects pure kebab-case and rejects the existing token names.

Rather than relax the stylelint config repo-wide (which would be a drive-by tooling change bundled into this migration), I added a scoped /* stylelint-disable custom-property-pattern */ comment at the top of IconButton.module.css. If you'd prefer the stylelint rule loosened repo-wide instead — so future migrations of camelCase-token components don't each need the disable — that's a follow-up I'm happy to take separately.

Test plan

  • yarn test:visual tests/buttons/iconbutton.spec.ts — all 25 snapshots pass against the baseline with zero regenerations after the migration commit.
  • yarn test IconButton — unit tests pass unchanged.
  • yarn lint:code src/components/IconButton/ — no new errors.
  • yarn lint:css — clean (with the scoped disable noted above).
  • yarn build — succeeds.
  • grep -r 'styled-components' src/components/IconButton/ — empty.

🤖 Generated with Claude Code

DreaminDani and others added 2 commits May 19, 2026 17:51
…igration

Captures the current styled-components rendering for each type
variant (primary, secondary, ghost, danger, info), size variant
(default, sm, xs), disabled state, and interactive states (hover,
focus, active) under both light and dark themes. These snapshots
will be re-asserted byte-for-byte after the CSS Modules migration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces the inline styled.button template with an IconButton.module.css
+ cva/cn wrapper. The DOM (role, aria-label, disabled) and all visual
states are preserved byte-for-byte against the snapshots captured in the
baseline commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

🦋 Changeset detected

Latest commit: c97a548

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

@workflow-authentication-public
Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

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

Built from commit: 4b7fc73debd96cc7e63f8f411b4e296e871e42f4

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.

1 participant