-
Notifications
You must be signed in to change notification settings - Fork 22
chore(Spacer): migrate to CSS Modules with visual regression baseline #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clickhouse/click-ui': patch | ||
| --- | ||
|
|
||
| Migrate Spacer from styled-components to css modules with no change in behavior |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| .spacer { | ||
| display: flex; | ||
| background: transparent; | ||
| } | ||
|
|
||
| .spacer_size_xs { | ||
| padding: var(--click-spacer-horizontal-space-y-xs) var(--click-spacer-horizontal-space-x-all); | ||
| } | ||
|
|
||
| .spacer_size_sm { | ||
| padding: var(--click-spacer-horizontal-space-y-sm) var(--click-spacer-horizontal-space-x-all); | ||
| } | ||
|
|
||
| .spacer_size_md { | ||
| padding: var(--click-spacer-horizontal-space-y-md) var(--click-spacer-horizontal-space-x-all); | ||
| } | ||
|
|
||
| .spacer_size_lg { | ||
| padding: var(--click-spacer-horizontal-space-y-lg) var(--click-spacer-horizontal-space-x-all); | ||
| } | ||
|
|
||
| .spacer_size_xl { | ||
| padding: var(--click-spacer-horizontal-space-y-xl) var(--click-spacer-horizontal-space-x-all); | ||
| } | ||
|
|
||
| .spacer_size_xxl { | ||
| padding: var(--click-spacer-horizontal-space-y-xxl) var(--click-spacer-horizontal-space-x-all); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,23 @@ | ||
| import { styled } from 'styled-components'; | ||
| import { SpacerProps, SizeType } from './Spacer.types'; | ||
| import { cn, cva } from '@/lib/cva'; | ||
| import { SpacerProps } from './Spacer.types'; | ||
| import styles from './Spacer.module.css'; | ||
|
|
||
| const CUISpacer = styled.div<{ | ||
| $size?: SizeType; | ||
| }>` | ||
| background: transparent; | ||
| display: flex; | ||
| padding: ${({ theme, $size = 'md' }) => | ||
| `${theme.click.spacer.horizontal.space.y[$size]} ${theme.click.spacer.horizontal.space.x.all}`}; | ||
| `; | ||
| const spacerVariants = cva(styles.spacer, { | ||
| variants: { | ||
| size: { | ||
| xs: styles['spacer_size_xs'], | ||
| sm: styles['spacer_size_sm'], | ||
| md: styles['spacer_size_md'], | ||
| lg: styles['spacer_size_lg'], | ||
| xl: styles['spacer_size_xl'], | ||
| xxl: styles['spacer_size_xxl'], | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| size: 'md', | ||
| }, | ||
| }); | ||
|
|
||
| export const Spacer = ({ size }: SpacerProps) => <CUISpacer $size={size} />; | ||
| export const Spacer = ({ size }: SpacerProps) => ( | ||
| <div className={cn(spacerVariants({ size }))} /> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| import { test as it, expect } from '@playwright/test'; | ||
| import { getStoryUrl } from '../utils'; | ||
|
|
||
| const { describe, use } = it; | ||
|
|
||
|
DreaminDani marked this conversation as resolved.
|
||
| const harnessLocator = '[data-testid="spacer-harness"]'; | ||
|
|
||
| describe('Spacer Visual Regression', () => { | ||
| describe('Light Theme (Storybook Global)', () => { | ||
| describe('Size Variants', () => { | ||
| it('xs size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-xs', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-xs-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('sm size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-sm', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-sm-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('md size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-md', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-md-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('lg size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-lg', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-lg-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('xl size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-xl', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-xl-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('xxl size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-xxl', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-xxl-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('default size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--default-size', 'light'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-default-size-light.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Dark Theme (System prefers-color-scheme)', () => { | ||
| use({ colorScheme: 'dark' }); | ||
|
|
||
| describe('Size Variants', () => { | ||
| it('xs size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-xs'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-xs-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('sm size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-sm'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-sm-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('md size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-md'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-md-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('lg size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-lg'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-lg-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('xl size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-xl'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-xl-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('xxl size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--size-xxl'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-size-xxl-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
|
|
||
| it('default size matches snapshot', async ({ page }) => { | ||
| await page.goto(getStoryUrl('display-spacer--default-size'), { | ||
| waitUntil: 'networkidle', | ||
| }); | ||
| const harness = page.locator(harnessLocator).first(); | ||
| await expect(harness).toBeVisible({ timeout: 10000 }); | ||
| await expect(harness).toHaveScreenshot('spacer-default-size-dark.png', { | ||
| maxDiffPixels: 100, | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
Binary file added
BIN
+256 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-default-size-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+256 Bytes
...s/display/spacer.spec.ts-snapshots/spacer-default-size-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+292 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-lg-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+292 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-lg-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+256 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-md-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+256 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-md-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+238 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-sm-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+238 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-sm-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+326 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-xl-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+326 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-xl-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+205 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-xs-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+205 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-xs-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+362 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-xxl-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+362 Bytes
tests/display/spacer.spec.ts-snapshots/spacer-size-xxl-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.