@newjersey/njwds 2.9.0 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/.nvmrc +1 -1
  2. package/README.md +10 -0
  3. package/dist/css/button.css +1 -1
  4. package/dist/css/button.css.map +1 -1
  5. package/dist/css/icon.css +1 -1
  6. package/dist/css/icon.css.map +1 -1
  7. package/dist/css/styles.css +2 -2
  8. package/dist/css/styles.css.map +1 -1
  9. package/package.json +18 -5
  10. package/src/components/02-buttons/buttons.njk +4 -4
  11. package/src/sass/_uswds-theme-custom-styles.scss +12 -326
  12. package/src/sass/_uswds-theme.scss +2 -2
  13. package/src/sass/button.scss +3 -68
  14. package/src/sass/icon.scss +2 -69
  15. package/src/sass/styles.scss +1 -65
  16. package/src/sass/theme/nj-banner/index.scss +1 -0
  17. package/src/sass/theme/nj-banner/nj-banner.scss +57 -0
  18. package/src/sass/theme/nj-button/index.scss +6 -0
  19. package/src/sass/theme/nj-button/nj-button-icon.scss +12 -0
  20. package/src/sass/theme/nj-button/nj-button-outline.scss +55 -0
  21. package/src/sass/theme/nj-button/nj-button-primary.scss +22 -0
  22. package/src/sass/theme/nj-button/nj-button-secondary.scss +15 -0
  23. package/src/sass/theme/nj-button/nj-button-unstyled.scss +48 -0
  24. package/src/sass/theme/nj-button/nj-button.scss +12 -0
  25. package/src/sass/theme/nj-error-message/index.scss +1 -0
  26. package/src/sass/theme/nj-error-message/nj-error-message.scss +19 -0
  27. package/src/sass/theme/nj-forms/index.scss +1 -0
  28. package/src/sass/theme/nj-forms/nj-forms.scss +39 -0
  29. package/src/sass/theme/nj-header/index.scss +1 -0
  30. package/src/sass/theme/nj-header/nj-header.scss +8 -0
  31. package/src/sass/theme/nj-hero/index.scss +1 -0
  32. package/src/sass/theme/nj-hero/nj-hero.scss +6 -0
  33. package/src/sass/theme/nj-icon/index.scss +1 -0
  34. package/src/sass/theme/nj-icon/nj-icon.scss +21 -0
  35. package/src/sass/theme/nj-intro/index.scss +1 -0
  36. package/src/sass/theme/nj-intro/nj-intro.scss +5 -0
  37. package/src/sass/theme/nj-nav/index.scss +1 -0
  38. package/src/sass/theme/nj-nav/nj-nav.scss +7 -0
  39. package/src/sass/theme/nj-prose/index.scss +1 -0
  40. package/src/sass/theme/nj-prose/nj-prose.scss +14 -0
  41. package/src/sass/theme/nj-section/index.scss +1 -0
  42. package/src/sass/theme/nj-section/nj-section.scss +6 -0
  43. package/src/tests/__screenshots__/banner/banner.visual.spec.ts/banner-narrow.png +0 -0
  44. package/src/tests/__screenshots__/banner/banner.visual.spec.ts/banner-wide.png +0 -0
  45. package/src/tests/__screenshots__/button/visual/button-danger.visual.spec.ts/button-danger-narrow.png +0 -0
  46. package/src/tests/__screenshots__/button/visual/button-danger.visual.spec.ts/button-danger-wide.png +0 -0
  47. package/src/tests/__screenshots__/button/visual/button-dark.visual.spec.ts/button-dark-narrow.png +0 -0
  48. package/src/tests/__screenshots__/button/visual/button-dark.visual.spec.ts/button-dark-wide.png +0 -0
  49. package/src/tests/__screenshots__/button/visual/button-secondary-danger.visual.spec.ts/button-secondary-danger-narrow.png +0 -0
  50. package/src/tests/__screenshots__/button/visual/button-secondary-danger.visual.spec.ts/button-secondary-danger-wide.png +0 -0
  51. package/src/tests/__screenshots__/button/visual/button-secondary-dark.visual.spec.ts/button-secondary-dark-narrow.png +0 -0
  52. package/src/tests/__screenshots__/button/visual/button-secondary-dark.visual.spec.ts/button-secondary-dark-wide.png +0 -0
  53. package/src/tests/__screenshots__/button/visual/button-secondary.visual.spec.ts/button-secondary-narrow.png +0 -0
  54. package/src/tests/__screenshots__/button/visual/button-secondary.visual.spec.ts/button-secondary-wide.png +0 -0
  55. package/src/tests/__screenshots__/button/visual/button-tertiary-danger.visual.spec.ts/button-tertiary-danger-narrow.png +0 -0
  56. package/src/tests/__screenshots__/button/visual/button-tertiary-danger.visual.spec.ts/button-tertiary-danger-wide.png +0 -0
  57. package/src/tests/__screenshots__/button/visual/button-tertiary-dark.visual.spec.ts/button-tertiary-dark-narrow.png +0 -0
  58. package/src/tests/__screenshots__/button/visual/button-tertiary-dark.visual.spec.ts/button-tertiary-dark-wide.png +0 -0
  59. package/src/tests/__screenshots__/button/visual/button-tertiary.visual.spec.ts/button-tertiary-narrow.png +0 -0
  60. package/src/tests/__screenshots__/button/visual/button-tertiary.visual.spec.ts/button-tertiary-wide.png +0 -0
  61. package/src/tests/__screenshots__/button/visual/button.visual.spec.ts/button-narrow.png +0 -0
  62. package/src/tests/__screenshots__/button/visual/button.visual.spec.ts/button-wide.png +0 -0
  63. package/src/tests/banner/banner.accessibility.spec.ts +28 -0
  64. package/src/tests/banner/banner.visual.spec.ts +35 -0
  65. package/src/tests/button/accessibility/button-danger.accessibility.spec.ts +30 -0
  66. package/src/tests/button/accessibility/button-dark.accessibility.spec.ts +30 -0
  67. package/src/tests/button/accessibility/button-secondary-danger.accessibility.spec.ts +30 -0
  68. package/src/tests/button/accessibility/button-secondary-dark.accessibility.spec.ts +30 -0
  69. package/src/tests/button/accessibility/button-secondary.accessibility.spec.ts +30 -0
  70. package/src/tests/button/accessibility/button-tertiary-danger.accessibility.spec.ts +30 -0
  71. package/src/tests/button/accessibility/button-tertiary-dark.accessibility.spec.ts +30 -0
  72. package/src/tests/button/accessibility/button-tertiary.accessibility.spec.ts +30 -0
  73. package/src/tests/button/accessibility/button.accessibility.spec.ts +30 -0
  74. package/src/tests/button/visual/button-danger.visual.spec.ts +35 -0
  75. package/src/tests/button/visual/button-dark.visual.spec.ts +35 -0
  76. package/src/tests/button/visual/button-secondary-danger.visual.spec.ts +35 -0
  77. package/src/tests/button/visual/button-secondary-dark.visual.spec.ts +35 -0
  78. package/src/tests/button/visual/button-secondary.visual.spec.ts +35 -0
  79. package/src/tests/button/visual/button-tertiary-danger.visual.spec.ts +35 -0
  80. package/src/tests/button/visual/button-tertiary-dark.visual.spec.ts +35 -0
  81. package/src/tests/button/visual/button-tertiary.visual.spec.ts +35 -0
  82. package/src/tests/button/visual/button.visual.spec.ts +35 -0
