-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(Heading): update component to CSS Modules (#4819)
* refactor(Heading): update component to CSS Modules * test(e2e): add feature flags for Heading test * chore: fix stylelint errors * test(e2e): update snapshots for Heading * refactor(Heading): incorporate variant features into CSS Modules * chore: add changeset * test(e2e): remove theme testing * Fix props here * Remove examples/nextjs * Clean up css --------- Co-authored-by: Josh Black <joshblack@users.noreply.github.com> Co-authored-by: Jon Rohan <yes@jonrohan.codes>
- Loading branch information
1 parent
1a674f7
commit 0112347
Showing
14 changed files
with
156 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
Update Heading component to use CSS Modules behind feature flag |
Binary file removed
BIN
-10.8 KB
.../components/Heading.test.ts-snapshots/Heading-Default-dark-colorblind-linux.png
Binary file not shown.
Binary file removed
BIN
-10.8 KB
...hots/components/Heading.test.ts-snapshots/Heading-Default-dark-dimmed-linux.png
Binary file not shown.
Binary file removed
BIN
-10.7 KB
...mponents/Heading.test.ts-snapshots/Heading-Default-dark-high-contrast-linux.png
Binary file not shown.
Binary file removed
BIN
-10.8 KB
...t/snapshots/components/Heading.test.ts-snapshots/Heading-Default-dark-linux.png
Binary file not shown.
Binary file removed
BIN
-10.8 KB
.../components/Heading.test.ts-snapshots/Heading-Default-dark-tritanopia-linux.png
Binary file not shown.
Binary file removed
BIN
-10.7 KB
...components/Heading.test.ts-snapshots/Heading-Default-light-colorblind-linux.png
Binary file not shown.
Binary file removed
BIN
-10.6 KB
...ponents/Heading.test.ts-snapshots/Heading-Default-light-high-contrast-linux.png
Binary file not shown.
Binary file removed
BIN
-10.7 KB
.../snapshots/components/Heading.test.ts-snapshots/Heading-Default-light-linux.png
Binary file not shown.
Binary file removed
BIN
-10.7 KB
...components/Heading.test.ts-snapshots/Heading-Default-light-tritanopia-linux.png
Binary file not shown.
This file contains 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,74 +1,69 @@ | ||
import {test, expect} from '@playwright/test' | ||
import {visit} from '../test-helpers/storybook' | ||
|
||
test.describe('Heading', () => { | ||
test.describe('Default', () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading--default', | ||
}) | ||
|
||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Heading.Default.png`) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading--default', | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
|
||
test.describe('Small', () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading-features--small', | ||
}) | ||
const stories = [ | ||
{ | ||
title: 'Default', | ||
id: 'components-heading--default', | ||
}, | ||
{ | ||
title: 'Small', | ||
id: 'components-heading-features--small', | ||
}, | ||
{ | ||
title: 'Medium', | ||
id: 'components-heading-features--medium', | ||
}, | ||
{ | ||
title: 'Large', | ||
id: 'components-heading-features--large', | ||
}, | ||
] as const | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`Heading.Small.png`) | ||
}) | ||
test.describe('Heading', () => { | ||
for (const story of stories) { | ||
test.describe(story.title, () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: story.id, | ||
globals: { | ||
featureFlags: { | ||
primer_react_css_modules: true, | ||
}, | ||
}, | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading-features--small', | ||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Heading.${story.title}.png`) | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
|
||
test.describe('Medium', () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading-features--medium', | ||
}) | ||
test('default (styled-components) @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: story.id, | ||
}) | ||
|
||
expect(await page.screenshot()).toMatchSnapshot(`Heading.Medium.png`) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading-features--medium', | ||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Heading.${story.title}.png`) | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
|
||
test.describe('Large', () => { | ||
test('default @vrt', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading-features--large', | ||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: story.id, | ||
globals: { | ||
featureFlags: { | ||
primer_react_css_modules: true, | ||
}, | ||
}, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
|
||
// Default state | ||
expect(await page.screenshot()).toMatchSnapshot(`Heading.Large.png`) | ||
}) | ||
|
||
test('axe @aat', async ({page}) => { | ||
await visit(page, { | ||
id: 'components-heading-features--large', | ||
test('axe (styled-components) @aat', async ({page}) => { | ||
await visit(page, { | ||
id: story.id, | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
await expect(page).toHaveNoViolations() | ||
}) | ||
}) | ||
} | ||
}) |
This file contains 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,17 @@ | ||
.Heading { | ||
margin: 0; | ||
font-size: var(--text-title-size-large); | ||
font-weight: var(--base-text-weight-semibold); | ||
|
||
&[data-variant='large'] { | ||
font: var(--text-title-shorthand-large); | ||
} | ||
|
||
&[data-variant='medium'] { | ||
font: var(--text-title-shorthand-medium); | ||
} | ||
|
||
&[data-variant='small'] { | ||
font: var(--text-title-shorthand-small); | ||
} | ||
} |
This file contains 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 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