@nationaldesignstudio/react 0.5.2 → 0.5.3
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.
- package/package.json +10 -2
- package/src/App.css +0 -0
- package/src/App.tsx +0 -7
- package/src/assets/fonts/PPNeueMontreal-Variable.woff2 +0 -0
- package/src/assets/react.svg +0 -1
- package/src/components/atoms/accordion/accordion.stories.tsx +0 -228
- package/src/components/atoms/accordion/accordion.test.tsx +0 -231
- package/src/components/atoms/accordion/index.ts +0 -6
- package/src/components/atoms/background/background.test.tsx +0 -213
- package/src/components/atoms/background/index.ts +0 -22
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-charcoal-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-charcoal-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-charcoal-outline-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-charcoal-outline-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-charcoal-outline-quiet-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-charcoal-outline-quiet-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-disabled-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-disabled-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-ivory-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-ivory-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-ivory-outline-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-ivory-outline-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-ivory-outline-quiet-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-ivory-outline-quiet-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-size-large-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-size-large-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-size-medium-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-size-medium-chromium-linux.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-size-small-chromium-darwin.png +0 -0
- package/src/components/atoms/button/__screenshots__/button.visual.test.tsx/button-size-small-chromium-linux.png +0 -0
- package/src/components/atoms/button/button.stories.tsx +0 -289
- package/src/components/atoms/button/button.test.tsx +0 -419
- package/src/components/atoms/button/button.visual.test.tsx +0 -98
- package/src/components/atoms/button/icon-button.stories.tsx +0 -260
- package/src/components/atoms/button/icon-button.test.tsx +0 -186
- package/src/components/atoms/button/index.ts +0 -6
- package/src/components/atoms/input/index.ts +0 -17
- package/src/components/atoms/input/input-group.stories.tsx +0 -646
- package/src/components/atoms/input/input-group.test.tsx +0 -362
- package/src/components/atoms/input/input.stories.tsx +0 -228
- package/src/components/atoms/input/input.test.tsx +0 -167
- package/src/components/atoms/ndstudio-footer/index.ts +0 -1
- package/src/components/atoms/pager-control/index.ts +0 -5
- package/src/components/atoms/pager-control/pager-control.stories.tsx +0 -207
- package/src/components/atoms/pager-control/pager-control.test.tsx +0 -130
- package/src/components/atoms/popover/index.ts +0 -30
- package/src/components/atoms/popover/popover.stories.tsx +0 -531
- package/src/components/atoms/popover/popover.test.tsx +0 -486
- package/src/components/atoms/select/index.ts +0 -18
- package/src/components/atoms/select/select.stories.tsx +0 -455
- package/src/components/atoms/tooltip/index.ts +0 -24
- package/src/components/atoms/tooltip/tooltip.stories.tsx +0 -348
- package/src/components/atoms/tooltip/tooltip.test.tsx +0 -363
- package/src/components/dev-tools/dev-toolbar/dev-toolbar.stories.tsx +0 -73
- package/src/components/dev-tools/dev-toolbar/index.ts +0 -1
- package/src/components/dev-tools/grid-overlay/index.ts +0 -1
- package/src/components/dev-tools/index.ts +0 -2
- package/src/components/foundation/typography/typography.stories.tsx +0 -401
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-default-vertical-chromium-darwin.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-default-vertical-chromium-linux.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-horizontal-chromium-darwin.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-horizontal-chromium-linux.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-minimal-chromium-darwin.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-minimal-chromium-linux.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-without-actions-chromium-darwin.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-without-actions-chromium-linux.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-without-eyebrow-chromium-darwin.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-without-eyebrow-chromium-linux.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-without-image-chromium-darwin.png +0 -0
- package/src/components/organisms/card/__screenshots__/card.visual.test.tsx/card-without-image-chromium-linux.png +0 -0
- package/src/components/organisms/card/card.stories.tsx +0 -293
- package/src/components/organisms/card/card.test.tsx +0 -247
- package/src/components/organisms/card/card.visual.test.tsx +0 -197
- package/src/components/organisms/card/index.ts +0 -26
- package/src/components/organisms/navbar/__screenshots__/navbar.visual.test.tsx/navbar-active-link-chromium-darwin.png +0 -0
- package/src/components/organisms/navbar/__screenshots__/navbar.visual.test.tsx/navbar-active-link-chromium-linux.png +0 -0
- package/src/components/organisms/navbar/__screenshots__/navbar.visual.test.tsx/navbar-brand-only-chromium-darwin.png +0 -0
- package/src/components/organisms/navbar/__screenshots__/navbar.visual.test.tsx/navbar-brand-only-chromium-linux.png +0 -0
- package/src/components/organisms/navbar/__screenshots__/navbar.visual.test.tsx/navbar-default-chromium-darwin.png +0 -0
- package/src/components/organisms/navbar/__screenshots__/navbar.visual.test.tsx/navbar-default-chromium-linux.png +0 -0
- package/src/components/organisms/navbar/index.ts +0 -18
- package/src/components/organisms/navbar/navbar.stories.tsx +0 -313
- package/src/components/organisms/navbar/navbar.test.tsx +0 -190
- package/src/components/organisms/navbar/navbar.visual.test.tsx +0 -85
- package/src/components/organisms/us-gov-banner/__screenshots__/us-gov-banner.visual.test.tsx/us-gov-banner-custom-icon-chromium-darwin.png +0 -0
- package/src/components/organisms/us-gov-banner/__screenshots__/us-gov-banner.visual.test.tsx/us-gov-banner-custom-icon-chromium-linux.png +0 -0
- package/src/components/organisms/us-gov-banner/__screenshots__/us-gov-banner.visual.test.tsx/us-gov-banner-custom-text-chromium-darwin.png +0 -0
- package/src/components/organisms/us-gov-banner/__screenshots__/us-gov-banner.visual.test.tsx/us-gov-banner-custom-text-chromium-linux.png +0 -0
- package/src/components/organisms/us-gov-banner/__screenshots__/us-gov-banner.visual.test.tsx/us-gov-banner-default-chromium-darwin.png +0 -0
- package/src/components/organisms/us-gov-banner/__screenshots__/us-gov-banner.visual.test.tsx/us-gov-banner-default-chromium-linux.png +0 -0
- package/src/components/organisms/us-gov-banner/index.ts +0 -5
- package/src/components/organisms/us-gov-banner/us-gov-banner.stories.tsx +0 -35
- package/src/components/organisms/us-gov-banner/us-gov-banner.test.tsx +0 -107
- package/src/components/organisms/us-gov-banner/us-gov-banner.visual.test.tsx +0 -46
- package/src/components/sections/banner/banner.stories.tsx +0 -150
- package/src/components/sections/banner/banner.test.tsx +0 -185
- package/src/components/sections/banner/index.ts +0 -2
- package/src/components/sections/card-grid/card-grid.stories.tsx +0 -351
- package/src/components/sections/card-grid/index.ts +0 -1
- package/src/components/sections/faq-section/faq-section.stories.tsx +0 -453
- package/src/components/sections/faq-section/index.ts +0 -2
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a1-desktop-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a1-desktop-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a1-mobile-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a1-mobile-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a1-tablet-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a1-tablet-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a2-desktop-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a2-desktop-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a2-mobile-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a2-mobile-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a2-tablet-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a2-tablet-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a3-desktop-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a3-desktop-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a3-mobile-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a3-mobile-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a3-tablet-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-a3-tablet-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-custom-class-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-custom-class-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-default-chromium-linux.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-long-title-chromium-darwin.png +0 -0
- package/src/components/sections/hero/__screenshots__/hero.visual.test.tsx/hero-long-title-chromium-linux.png +0 -0
- package/src/components/sections/hero/hero.stories.tsx +0 -397
- package/src/components/sections/hero/hero.test.tsx +0 -138
- package/src/components/sections/hero/hero.visual.test.tsx +0 -140
- package/src/components/sections/hero/index.ts +0 -23
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-h3-heading-chromium-darwin.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-h3-heading-chromium-linux.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-multiple-paragraphs-chromium-darwin.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-multiple-paragraphs-chromium-linux.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-multiple-sections-chromium-darwin.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-multiple-sections-chromium-linux.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-single-section-chromium-darwin.png +0 -0
- package/src/components/sections/prose/__screenshots__/prose.visual.test.tsx/prose-single-section-chromium-linux.png +0 -0
- package/src/components/sections/prose/index.ts +0 -6
- package/src/components/sections/prose/prose.stories.tsx +0 -144
- package/src/components/sections/prose/prose.test.tsx +0 -178
- package/src/components/sections/prose/prose.visual.test.tsx +0 -105
- package/src/components/sections/quote-block/index.ts +0 -5
- package/src/components/sections/river/index.ts +0 -1
- package/src/components/sections/river/river.stories.tsx +0 -237
- package/src/components/sections/river/river.test.tsx +0 -268
- package/src/components/sections/tout/index.ts +0 -1
- package/src/components/sections/tout/tout.stories.tsx +0 -171
- package/src/components/sections/tout/tout.test.tsx +0 -242
- package/src/components/sections/two-column-section/index.ts +0 -5
- package/src/components/sections/two-column-section/two-column-section.stories.tsx +0 -285
- package/src/components/shared/index.ts +0 -5
- package/src/index.ts +0 -293
- package/src/main.tsx +0 -13
- package/src/stories/grid-system.stories.tsx +0 -309
- package/src/stories/introduction.mdx +0 -128
- package/src/stories/theme-provider.stories.tsx +0 -349
- package/src/stories/token-showcase.stories.tsx +0 -73
- package/src/stories/token-showcase.tsx +0 -777
- package/src/styles.css +0 -14
- package/src/tests/token-resolution.test.tsx +0 -298
- package/src/theme/theme-provider.test.tsx +0 -270
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { page } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
import { Button } from "../../atoms/button";
|
|
5
|
-
import {
|
|
6
|
-
Navbar,
|
|
7
|
-
NavbarActions,
|
|
8
|
-
NavbarBrand,
|
|
9
|
-
NavbarLink,
|
|
10
|
-
NavbarLinks,
|
|
11
|
-
} from "./navbar";
|
|
12
|
-
|
|
13
|
-
describe("Navbar", () => {
|
|
14
|
-
describe("Accessibility", () => {
|
|
15
|
-
test("renders as nav landmark", async () => {
|
|
16
|
-
render(
|
|
17
|
-
<Navbar>
|
|
18
|
-
<NavbarBrand>Logo</NavbarBrand>
|
|
19
|
-
</Navbar>,
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
await expect.element(page.getByRole("navigation")).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("links are accessible", async () => {
|
|
26
|
-
// NavbarLinks is hidden at mobile viewport, set to desktop
|
|
27
|
-
await page.viewport(1280, 800);
|
|
28
|
-
|
|
29
|
-
render(
|
|
30
|
-
<Navbar>
|
|
31
|
-
<NavbarLinks>
|
|
32
|
-
<NavbarLink href="/home">Home</NavbarLink>
|
|
33
|
-
<NavbarLink href="/about">About</NavbarLink>
|
|
34
|
-
</NavbarLinks>
|
|
35
|
-
</Navbar>,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
await expect
|
|
39
|
-
.element(page.getByRole("link", { name: "Home" }))
|
|
40
|
-
.toBeInTheDocument();
|
|
41
|
-
await expect
|
|
42
|
-
.element(page.getByRole("link", { name: "About" }))
|
|
43
|
-
.toBeInTheDocument();
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("links have correct href attributes", async () => {
|
|
47
|
-
// NavbarLinks is hidden at mobile viewport, set to desktop
|
|
48
|
-
await page.viewport(1280, 800);
|
|
49
|
-
|
|
50
|
-
render(
|
|
51
|
-
<Navbar>
|
|
52
|
-
<NavbarLinks>
|
|
53
|
-
<NavbarLink href="/test-page">Test Link</NavbarLink>
|
|
54
|
-
</NavbarLinks>
|
|
55
|
-
</Navbar>,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
await expect
|
|
59
|
-
.element(page.getByRole("link", { name: "Test Link" }))
|
|
60
|
-
.toHaveAttribute("href", "/test-page");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test("buttons in actions are accessible", async () => {
|
|
64
|
-
render(
|
|
65
|
-
<Navbar>
|
|
66
|
-
<NavbarActions>
|
|
67
|
-
<Button>Sign In</Button>
|
|
68
|
-
</NavbarActions>
|
|
69
|
-
</Navbar>,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
await expect
|
|
73
|
-
.element(page.getByRole("button", { name: "Sign In" }))
|
|
74
|
-
.toBeInTheDocument();
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
describe("NavbarLink", () => {
|
|
79
|
-
test("active link has different styling", async () => {
|
|
80
|
-
// NavbarLinks is hidden at mobile viewport, set to desktop
|
|
81
|
-
await page.viewport(1280, 800);
|
|
82
|
-
|
|
83
|
-
render(
|
|
84
|
-
<Navbar>
|
|
85
|
-
<NavbarLinks>
|
|
86
|
-
<NavbarLink href="#" active data-testid="active-link">
|
|
87
|
-
Active
|
|
88
|
-
</NavbarLink>
|
|
89
|
-
<NavbarLink href="#" data-testid="inactive-link">
|
|
90
|
-
Inactive
|
|
91
|
-
</NavbarLink>
|
|
92
|
-
</NavbarLinks>
|
|
93
|
-
</Navbar>,
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const activeLink = page.getByTestId("active-link");
|
|
97
|
-
await expect.element(activeLink).toHaveClass(/text-gray-1100/);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("supports asChild prop for router links", async () => {
|
|
101
|
-
// NavbarLinks is hidden at mobile viewport, set to desktop
|
|
102
|
-
await page.viewport(1280, 800);
|
|
103
|
-
|
|
104
|
-
render(
|
|
105
|
-
<Navbar>
|
|
106
|
-
<NavbarLinks>
|
|
107
|
-
<NavbarLink asChild>
|
|
108
|
-
<a href="/custom">Custom Link</a>
|
|
109
|
-
</NavbarLink>
|
|
110
|
-
</NavbarLinks>
|
|
111
|
-
</Navbar>,
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
await expect
|
|
115
|
-
.element(page.getByRole("link", { name: "Custom Link" }))
|
|
116
|
-
.toHaveAttribute("href", "/custom");
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe("NavbarBrand", () => {
|
|
121
|
-
test("renders brand content", async () => {
|
|
122
|
-
render(
|
|
123
|
-
<Navbar>
|
|
124
|
-
<NavbarBrand>
|
|
125
|
-
<span>My Brand</span>
|
|
126
|
-
</NavbarBrand>
|
|
127
|
-
</Navbar>,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
await expect.element(page.getByText("My Brand")).toBeInTheDocument();
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test("supports asChild for link brands", async () => {
|
|
134
|
-
render(
|
|
135
|
-
<Navbar>
|
|
136
|
-
<NavbarBrand asChild>
|
|
137
|
-
<a href="/">Home Brand</a>
|
|
138
|
-
</NavbarBrand>
|
|
139
|
-
</Navbar>,
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
await expect
|
|
143
|
-
.element(page.getByRole("link", { name: "Home Brand" }))
|
|
144
|
-
.toHaveAttribute("href", "/");
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe("Composition", () => {
|
|
149
|
-
test("renders complete navbar with all components", async () => {
|
|
150
|
-
// NavbarLinks is hidden at mobile viewport, set to desktop
|
|
151
|
-
await page.viewport(1280, 800);
|
|
152
|
-
|
|
153
|
-
render(
|
|
154
|
-
<Navbar>
|
|
155
|
-
<NavbarBrand>Logo</NavbarBrand>
|
|
156
|
-
<NavbarLinks>
|
|
157
|
-
<NavbarLink href="#">Link 1</NavbarLink>
|
|
158
|
-
<NavbarLink href="#">Link 2</NavbarLink>
|
|
159
|
-
</NavbarLinks>
|
|
160
|
-
<NavbarActions>
|
|
161
|
-
<Button>Action</Button>
|
|
162
|
-
</NavbarActions>
|
|
163
|
-
</Navbar>,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
await expect.element(page.getByRole("navigation")).toBeInTheDocument();
|
|
167
|
-
await expect.element(page.getByText("Logo")).toBeInTheDocument();
|
|
168
|
-
await expect
|
|
169
|
-
.element(page.getByRole("link", { name: "Link 1" }))
|
|
170
|
-
.toBeInTheDocument();
|
|
171
|
-
await expect
|
|
172
|
-
.element(page.getByRole("link", { name: "Link 2" }))
|
|
173
|
-
.toBeInTheDocument();
|
|
174
|
-
await expect
|
|
175
|
-
.element(page.getByRole("button", { name: "Action" }))
|
|
176
|
-
.toBeInTheDocument();
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test("supports custom className on Navbar", async () => {
|
|
180
|
-
render(
|
|
181
|
-
<Navbar className="custom-navbar" data-testid="navbar">
|
|
182
|
-
<NavbarBrand>Logo</NavbarBrand>
|
|
183
|
-
</Navbar>,
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
const navbar = page.getByTestId("navbar");
|
|
187
|
-
await expect.element(navbar).toHaveClass(/custom-navbar/);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { page } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
import { Button } from "../../atoms/button";
|
|
5
|
-
import {
|
|
6
|
-
Navbar,
|
|
7
|
-
NavbarActions,
|
|
8
|
-
NavbarBrand,
|
|
9
|
-
NavbarLink,
|
|
10
|
-
NavbarLinks,
|
|
11
|
-
} from "./navbar";
|
|
12
|
-
|
|
13
|
-
describe("Navbar Visual Regression", () => {
|
|
14
|
-
test("default navbar renders correctly", async () => {
|
|
15
|
-
await page.viewport(1280, 800);
|
|
16
|
-
|
|
17
|
-
render(
|
|
18
|
-
<Navbar data-testid="navbar">
|
|
19
|
-
<NavbarBrand>
|
|
20
|
-
<span className="text-xl font-bold">Logo</span>
|
|
21
|
-
</NavbarBrand>
|
|
22
|
-
<NavbarLinks>
|
|
23
|
-
<NavbarLink href="#">Home</NavbarLink>
|
|
24
|
-
<NavbarLink href="#">About</NavbarLink>
|
|
25
|
-
<NavbarLink href="#">Services</NavbarLink>
|
|
26
|
-
<NavbarLink href="#">Contact</NavbarLink>
|
|
27
|
-
</NavbarLinks>
|
|
28
|
-
<NavbarActions>
|
|
29
|
-
<Button size="sm" variant="primary">
|
|
30
|
-
Sign In
|
|
31
|
-
</Button>
|
|
32
|
-
</NavbarActions>
|
|
33
|
-
</Navbar>,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
await expect(page.getByTestId("navbar")).toMatchScreenshot(
|
|
37
|
-
"navbar-default",
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test("navbar with active link renders correctly", async () => {
|
|
42
|
-
await page.viewport(1280, 800);
|
|
43
|
-
|
|
44
|
-
render(
|
|
45
|
-
<Navbar data-testid="navbar">
|
|
46
|
-
<NavbarBrand>
|
|
47
|
-
<span className="text-xl font-bold">Logo</span>
|
|
48
|
-
</NavbarBrand>
|
|
49
|
-
<NavbarLinks>
|
|
50
|
-
<NavbarLink href="#" active>
|
|
51
|
-
Home
|
|
52
|
-
</NavbarLink>
|
|
53
|
-
<NavbarLink href="#">About</NavbarLink>
|
|
54
|
-
<NavbarLink href="#">Services</NavbarLink>
|
|
55
|
-
<NavbarLink href="#">Contact</NavbarLink>
|
|
56
|
-
</NavbarLinks>
|
|
57
|
-
<NavbarActions>
|
|
58
|
-
<Button size="sm" variant="primary">
|
|
59
|
-
Sign In
|
|
60
|
-
</Button>
|
|
61
|
-
</NavbarActions>
|
|
62
|
-
</Navbar>,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
await expect(page.getByTestId("navbar")).toMatchScreenshot(
|
|
66
|
-
"navbar-active-link",
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("navbar brand only renders correctly", async () => {
|
|
71
|
-
await page.viewport(1280, 800);
|
|
72
|
-
|
|
73
|
-
render(
|
|
74
|
-
<Navbar data-testid="navbar">
|
|
75
|
-
<NavbarBrand>
|
|
76
|
-
<span className="text-xl font-bold">Brand Only</span>
|
|
77
|
-
</NavbarBrand>
|
|
78
|
-
</Navbar>,
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
await expect(page.getByTestId("navbar")).toMatchScreenshot(
|
|
82
|
-
"navbar-brand-only",
|
|
83
|
-
);
|
|
84
|
-
});
|
|
85
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { USGovBanner } from ".";
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof USGovBanner> = {
|
|
5
|
-
title: "Organisms/USGovBanner",
|
|
6
|
-
component: USGovBanner,
|
|
7
|
-
parameters: {
|
|
8
|
-
layout: "fullscreen",
|
|
9
|
-
},
|
|
10
|
-
} as Meta<typeof USGovBanner>;
|
|
11
|
-
|
|
12
|
-
export default meta;
|
|
13
|
-
type Story = StoryObj<typeof USGovBanner>;
|
|
14
|
-
|
|
15
|
-
export const Default: Story = {
|
|
16
|
-
render: () => <USGovBanner />,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const CustomText: Story = {
|
|
20
|
-
render: () => (
|
|
21
|
-
<USGovBanner text="An official website of the U.S. Department of State" />
|
|
22
|
-
),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const Playground: Story = {
|
|
26
|
-
render: (args) => <USGovBanner {...args} />,
|
|
27
|
-
};
|
|
28
|
-
Playground.argTypes = {
|
|
29
|
-
text: {
|
|
30
|
-
control: { type: "text" },
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
Playground.args = {
|
|
34
|
-
text: "An official website of the United States government",
|
|
35
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { page } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
import { USGovBanner } from "./us-gov-banner";
|
|
5
|
-
|
|
6
|
-
describe("USGovBanner", () => {
|
|
7
|
-
describe("Accessibility", () => {
|
|
8
|
-
test("banner text is readable", async () => {
|
|
9
|
-
render(<USGovBanner />);
|
|
10
|
-
|
|
11
|
-
await expect
|
|
12
|
-
.element(
|
|
13
|
-
page.getByText("An official website of the United States government"),
|
|
14
|
-
)
|
|
15
|
-
.toBeInTheDocument();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("flag icon is hidden from screen readers", async () => {
|
|
19
|
-
render(<USGovBanner data-testid="banner" />);
|
|
20
|
-
|
|
21
|
-
// The default flag SVG has aria-hidden="true"
|
|
22
|
-
const banner = page.getByTestId("banner");
|
|
23
|
-
await expect.element(banner).toBeInTheDocument();
|
|
24
|
-
|
|
25
|
-
// Verify the SVG is present but decorative
|
|
26
|
-
const svg = banner.element().querySelector("svg");
|
|
27
|
-
expect(svg?.getAttribute("aria-hidden")).toBe("true");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("custom text is readable", async () => {
|
|
31
|
-
render(<USGovBanner text="Custom government message" />);
|
|
32
|
-
|
|
33
|
-
await expect
|
|
34
|
-
.element(page.getByText("Custom government message"))
|
|
35
|
-
.toBeInTheDocument();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe("Props", () => {
|
|
40
|
-
test("renders default text when no text prop provided", async () => {
|
|
41
|
-
render(<USGovBanner />);
|
|
42
|
-
|
|
43
|
-
await expect
|
|
44
|
-
.element(
|
|
45
|
-
page.getByText("An official website of the United States government"),
|
|
46
|
-
)
|
|
47
|
-
.toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("renders custom text when provided", async () => {
|
|
51
|
-
render(<USGovBanner text="An official California website" />);
|
|
52
|
-
|
|
53
|
-
await expect
|
|
54
|
-
.element(page.getByText("An official California website"))
|
|
55
|
-
.toBeInTheDocument();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("renders custom flag icon when provided", async () => {
|
|
59
|
-
render(
|
|
60
|
-
<USGovBanner flagIcon={<span data-testid="custom-icon">🏛️</span>} />,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
await expect.element(page.getByTestId("custom-icon")).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("supports custom className", async () => {
|
|
67
|
-
render(<USGovBanner className="custom-banner" data-testid="banner" />);
|
|
68
|
-
|
|
69
|
-
const banner = page.getByTestId("banner");
|
|
70
|
-
await expect.element(banner).toHaveClass(/custom-banner/);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test("spreads additional props", async () => {
|
|
74
|
-
render(
|
|
75
|
-
<USGovBanner data-testid="banner" aria-label="Government banner" />,
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
const banner = page.getByTestId("banner");
|
|
79
|
-
await expect
|
|
80
|
-
.element(banner)
|
|
81
|
-
.toHaveAttribute("aria-label", "Government banner");
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
describe("Styling", () => {
|
|
86
|
-
test("has light background by default", async () => {
|
|
87
|
-
render(<USGovBanner data-testid="banner" />);
|
|
88
|
-
|
|
89
|
-
const banner = page.getByTestId("banner");
|
|
90
|
-
await expect.element(banner).toHaveClass(/bg-gray-50/);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test("is centered", async () => {
|
|
94
|
-
render(<USGovBanner data-testid="banner" />);
|
|
95
|
-
|
|
96
|
-
const banner = page.getByTestId("banner");
|
|
97
|
-
await expect.element(banner).toHaveClass(/justify-center/);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("spans full width", async () => {
|
|
101
|
-
render(<USGovBanner data-testid="banner" />);
|
|
102
|
-
|
|
103
|
-
const banner = page.getByTestId("banner");
|
|
104
|
-
await expect.element(banner).toHaveClass(/w-full/);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "vitest";
|
|
2
|
-
import { page } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
import { USGovBanner } from "./us-gov-banner";
|
|
5
|
-
|
|
6
|
-
describe("USGovBanner Visual Regression", () => {
|
|
7
|
-
test("default banner renders correctly", async () => {
|
|
8
|
-
await page.viewport(1280, 800);
|
|
9
|
-
|
|
10
|
-
render(<USGovBanner data-testid="banner" />);
|
|
11
|
-
|
|
12
|
-
await expect(page.getByTestId("banner")).toMatchScreenshot(
|
|
13
|
-
"us-gov-banner-default",
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test("banner with custom text renders correctly", async () => {
|
|
18
|
-
await page.viewport(1280, 800);
|
|
19
|
-
|
|
20
|
-
render(
|
|
21
|
-
<USGovBanner
|
|
22
|
-
data-testid="banner"
|
|
23
|
-
text="An official website of the State of California"
|
|
24
|
-
/>,
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
await expect(page.getByTestId("banner")).toMatchScreenshot(
|
|
28
|
-
"us-gov-banner-custom-text",
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("banner with custom flag icon renders correctly", async () => {
|
|
33
|
-
await page.viewport(1280, 800);
|
|
34
|
-
|
|
35
|
-
render(
|
|
36
|
-
<USGovBanner
|
|
37
|
-
data-testid="banner"
|
|
38
|
-
flagIcon={<span aria-hidden="true">🏛️</span>}
|
|
39
|
-
/>,
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
await expect(page.getByTestId("banner")).toMatchScreenshot(
|
|
43
|
-
"us-gov-banner-custom-icon",
|
|
44
|
-
);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { Button } from "../../atoms/button";
|
|
3
|
-
import { Banner } from ".";
|
|
4
|
-
|
|
5
|
-
const meta: Meta<typeof Banner> = {
|
|
6
|
-
title: "Sections/Banner",
|
|
7
|
-
component: Banner,
|
|
8
|
-
parameters: {
|
|
9
|
-
layout: "fullscreen",
|
|
10
|
-
},
|
|
11
|
-
argTypes: {
|
|
12
|
-
heading: {
|
|
13
|
-
control: "text",
|
|
14
|
-
description: "The heading text displayed in the banner",
|
|
15
|
-
},
|
|
16
|
-
description: {
|
|
17
|
-
control: "text",
|
|
18
|
-
description: "The description text displayed below the heading",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
} as Meta<typeof Banner>;
|
|
22
|
-
|
|
23
|
-
export default meta;
|
|
24
|
-
type Story = StoryObj<typeof Banner>;
|
|
25
|
-
|
|
26
|
-
export const Playground: Story = {
|
|
27
|
-
render: (args) => <Banner {...args} />,
|
|
28
|
-
};
|
|
29
|
-
Playground.args = {
|
|
30
|
-
heading: "Important Update",
|
|
31
|
-
description:
|
|
32
|
-
"Use banners to surface short, important updates or a single key action without disrupting the main page content.",
|
|
33
|
-
action: <Button>Learn More</Button>,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// =============================================================================
|
|
37
|
-
// Default
|
|
38
|
-
// =============================================================================
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Default banner with heading, description, and action button.
|
|
42
|
-
* Responsive across all breakpoints.
|
|
43
|
-
*/
|
|
44
|
-
export const Default: Story = {
|
|
45
|
-
render: () => (
|
|
46
|
-
<Banner
|
|
47
|
-
heading="Important Update"
|
|
48
|
-
description="Use banners to surface short, important updates or a single key action without disrupting the main page content."
|
|
49
|
-
action={<Button>Learn More</Button>}
|
|
50
|
-
/>
|
|
51
|
-
),
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Banner without an action button.
|
|
56
|
-
*/
|
|
57
|
-
export const WithoutAction: Story = {
|
|
58
|
-
render: () => (
|
|
59
|
-
<Banner
|
|
60
|
-
heading="Announcement"
|
|
61
|
-
description="Use banners to surface short, important updates or a single key action without disrupting the main page content."
|
|
62
|
-
/>
|
|
63
|
-
),
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// =============================================================================
|
|
67
|
-
// Responsive Variants
|
|
68
|
-
// =============================================================================
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Desktop viewport (lg breakpoint, 1440px)
|
|
72
|
-
* Horizontal layout with 72px padding
|
|
73
|
-
*/
|
|
74
|
-
export const Desktop: Story = {
|
|
75
|
-
render: () => (
|
|
76
|
-
<Banner
|
|
77
|
-
heading="Desktop Banner"
|
|
78
|
-
description="Use banners to surface short, important updates or a single key action without disrupting the main page content."
|
|
79
|
-
action={<Button>Learn More</Button>}
|
|
80
|
-
/>
|
|
81
|
-
),
|
|
82
|
-
globals: {
|
|
83
|
-
viewport: { value: "lg", isRotated: false },
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Tablet viewport (md breakpoint, 768px)
|
|
89
|
-
* Horizontal layout with 56px padding
|
|
90
|
-
*/
|
|
91
|
-
export const Tablet: Story = {
|
|
92
|
-
render: () => (
|
|
93
|
-
<Banner
|
|
94
|
-
heading="Tablet Banner"
|
|
95
|
-
description="Use banners to surface short, important updates or a single key action without disrupting the main page content."
|
|
96
|
-
action={<Button>Learn More</Button>}
|
|
97
|
-
/>
|
|
98
|
-
),
|
|
99
|
-
globals: {
|
|
100
|
-
viewport: { value: "md", isRotated: false },
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Mobile viewport (sm breakpoint, 320px)
|
|
106
|
-
* Stacked layout with 20x32px padding
|
|
107
|
-
*/
|
|
108
|
-
export const Mobile: Story = {
|
|
109
|
-
render: () => (
|
|
110
|
-
<Banner
|
|
111
|
-
heading="Mobile Banner"
|
|
112
|
-
description="Use banners to surface short, important updates or a single key action without disruption."
|
|
113
|
-
action={<Button size="sm">Learn More</Button>}
|
|
114
|
-
/>
|
|
115
|
-
),
|
|
116
|
-
globals: {
|
|
117
|
-
viewport: { value: "sm", isRotated: false },
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// =============================================================================
|
|
122
|
-
// Examples
|
|
123
|
-
// =============================================================================
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Banner with a longer description that wraps
|
|
127
|
-
*/
|
|
128
|
-
export const LongDescription: Story = {
|
|
129
|
-
render: () => (
|
|
130
|
-
<Banner
|
|
131
|
-
heading="New Features Available"
|
|
132
|
-
description="We've made significant improvements to our platform including enhanced security features, faster load times, improved accessibility across all components, and a redesigned dashboard experience. Check out the documentation for more details on how to take advantage of these updates."
|
|
133
|
-
action={<Button>View Documentation</Button>}
|
|
134
|
-
/>
|
|
135
|
-
),
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Banner with custom styling
|
|
140
|
-
*/
|
|
141
|
-
export const CustomBackground: Story = {
|
|
142
|
-
render: () => (
|
|
143
|
-
<Banner
|
|
144
|
-
heading="Custom Styled Banner"
|
|
145
|
-
description="This banner has a custom background color applied via className."
|
|
146
|
-
action={<Button variant="secondary-outline">Action</Button>}
|
|
147
|
-
className="bg-gray-1000 text-gray-50 [&_h2]:text-gray-50 [&_p]:text-gray-200"
|
|
148
|
-
/>
|
|
149
|
-
),
|
|
150
|
-
};
|