@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,260 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
-
import { IconButton } from ".";
|
|
3
|
-
|
|
4
|
-
const SearchIcon = () => (
|
|
5
|
-
<svg
|
|
6
|
-
width="16"
|
|
7
|
-
height="16"
|
|
8
|
-
viewBox="0 0 16 16"
|
|
9
|
-
fill="none"
|
|
10
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
-
aria-hidden="true"
|
|
12
|
-
>
|
|
13
|
-
<path
|
|
14
|
-
d="M7.33333 12.6667C10.2789 12.6667 12.6667 10.2789 12.6667 7.33333C12.6667 4.38781 10.2789 2 7.33333 2C4.38781 2 2 4.38781 2 7.33333C2 10.2789 4.38781 12.6667 7.33333 12.6667Z"
|
|
15
|
-
stroke="currentColor"
|
|
16
|
-
strokeWidth="1.5"
|
|
17
|
-
strokeLinecap="round"
|
|
18
|
-
strokeLinejoin="round"
|
|
19
|
-
/>
|
|
20
|
-
<path
|
|
21
|
-
d="M14 14L11.1 11.1"
|
|
22
|
-
stroke="currentColor"
|
|
23
|
-
strokeWidth="1.5"
|
|
24
|
-
strokeLinecap="round"
|
|
25
|
-
strokeLinejoin="round"
|
|
26
|
-
/>
|
|
27
|
-
</svg>
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
const ArrowRightIcon = () => (
|
|
31
|
-
<svg
|
|
32
|
-
width="12"
|
|
33
|
-
height="12"
|
|
34
|
-
viewBox="0 0 12 12"
|
|
35
|
-
fill="none"
|
|
36
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
37
|
-
aria-hidden="true"
|
|
38
|
-
>
|
|
39
|
-
<path
|
|
40
|
-
d="M2.5 6H9.5M9.5 6L6 2.5M9.5 6L6 9.5"
|
|
41
|
-
stroke="currentColor"
|
|
42
|
-
strokeWidth="1.5"
|
|
43
|
-
strokeLinecap="round"
|
|
44
|
-
strokeLinejoin="round"
|
|
45
|
-
/>
|
|
46
|
-
</svg>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
const meta: Meta<typeof IconButton> = {
|
|
50
|
-
title: "Atoms/IconButton",
|
|
51
|
-
} as Meta<typeof IconButton>;
|
|
52
|
-
|
|
53
|
-
export default meta;
|
|
54
|
-
type Story = StoryObj<typeof IconButton>;
|
|
55
|
-
|
|
56
|
-
export const Playground: Story = {
|
|
57
|
-
render: (args) => (
|
|
58
|
-
<IconButton {...args}>
|
|
59
|
-
<SearchIcon />
|
|
60
|
-
</IconButton>
|
|
61
|
-
),
|
|
62
|
-
};
|
|
63
|
-
Playground.argTypes = {
|
|
64
|
-
size: {
|
|
65
|
-
control: {
|
|
66
|
-
type: "radio",
|
|
67
|
-
},
|
|
68
|
-
options: ["sm", "md", "lg"],
|
|
69
|
-
},
|
|
70
|
-
disabled: {
|
|
71
|
-
control: {
|
|
72
|
-
type: "boolean",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
variant: {
|
|
76
|
-
control: {
|
|
77
|
-
type: "radio",
|
|
78
|
-
},
|
|
79
|
-
options: [
|
|
80
|
-
"primary",
|
|
81
|
-
"primary-outline",
|
|
82
|
-
"secondary",
|
|
83
|
-
"secondary-outline",
|
|
84
|
-
"ghost",
|
|
85
|
-
"ghost-inverse",
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
rounded: {
|
|
89
|
-
control: {
|
|
90
|
-
type: "radio",
|
|
91
|
-
},
|
|
92
|
-
options: ["default", "full"],
|
|
93
|
-
},
|
|
94
|
-
};
|
|
95
|
-
Playground.args = {
|
|
96
|
-
size: "md",
|
|
97
|
-
disabled: false,
|
|
98
|
-
variant: "primary",
|
|
99
|
-
rounded: "default",
|
|
100
|
-
"aria-label": "Search",
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const Primary = () => (
|
|
104
|
-
<IconButton variant="primary" aria-label="Search">
|
|
105
|
-
<SearchIcon />
|
|
106
|
-
</IconButton>
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
export const PrimaryOutline = () => (
|
|
110
|
-
<IconButton variant="primary-outline" aria-label="Search">
|
|
111
|
-
<SearchIcon />
|
|
112
|
-
</IconButton>
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
export const Ghost = () => (
|
|
116
|
-
<IconButton variant="ghost" aria-label="Search">
|
|
117
|
-
<SearchIcon />
|
|
118
|
-
</IconButton>
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
const DarkBackground = ({ children }: { children: React.ReactNode }) => (
|
|
122
|
-
<div className="rounded-radius-12 bg-gray-1200 p-32">{children}</div>
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
export const Secondary = () => (
|
|
126
|
-
<DarkBackground>
|
|
127
|
-
<IconButton variant="secondary" aria-label="Navigate">
|
|
128
|
-
<ArrowRightIcon />
|
|
129
|
-
</IconButton>
|
|
130
|
-
</DarkBackground>
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
export const SecondaryOutline = () => (
|
|
134
|
-
<DarkBackground>
|
|
135
|
-
<IconButton variant="secondary-outline" aria-label="Navigate">
|
|
136
|
-
<ArrowRightIcon />
|
|
137
|
-
</IconButton>
|
|
138
|
-
</DarkBackground>
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
export const GhostInverse = () => (
|
|
142
|
-
<DarkBackground>
|
|
143
|
-
<IconButton variant="ghost-inverse" aria-label="Navigate">
|
|
144
|
-
<ArrowRightIcon />
|
|
145
|
-
</IconButton>
|
|
146
|
-
</DarkBackground>
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
export const AllVariants = () => (
|
|
150
|
-
<div className="flex flex-col gap-32">
|
|
151
|
-
<div>
|
|
152
|
-
<h3 className="mb-16 text-14 font-medium text-text-secondary">
|
|
153
|
-
For Light Backgrounds
|
|
154
|
-
</h3>
|
|
155
|
-
<div className="flex gap-16">
|
|
156
|
-
<IconButton variant="primary" aria-label="Primary">
|
|
157
|
-
<SearchIcon />
|
|
158
|
-
</IconButton>
|
|
159
|
-
<IconButton variant="primary-outline" aria-label="Primary Outline">
|
|
160
|
-
<SearchIcon />
|
|
161
|
-
</IconButton>
|
|
162
|
-
<IconButton variant="ghost" aria-label="Ghost">
|
|
163
|
-
<SearchIcon />
|
|
164
|
-
</IconButton>
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
<DarkBackground>
|
|
168
|
-
<h3 className="mb-16 text-14 font-medium text-gray-400">
|
|
169
|
-
For Dark Backgrounds
|
|
170
|
-
</h3>
|
|
171
|
-
<div className="flex gap-16">
|
|
172
|
-
<IconButton variant="secondary" aria-label="Secondary">
|
|
173
|
-
<ArrowRightIcon />
|
|
174
|
-
</IconButton>
|
|
175
|
-
<IconButton variant="secondary-outline" aria-label="Secondary Outline">
|
|
176
|
-
<ArrowRightIcon />
|
|
177
|
-
</IconButton>
|
|
178
|
-
<IconButton variant="ghost-inverse" aria-label="Ghost Inverse">
|
|
179
|
-
<ArrowRightIcon />
|
|
180
|
-
</IconButton>
|
|
181
|
-
</div>
|
|
182
|
-
</DarkBackground>
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
export const RoundedDefault = () => (
|
|
187
|
-
<IconButton rounded="default" aria-label="Search">
|
|
188
|
-
<SearchIcon />
|
|
189
|
-
</IconButton>
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
export const RoundedFull = () => (
|
|
193
|
-
<IconButton rounded="full" aria-label="Search">
|
|
194
|
-
<SearchIcon />
|
|
195
|
-
</IconButton>
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
export const AllRounded = () => (
|
|
199
|
-
<div className="flex gap-16">
|
|
200
|
-
<div className="text-center">
|
|
201
|
-
<IconButton rounded="default" aria-label="Default rounded">
|
|
202
|
-
<SearchIcon />
|
|
203
|
-
</IconButton>
|
|
204
|
-
<p className="mt-8 text-12 text-text-muted">default</p>
|
|
205
|
-
</div>
|
|
206
|
-
<div className="text-center">
|
|
207
|
-
<IconButton rounded="full" aria-label="Full rounded">
|
|
208
|
-
<SearchIcon />
|
|
209
|
-
</IconButton>
|
|
210
|
-
<p className="mt-8 text-12 text-text-muted">full</p>
|
|
211
|
-
</div>
|
|
212
|
-
</div>
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
export const Small = () => (
|
|
216
|
-
<IconButton size="sm" aria-label="Search">
|
|
217
|
-
<ArrowRightIcon />
|
|
218
|
-
</IconButton>
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
export const Medium = () => (
|
|
222
|
-
<IconButton size="md" aria-label="Search">
|
|
223
|
-
<SearchIcon />
|
|
224
|
-
</IconButton>
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
export const Large = () => (
|
|
228
|
-
<IconButton size="lg" aria-label="Search">
|
|
229
|
-
<SearchIcon />
|
|
230
|
-
</IconButton>
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
export const AllSizes = () => (
|
|
234
|
-
<div className="flex items-center gap-16">
|
|
235
|
-
<div className="text-center">
|
|
236
|
-
<IconButton size="sm" aria-label="Small">
|
|
237
|
-
<ArrowRightIcon />
|
|
238
|
-
</IconButton>
|
|
239
|
-
<p className="mt-8 text-12 text-text-muted">sm (28px)</p>
|
|
240
|
-
</div>
|
|
241
|
-
<div className="text-center">
|
|
242
|
-
<IconButton size="md" aria-label="Default">
|
|
243
|
-
<SearchIcon />
|
|
244
|
-
</IconButton>
|
|
245
|
-
<p className="mt-8 text-12 text-text-muted">md (40px)</p>
|
|
246
|
-
</div>
|
|
247
|
-
<div className="text-center">
|
|
248
|
-
<IconButton size="lg" aria-label="Large">
|
|
249
|
-
<SearchIcon />
|
|
250
|
-
</IconButton>
|
|
251
|
-
<p className="mt-8 text-12 text-text-muted">lg (56px)</p>
|
|
252
|
-
</div>
|
|
253
|
-
</div>
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
export const Disabled = () => (
|
|
257
|
-
<IconButton disabled aria-label="Search">
|
|
258
|
-
<SearchIcon />
|
|
259
|
-
</IconButton>
|
|
260
|
-
);
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test, vi } from "vitest";
|
|
2
|
-
import { page, userEvent } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
import { IconButton } from "./icon-button";
|
|
5
|
-
|
|
6
|
-
const TestIcon = () => (
|
|
7
|
-
// biome-ignore lint/a11y/noSvgWithoutTitle: Test component doesn't need accessibility title
|
|
8
|
-
<svg data-testid="test-icon" width="24" height="24" viewBox="0 0 24 24">
|
|
9
|
-
<path d="M12 2L2 7l10 5 10-5-10-5z" />
|
|
10
|
-
</svg>
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
describe("IconButton", () => {
|
|
14
|
-
describe("Accessibility", () => {
|
|
15
|
-
test("has correct button role", async () => {
|
|
16
|
-
render(
|
|
17
|
-
<IconButton aria-label="Test action">
|
|
18
|
-
<TestIcon />
|
|
19
|
-
</IconButton>,
|
|
20
|
-
);
|
|
21
|
-
await expect
|
|
22
|
-
.element(page.getByRole("button", { name: "Test action" }))
|
|
23
|
-
.toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test("is focusable via keyboard", async () => {
|
|
27
|
-
render(
|
|
28
|
-
<IconButton aria-label="Focusable">
|
|
29
|
-
<TestIcon />
|
|
30
|
-
</IconButton>,
|
|
31
|
-
);
|
|
32
|
-
await userEvent.keyboard("{Tab}");
|
|
33
|
-
await expect
|
|
34
|
-
.element(page.getByRole("button", { name: "Focusable" }))
|
|
35
|
-
.toHaveFocus();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("disabled button has disabled attribute", async () => {
|
|
39
|
-
render(
|
|
40
|
-
<IconButton disabled aria-label="Disabled">
|
|
41
|
-
<TestIcon />
|
|
42
|
-
</IconButton>,
|
|
43
|
-
);
|
|
44
|
-
await expect
|
|
45
|
-
.element(page.getByRole("button", { name: "Disabled" }))
|
|
46
|
-
.toBeDisabled();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("disabled button is not focusable", async () => {
|
|
50
|
-
render(
|
|
51
|
-
<>
|
|
52
|
-
<IconButton disabled aria-label="Disabled">
|
|
53
|
-
<TestIcon />
|
|
54
|
-
</IconButton>
|
|
55
|
-
<IconButton aria-label="After">
|
|
56
|
-
<TestIcon />
|
|
57
|
-
</IconButton>
|
|
58
|
-
</>,
|
|
59
|
-
);
|
|
60
|
-
await userEvent.keyboard("{Tab}");
|
|
61
|
-
await expect
|
|
62
|
-
.element(page.getByRole("button", { name: "After" }))
|
|
63
|
-
.toHaveFocus();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test("renders icon inside button", async () => {
|
|
67
|
-
render(
|
|
68
|
-
<IconButton aria-label="With icon">
|
|
69
|
-
<TestIcon />
|
|
70
|
-
</IconButton>,
|
|
71
|
-
);
|
|
72
|
-
const icon = page.getByTestId("test-icon");
|
|
73
|
-
await expect.element(icon).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe("Interactions", () => {
|
|
78
|
-
test("calls onClick when clicked", async () => {
|
|
79
|
-
const handleClick = vi.fn();
|
|
80
|
-
render(
|
|
81
|
-
<IconButton onClick={handleClick} aria-label="Clickable">
|
|
82
|
-
<TestIcon />
|
|
83
|
-
</IconButton>,
|
|
84
|
-
);
|
|
85
|
-
await page.getByRole("button", { name: "Clickable" }).click();
|
|
86
|
-
expect(handleClick).toHaveBeenCalledOnce();
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test("responds to Enter key when focused", async () => {
|
|
90
|
-
const handleClick = vi.fn();
|
|
91
|
-
render(
|
|
92
|
-
<IconButton onClick={handleClick} aria-label="Enter key">
|
|
93
|
-
<TestIcon />
|
|
94
|
-
</IconButton>,
|
|
95
|
-
);
|
|
96
|
-
page.getByRole("button", { name: "Enter key" }).element().focus();
|
|
97
|
-
await userEvent.keyboard("{Enter}");
|
|
98
|
-
expect(handleClick).toHaveBeenCalledOnce();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test("responds to Space key when focused", async () => {
|
|
102
|
-
const handleClick = vi.fn();
|
|
103
|
-
render(
|
|
104
|
-
<IconButton onClick={handleClick} aria-label="Space key">
|
|
105
|
-
<TestIcon />
|
|
106
|
-
</IconButton>,
|
|
107
|
-
);
|
|
108
|
-
page.getByRole("button", { name: "Space key" }).element().focus();
|
|
109
|
-
await userEvent.keyboard(" ");
|
|
110
|
-
expect(handleClick).toHaveBeenCalledOnce();
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test("does not fire onClick when disabled", async () => {
|
|
114
|
-
const handleClick = vi.fn();
|
|
115
|
-
render(
|
|
116
|
-
<IconButton disabled onClick={handleClick} aria-label="Disabled">
|
|
117
|
-
<TestIcon />
|
|
118
|
-
</IconButton>,
|
|
119
|
-
);
|
|
120
|
-
await page
|
|
121
|
-
.getByRole("button", { name: "Disabled" })
|
|
122
|
-
.click({ force: true });
|
|
123
|
-
expect(handleClick).not.toHaveBeenCalled();
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe("render prop", () => {
|
|
128
|
-
test("renders as anchor element when render prop is used", async () => {
|
|
129
|
-
render(
|
|
130
|
-
// biome-ignore lint/a11y/useAnchorContent: Content is provided via IconButton children
|
|
131
|
-
<IconButton render={<a href="/test" />} aria-label="Link button">
|
|
132
|
-
<TestIcon />
|
|
133
|
-
</IconButton>,
|
|
134
|
-
);
|
|
135
|
-
const element = page.getByRole("link", { name: "Link button" });
|
|
136
|
-
await expect.element(element).toBeInTheDocument();
|
|
137
|
-
await expect.element(element).toHaveAttribute("href", "/test");
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
describe("Variants", () => {
|
|
142
|
-
test("primary variant has visible background color", async () => {
|
|
143
|
-
render(
|
|
144
|
-
<IconButton aria-label="Default">
|
|
145
|
-
<TestIcon />
|
|
146
|
-
</IconButton>,
|
|
147
|
-
);
|
|
148
|
-
const button = page.getByRole("button", { name: "Default" });
|
|
149
|
-
await expect.element(button).toBeInTheDocument();
|
|
150
|
-
|
|
151
|
-
const element = button.element();
|
|
152
|
-
const bgColor = window.getComputedStyle(element).backgroundColor;
|
|
153
|
-
expect(bgColor).not.toBe("rgba(0, 0, 0, 0)");
|
|
154
|
-
expect(bgColor).not.toBe("transparent");
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe("Sizes", () => {
|
|
159
|
-
test("different sizes have different dimensions", async () => {
|
|
160
|
-
render(
|
|
161
|
-
<>
|
|
162
|
-
<IconButton size="sm" aria-label="Small">
|
|
163
|
-
<TestIcon />
|
|
164
|
-
</IconButton>
|
|
165
|
-
<IconButton size="lg" aria-label="Large">
|
|
166
|
-
<TestIcon />
|
|
167
|
-
</IconButton>
|
|
168
|
-
</>,
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
const smallBtn = page.getByRole("button", { name: "Small" });
|
|
172
|
-
const largeBtn = page.getByRole("button", { name: "Large" });
|
|
173
|
-
await expect.element(smallBtn).toBeInTheDocument();
|
|
174
|
-
await expect.element(largeBtn).toBeInTheDocument();
|
|
175
|
-
|
|
176
|
-
const smallWidth = Number.parseFloat(
|
|
177
|
-
window.getComputedStyle(smallBtn.element()).width,
|
|
178
|
-
);
|
|
179
|
-
const largeWidth = Number.parseFloat(
|
|
180
|
-
window.getComputedStyle(largeBtn.element()).width,
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
expect(largeWidth).toBeGreaterThan(smallWidth);
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { Input, type InputProps, inputVariants } from "./input";
|
|
2
|
-
export {
|
|
3
|
-
InputGroup,
|
|
4
|
-
InputGroupAddon,
|
|
5
|
-
type InputGroupAddonProps,
|
|
6
|
-
InputGroupButton,
|
|
7
|
-
type InputGroupButtonProps,
|
|
8
|
-
InputGroupInput,
|
|
9
|
-
type InputGroupInputProps,
|
|
10
|
-
type InputGroupProps,
|
|
11
|
-
InputGroupText,
|
|
12
|
-
InputGroupTextarea,
|
|
13
|
-
type InputGroupTextareaProps,
|
|
14
|
-
type InputGroupTextProps,
|
|
15
|
-
inputGroupAddonVariants,
|
|
16
|
-
inputGroupVariants,
|
|
17
|
-
} from "./input-group";
|