chore(Dialog): migrate to CSS Modules with visual regression baseline#1087
chore(Dialog): migrate to CSS Modules with visual regression baseline#1087DreaminDani wants to merge 3 commits into
Conversation
…tion Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e4ce0c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Pull request overview
Migrates the Dialog component’s styling from styled-components to a CSS Modules implementation while adding Storybook variants and Playwright visual-regression coverage to lock in visual parity.
Changes:
- Added a new Playwright visual regression spec for
Dialogvariants across light/dark themes plus basic accessibility assertions. - Reworked
Dialogto useDialog.module.csswithcva/cn, and allowedclassNamecomposition on trigger/content. - Expanded Storybook stories to include additional named variants used by the visual tests, and added a patch changeset.
Reviewed changes
Copilot reviewed 5 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/display/dialog.spec.ts | Adds visual regression + a11y coverage for Dialog variants in light/dark. |
| src/components/Dialog/Dialog.tsx | Switches Dialog styling from styled-components to CSS Modules with cva/cn and className composition. |
| src/components/Dialog/Dialog.stories.tsx | Adds/adjusts stories for visual baselines; removes styled-components wrappers. |
| src/components/Dialog/Dialog.module.css | New CSS Modules stylesheet implementing prior Dialog styles and animations. |
| .changeset/migrate-dialog-to-css-modules.md | Records a patch release note for the migration. |
Comments suppressed due to low confidence (1)
src/components/Dialog/Dialog.tsx:85
CloseButtononly destructuresonCloseand does not forward other props toCrossButton. As a result,data-testid="click-dialog-close"passed at the call site is silently dropped (and any future attributes likearia-label/classNamewould be too). Forward remaining props and mergeonClickwithonClose.
const CloseButton = ({ onClose }: { onClose?: () => void }) => (
<RadixDialog.Close asChild>
<CrossButton onClick={onClose}>
<Icon
name="cross"
size="lg"
/>
</CrossButton>
</RadixDialog.Close>
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Storybook Preview Deployed✅ Preview URL: https://click-fwc6zx0vu-clickhouse.vercel.app Built from commit: |
Commits
test(Dialog): add visual regression baseline before CSS Modules migration— adds named stories per visual variant (modal, with-description, title-only, only-close, no-header, reduce-padding, chat), a Playwright spec covering light + dark themes plus accessibility assertions, and fresh PNG snapshots that capture the current rendering. Also converts the two styled-components story wrappers (ActionArea,TopNav) to inline-styled divs so the baseline file carries no styled-components.chore(Dialog): migrate styling from styled-components to CSS Modules— replaces styled-components withDialog.module.css+cva/cn. DOM-identical, byte-for-byte visual parity verified.Verification
yarn test:visual tests/display/dialog.spec.tspasses with zero snapshot regenerations (migrated CSS Modules vs the styled-components baseline)yarn test Dialog,yarn lint:css,yarn lint:code,yarn format,yarn buildall greengrep -r 'styled-components' src/components/Dialog/emptyNote
Low Risk
Styling-only refactor of a UI component with visual regression tests; public props and Radix behavior are intended to stay the same.
Overview
Dialog styling moves from styled-components to
Dialog.module.css, using design-token CSS variables andcva/cnforreducePaddingand title-bar layout (onlyClose). Radix primitives get module classes directly;Dialog.TriggerandDialog.Contentnow acceptclassNamefor extension without changing behavior.Storybook adds dedicated stories (title-only, only-close, no header, reduce padding, etc.) and replaces story-only styled wrappers with inline CSS variables. A new Playwright spec (
tests/display/dialog.spec.ts) locks light/dark screenshots and basic a11y checks against those stories. Patch changeset documents a no-behavior-change release.Reviewed by Cursor Bugbot for commit e4ce0c9. Bugbot is set up for automated code reviews on this repo. Configure here.