@@ -0,0 +1,30 @@
1
+ import { test, expect } from "@playwright/test";
2
+ import AxeBuilder from "@axe-core/playwright";
3
+
4
+ // The base URL for your locally served components.
5
+ const BASE_URL = "http://localhost:3000";
6
+
7
+ // The specific page URL for the Button component preview.
8
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(light)`;
9
+
10
+ // Group all accessibility tests for the Button component under a single describe block.
11
+ test.describe("Button, secondary - accessibility", () => {
12
+ // Primary axe-core scan for this component.
13
+ test("has no detectable a11y violations", async ({ page }) => {
14
+ // Open the page at the URL defined above.
15
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
16
+ // finished before running the accessibility scan.
17
+ await page.goto(PAGE_URL);
18
+ await page.waitForLoadState("networkidle");
19
+
20
+ // .include(".usa-button") ensures the scan is scoped to the Button itself.
21
+ const accessibilityScanResults = await new AxeBuilder({ page })
22
+ .include(".usa-button")
23
+ .analyze();
24
+
25
+ // If axe finds any violations, this test will fail, and Playwright will
26
+ // report detailed information about each issue (impact, rule, affected nodes).
27
+ // The empty array assertion ensures only a clean, violation-free component passes.
28
+ expect(accessibilityScanResults.violations).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,30 @@
1
+ import { test, expect } from "@playwright/test";
2
+ import AxeBuilder from "@axe-core/playwright";
3
+
4
+ // The base URL for your locally served components.
5
+ const BASE_URL = "http://localhost:3000";
6
+
7
+ // The specific page URL for the Button component preview.
8
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(danger)`;
9
+
10
+ // Group all accessibility tests for the Button component under a single describe block.
11
+ test.describe("Button, tertiary danger - accessibility", () => {
12
+ // Primary axe-core scan for this component.
13
+ test("has no detectable a11y violations", async ({ page }) => {
14
+ // Open the page at the URL defined above.
15
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
16
+ // finished before running the accessibility scan.
17
+ await page.goto(PAGE_URL);
18
+ await page.waitForLoadState("networkidle");
19
+
20
+ // .include(".usa-button") ensures the scan is scoped to the Button itself.
21
+ const accessibilityScanResults = await new AxeBuilder({ page })
22
+ .include(".usa-button")
23
+ .analyze();
24
+
25
+ // If axe finds any violations, this test will fail, and Playwright will
26
+ // report detailed information about each issue (impact, rule, affected nodes).
27
+ // The empty array assertion ensures only a clean, violation-free component passes.
28
+ expect(accessibilityScanResults.violations).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,30 @@
1
+ import { test, expect } from "@playwright/test";
2
+ import AxeBuilder from "@axe-core/playwright";
3
+
4
+ // The base URL for your locally served components.
5
+ const BASE_URL = "http://localhost:3000";
6
+
7
+ // The specific page URL for the Button component preview.
8
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(dark)`;
9
+
10
+ // Group all accessibility tests for the Button component under a single describe block.
11
+ test.describe("Button, tertiary dark - accessibility", () => {
12
+ // Primary axe-core scan for this component.
13
+ test("has no detectable a11y violations", async ({ page }) => {
14
+ // Open the page at the URL defined above.
15
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
16
+ // finished before running the accessibility scan.
17
+ await page.goto(PAGE_URL);
18
+ await page.waitForLoadState("networkidle");
19
+
20
+ // .include(".usa-button") ensures the scan is scoped to the Button itself.
21
+ const accessibilityScanResults = await new AxeBuilder({ page })
22
+ .include(".usa-button")
23
+ .analyze();
24
+
25
+ // If axe finds any violations, this test will fail, and Playwright will
26
+ // report detailed information about each issue (impact, rule, affected nodes).
27
+ // The empty array assertion ensures only a clean, violation-free component passes.
28
+ expect(accessibilityScanResults.violations).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,30 @@
1
+ import { test, expect } from "@playwright/test";
2
+ import AxeBuilder from "@axe-core/playwright";
3
+
4
+ // The base URL for your locally served components.
5
+ const BASE_URL = "http://localhost:3000";
6
+
7
+ // The specific page URL for the Button component preview.
8
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(light)`;
9
+
10
+ // Group all accessibility tests for the Button component under a single describe block.
11
+ test.describe("Button, tertiary - accessibility", () => {
12
+ // Primary axe-core scan for this component.
13
+ test("has no detectable a11y violations", async ({ page }) => {
14
+ // Open the page at the URL defined above.
15
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
16
+ // finished before running the accessibility scan.
17
+ await page.goto(PAGE_URL);
18
+ await page.waitForLoadState("networkidle");
19
+
20
+ // .include(".usa-button") ensures the scan is scoped to the Button itself.
21
+ const accessibilityScanResults = await new AxeBuilder({ page })
22
+ .include(".usa-button")
23
+ .analyze();
24
+
25
+ // If axe finds any violations, this test will fail, and Playwright will
26
+ // report detailed information about each issue (impact, rule, affected nodes).
27
+ // The empty array assertion ensures only a clean, violation-free component passes.
28
+ expect(accessibilityScanResults.violations).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,30 @@
1
+ import { test, expect } from "@playwright/test";
2
+ import AxeBuilder from "@axe-core/playwright";
3
+
4
+ // The base URL for your locally served components.
5
+ const BASE_URL = "http://localhost:3000";
6
+
7
+ // The specific page URL for the Button component preview.
8
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(light)`;
9
+
10
+ // Group all accessibility tests for the Button component under a single describe block.
11
+ test.describe("Button, primary - accessibility", () => {
12
+ // Primary axe-core scan for this component.
13
+ test("has no detectable a11y violations", async ({ page }) => {
14
+ // Open the page at the URL defined above.
15
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
16
+ // finished before running the accessibility scan.
17
+ await page.goto(PAGE_URL);
18
+ await page.waitForLoadState("networkidle");
19
+
20
+ // .include(".usa-button") ensures the scan is scoped to the Button itself.
21
+ const accessibilityScanResults = await new AxeBuilder({ page })
22
+ .include(".usa-button")
23
+ .analyze();
24
+
25
+ // If axe finds any violations, this test will fail, and Playwright will
26
+ // report detailed information about each issue (impact, rule, affected nodes).
27
+ // The empty array assertion ensures only a clean, violation-free component passes.
28
+ expect(accessibilityScanResults.violations).toEqual([]);
29
+ });
30
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(danger)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, danger - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-danger-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(dark)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, dark - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-dark-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(danger)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, secondary danger - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-secondary-danger-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(dark)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, secondary dark - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-secondary-dark-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--secondary-(light)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, secondary - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-secondary-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(danger)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, tertiary danger - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-tertiary-danger-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(dark)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, tertiary dark - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-tertiary-dark-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--tertiary-(light)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, tertiary - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-tertiary-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });
@@ -0,0 +1,35 @@
1
+ import { test, expect } from "@playwright/test";
2
+
3
+ const BASE_URL = "http://localhost:3000";
4
+ const PAGE_URL = `${BASE_URL}/components/preview/buttons--primary-(light)`;
5
+
6
+ const viewports = [
7
+ { name: "narrow", width: 375, height: 800 },
8
+ { name: "wide", width: 1280, height: 800 },
9
+ ];
10
+
11
+ test.describe("Button, primary - visual regression", () => {
12
+ for (const viewport of viewports) {
13
+ test(`renders correctly (${viewport.name})`, async ({ page }) => {
14
+ await page.setViewportSize({
15
+ width: viewport.width,
16
+ height: viewport.height,
17
+ });
18
+
19
+ // Stabilize rendering:
20
+ await page.emulateMedia({ reducedMotion: "reduce" });
21
+
22
+ // Open the page at the URL defined above.
23
+ // Using `networkidle` ensures that all network requests (CSS, fonts, JS) have
24
+ // finished before running the test.
25
+ await page.goto(PAGE_URL);
26
+ await page.waitForLoadState("networkidle");
27
+
28
+ // Full-page screenshot
29
+ await expect(page).toHaveScreenshot(`button-${viewport.name}.png`, {
30
+ fullPage: true,
31
+ maxDiffPixelRatio: 0.01, // allow a 1px difference
32
+ });
33
+ });
34
+ }
35
+ });