component-css-modules-migration

Migrate Click UI components from styled-components to CSS Modules with visual regression parity.

132|29|Updated Mar 17, 2023
One-click install
npx skills add https://github.com/ClickHouse/click-ui --skill component-css-modules-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: component-css-modules-migration
Source: https://github.com/ClickHouse/click-ui/tree/main/.claude/skills/component-css-modules-migration
Command: npx skills add https://github.com/ClickHouse/click-ui --skill component-css-modules-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents visible regressions when migrating a Click UI component from styled-components to CSS Modules by enforcing a byte-for-byte, visual regression–verified workflow.

Core Features & Use Cases

  • Mechanical, scope-limited migration: Refactors styling only, preserving existing (even incorrect) behavior and DOM structure to keep visual diffs credible.
  • Visual regression baseline + parity enforcement: Captures a baseline from the styled-components rendering and requires CSS Modules snapshots to pass without regeneration.
  • Token-faithful CSS Modules implementation: Translates theme token usage into the correct --click-* CSS variables and mirrors selector/cascade behavior to match styled-components output.
  • Deterministic component refactor pattern: Replaces styled-components with cva + cn, preserves className merging, preserves prop/attribute spread order, and keeps forwardRef and displayName behavior.

Quick Start

Use this skill to migrate a single component (one at a time) by first creating a visual regression baseline on the existing styled-components stories and spec, then performing the CSS Modules + cva/cn refactor and verifying that yarn test:visual passes with zero snapshot changes.

Frequently Asked Questions about component-css-modules-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate styled-components to CSS Modules without visual regressions?

To migrate styled-components to CSS Modules without visual regressions, capture a Playwright visual regression baseline first, then refactor using `cva` and `cn` while enforcing snapshot acceptance criteria without regenerations.

What is the best way to preserve selector and cascade order when refactoring styled-components?

Preserving selector and cascade order when refactoring styled-components requires a mechanical, scope-limited approach that mirrors existing output behavior and translates theme tokens into the correct `--click-*` CSS variables.

Can I fix ARIA attributes while migrating a component to CSS Modules?

No, you should not fix ARIA or attribute correctness during a CSS Modules migration; the refactor is restricted to styling only to preserve existing behavior and keep visual diffs credible.

How do I use design tokens when migrating to CSS Modules?

Use design tokens during a CSS Modules migration by translating styled-components theme usage into the correct `--click-*` CSS variables found in `packages/design-tokens/dist/tokens.css`.

Does CSS Modules migration with visual regression testing work without existing Playwright tests?

No, visual regression testing for CSS Modules migration requires Playwright visual tests to run in the repo tooling to capture baselines and verify byte-for-byte parity without snapshot regenerations.

How do I handle className and prop spread precedence when replacing styled-components with cva?

Handle className and prop spread precedence when replacing styled-components with `cva` by using `cn` for deterministic className merging while preserving `forwardRef` and `displayName` behavior.