@fpkit/acss 0.4.19 → 0.5.0
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 +2 -2
- package/src/components/badge/badge.stories.tsx +3 -3
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +24 -8
- package/src/components/breadcrumbs/breadcrumb.tsx +47 -40
- package/src/components/buttons/button.stories.tsx +2 -2
- package/src/components/buttons/button.test.tsx +1 -1
- package/src/components/cards/card.stories.tsx +2 -2
- package/src/components/details/details.scss +10 -2
- package/src/components/details/details.stories.tsx +20 -4
- package/src/components/details/details.tsx +2 -1
- package/src/components/form/form.stories.tsx +2 -2
- package/src/components/form/input.stories.tsx +2 -2
- package/src/components/form/select.stories.tsx +2 -2
- package/src/components/form/select.tsx +23 -33
- package/src/components/fp.test.tsx +1 -1
- package/src/components/heading/heading.stories.tsx +2 -2
- package/src/components/images/figure.stories.tsx +3 -6
- package/src/components/images/img.stories.tsx +3 -3
- package/src/components/layout/footer.stories.tsx +2 -2
- package/src/components/layout/landmarks.stories.tsx +2 -2
- package/src/components/layout/main.stories.tsx +2 -2
- package/src/components/link/link.stories.tsx +2 -2
- package/src/components/list/list.stories.tsx +1 -2
- package/src/components/nav/nav.stories.tsx +4 -3
- package/src/components/popover/popover.stories.tsx +2 -2
- package/src/components/progress/progress.stories.tsx +2 -2
- package/src/components/tag/tag.stories.tsx +3 -3
- package/src/components/text/text.stories.tsx +6 -6
- package/src/patterns/page/page-header.stories.tsx +2 -2
- package/src/sass/_globals.scss +1 -0
- package/src/styles/cards/card.css +5 -0
- package/src/styles/cards/card.css.map +5 -1
- package/src/styles/details/details.css +9 -2
- package/src/styles/details/details.css.map +1 -1
- package/src/styles/form/form.css +3 -0
- package/src/styles/index.css +10 -2
- package/src/styles/index.css.map +1 -1
- package/LICENSE +0 -21
- package/libs/chunk-GCGKYLDG.js +0 -7
- package/libs/chunk-GCGKYLDG.js.map +0 -1
- package/libs/chunk-PDD4N5P5.cjs +0 -10
- package/libs/chunk-PDD4N5P5.cjs.map +0 -1
- package/libs/chunk-QHIABQNQ.js +0 -8
- package/libs/chunk-QHIABQNQ.js.map +0 -1
- package/libs/chunk-ZOHIKF6I.cjs +0 -31
- package/libs/chunk-ZOHIKF6I.cjs.map +0 -1
- package/libs/components/badge/badge.css +0 -1
- package/libs/components/badge/badge.css.map +0 -1
- package/libs/components/badge/badge.min.css +0 -3
- package/libs/components/breadcrumbs/breadcrumb.css +0 -1
- package/libs/components/breadcrumbs/breadcrumb.css.map +0 -1
- package/libs/components/breadcrumbs/breadcrumb.min.css +0 -3
- package/libs/components/buttons/button.css +0 -1
- package/libs/components/buttons/button.css.map +0 -1
- package/libs/components/buttons/button.min.css +0 -3
- package/libs/components/cards/card-style.css +0 -1
- package/libs/components/cards/card-style.css.map +0 -1
- package/libs/components/cards/card-style.min.css +0 -3
- package/libs/components/cards/card.css +0 -1
- package/libs/components/cards/card.css.map +0 -1
- package/libs/components/cards/card.min.css +0 -3
- package/libs/components/details/details.css +0 -1
- package/libs/components/details/details.css.map +0 -1
- package/libs/components/details/details.min.css +0 -3
- package/libs/components/form/form.css +0 -1
- package/libs/components/form/form.css.map +0 -1
- package/libs/components/form/form.min.css +0 -3
- package/libs/components/icons/icon.css +0 -1
- package/libs/components/icons/icon.css.map +0 -1
- package/libs/components/icons/icon.min.css +0 -3
- package/libs/components/images/img.css +0 -1
- package/libs/components/images/img.css.map +0 -1
- package/libs/components/images/img.min.css +0 -3
- package/libs/components/layout/landmarks.css +0 -1
- package/libs/components/layout/landmarks.css.map +0 -1
- package/libs/components/layout/landmarks.min.css +0 -3
- package/libs/components/link/link.css +0 -1
- package/libs/components/link/link.css.map +0 -1
- package/libs/components/link/link.min.css +0 -3
- package/libs/components/nav/nav.css +0 -1
- package/libs/components/nav/nav.css.map +0 -1
- package/libs/components/nav/nav.min.css +0 -3
- package/libs/components/progress/progress.css +0 -1
- package/libs/components/progress/progress.css.map +0 -1
- package/libs/components/progress/progress.min.css +0 -3
- package/libs/components/styles/index.css +0 -1
- package/libs/components/styles/index.css.map +0 -1
- package/libs/components/styles/index.min.css +0 -3
- package/libs/components/tag/tag.css +0 -1
- package/libs/components/tag/tag.css.map +0 -1
- package/libs/components/tag/tag.min.css +0 -3
- package/libs/components/text-to-speech/text-to-speech.css +0 -1
- package/libs/components/text-to-speech/text-to-speech.css.map +0 -1
- package/libs/components/text-to-speech/text-to-speech.min.css +0 -3
- package/libs/hooks.cjs +0 -12
- package/libs/hooks.cjs.map +0 -1
- package/libs/hooks.d.cts +0 -32
- package/libs/hooks.d.ts +0 -32
- package/libs/hooks.js +0 -3
- package/libs/hooks.js.map +0 -1
- package/libs/icons-1f5afc0c.d.ts +0 -318
- package/libs/icons.cjs +0 -12
- package/libs/icons.cjs.map +0 -1
- package/libs/icons.d.cts +0 -2
- package/libs/icons.d.ts +0 -2
- package/libs/icons.js +0 -3
- package/libs/icons.js.map +0 -1
- package/libs/index.cjs +0 -71
- package/libs/index.cjs.map +0 -1
- package/libs/index.css +0 -1
- package/libs/index.css.map +0 -1
- package/libs/index.d.cts +0 -558
- package/libs/index.d.ts +0 -558
- package/libs/index.js +0 -11
- package/libs/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@fpkit/acss",
|
|
3
3
|
"description": "A lightweight React UI library for building modern and accessible components that leverage CSS custom properties for reactive Styles.",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.5.0",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "run-p package:watch sass:watch",
|
|
8
8
|
"dev": "vite --open",
|
|
@@ -121,5 +121,5 @@
|
|
|
121
121
|
"publishConfig": {
|
|
122
122
|
"access": "public"
|
|
123
123
|
},
|
|
124
|
-
"gitHead": "
|
|
124
|
+
"gitHead": "7b4a44c832dfc94a47110337789fe47e763c7257"
|
|
125
125
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Badge from './badge'
|
|
6
|
-
import './badge.scss'
|
|
6
|
+
// import './badge.scss'
|
|
7
7
|
|
|
8
8
|
const meta: Meta<typeof Badge> = {
|
|
9
9
|
title: 'FP.REACT Components/Badge',
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within, userEvent,
|
|
3
|
-
|
|
2
|
+
import { within, userEvent, fn, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Breadcrumb from './breadcrumb'
|
|
6
6
|
|
|
7
|
+
const linkClicked = fn()
|
|
8
|
+
|
|
7
9
|
const meta: Meta<typeof Breadcrumb> = {
|
|
8
10
|
title: 'FP.REACT Components/Breadcrumb',
|
|
9
11
|
component: Breadcrumb,
|
|
@@ -16,7 +18,6 @@ const meta: Meta<typeof Breadcrumb> = {
|
|
|
16
18
|
},
|
|
17
19
|
},
|
|
18
20
|
args: {
|
|
19
|
-
// @ts-ignore
|
|
20
21
|
children: 'Link',
|
|
21
22
|
},
|
|
22
23
|
} as Story
|
|
@@ -75,13 +76,9 @@ export const EncodedBreadcrumbs: Story = {
|
|
|
75
76
|
},
|
|
76
77
|
],
|
|
77
78
|
currentRoute: '/products/learning%20in%20public',
|
|
79
|
+
|
|
78
80
|
},
|
|
79
81
|
|
|
80
|
-
play: async ({ canvasElement }) => {
|
|
81
|
-
const canvas = within(canvasElement)
|
|
82
|
-
await userEvent.click(screen.getByText('Shirts'))
|
|
83
|
-
expect(screen.getByText('Shirts')).toBeInTheDocument()
|
|
84
|
-
},
|
|
85
82
|
} as Story
|
|
86
83
|
|
|
87
84
|
export const TruncateName: Story = {
|
|
@@ -90,3 +87,22 @@ export const TruncateName: Story = {
|
|
|
90
87
|
currentRoute: '/products/AveryLongNameTruncate',
|
|
91
88
|
},
|
|
92
89
|
} as Story
|
|
90
|
+
|
|
91
|
+
export const ClickHomeLink: Story = {
|
|
92
|
+
args: {
|
|
93
|
+
...CustomURL.args,
|
|
94
|
+
currentRoute: '/products/shirts',
|
|
95
|
+
startRouteUrl: "#",
|
|
96
|
+
linkProps: {
|
|
97
|
+
onClick: linkClicked,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
play: async ({ canvasElement }) => {
|
|
102
|
+
const canvas = within(canvasElement)
|
|
103
|
+
const homeLink = canvas.getByRole('link', { name: 'Home' })
|
|
104
|
+
expect(homeLink).toHaveAttribute('href', '#')
|
|
105
|
+
// await userEvent.click(homeLink)
|
|
106
|
+
// expect(linkClicked).toHaveBeenCalled()
|
|
107
|
+
},
|
|
108
|
+
} as Story
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import UI from '#components/ui'
|
|
4
4
|
import { Truncate } from '#libs/content'
|
|
5
|
+
import Link from '#components/link/link'
|
|
5
6
|
|
|
6
7
|
// TYPES
|
|
7
8
|
|
|
@@ -19,6 +20,8 @@ type BreadcrumbProps = {
|
|
|
19
20
|
routes?: customRoute[]
|
|
20
21
|
/** Starting route node */
|
|
21
22
|
startRoute?: React.ReactNode
|
|
23
|
+
/* Starting route url */
|
|
24
|
+
startRouteUrl?: string
|
|
22
25
|
/** Spacer node between routes */
|
|
23
26
|
spacer?: React.ReactNode
|
|
24
27
|
/** String representing current route */
|
|
@@ -27,6 +30,8 @@ type BreadcrumbProps = {
|
|
|
27
30
|
ariaLabelPrefix?: string
|
|
28
31
|
/** Truncate breadcrumb text after this length */
|
|
29
32
|
truncateLength?: number
|
|
33
|
+
|
|
34
|
+
linkProps?: React.ComponentProps<typeof Link>
|
|
30
35
|
} & React.ComponentProps<typeof UI>
|
|
31
36
|
|
|
32
37
|
// Components
|
|
@@ -106,6 +111,7 @@ const Nav = ({
|
|
|
106
111
|
*/
|
|
107
112
|
export const Breadcrumb = ({
|
|
108
113
|
startRoute = 'Home',
|
|
114
|
+
startRouteUrl = "/",
|
|
109
115
|
currentRoute,
|
|
110
116
|
spacer = <>/</>,
|
|
111
117
|
routes,
|
|
@@ -114,6 +120,7 @@ export const Breadcrumb = ({
|
|
|
114
120
|
classes,
|
|
115
121
|
ariaLabelPrefix,
|
|
116
122
|
truncateLength = 15,
|
|
123
|
+
linkProps,
|
|
117
124
|
...props
|
|
118
125
|
}: BreadcrumbProps): React.JSX.Element => {
|
|
119
126
|
const [currentPath, setCurrentPath] = React.useState('')
|
|
@@ -122,7 +129,7 @@ export const Breadcrumb = ({
|
|
|
122
129
|
if (path.length) {
|
|
123
130
|
setCurrentPath(path)
|
|
124
131
|
}
|
|
125
|
-
}, [])
|
|
132
|
+
}, [currentRoute])
|
|
126
133
|
|
|
127
134
|
/**
|
|
128
135
|
* Gets the path name for the given path segment.
|
|
@@ -148,6 +155,7 @@ export const Breadcrumb = ({
|
|
|
148
155
|
/** Unique id for breadcrumb */
|
|
149
156
|
const uuid = React.useId()
|
|
150
157
|
|
|
158
|
+
|
|
151
159
|
return currentPath.length ? (
|
|
152
160
|
<Nav
|
|
153
161
|
id={id}
|
|
@@ -157,53 +165,52 @@ export const Breadcrumb = ({
|
|
|
157
165
|
aria-label={ariaLabelPrefix}
|
|
158
166
|
>
|
|
159
167
|
<Items key={`${startRoute}-${uuid}`}>
|
|
160
|
-
<
|
|
168
|
+
<Link href={startRouteUrl} {...linkProps}>{startRoute}</Link>
|
|
161
169
|
</Items>
|
|
170
|
+
<>
|
|
162
171
|
{segments.length ? (
|
|
163
172
|
segments.map((segment: any, index: number) => {
|
|
164
173
|
const currentSegment = getPathName(segment)
|
|
165
174
|
const { name, url, path } = currentSegment
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
</Items>
|
|
201
|
-
)
|
|
202
|
-
}
|
|
175
|
+
return index === lastSegment ? (
|
|
176
|
+
<>
|
|
177
|
+
{typeof segments[lastSegment] === 'string' &&
|
|
178
|
+
segments[lastSegment].length > 3 &&
|
|
179
|
+
segments[lastSegment] !== segments[lastSegment - 1] && (
|
|
180
|
+
<Items key={`${path || index}-${uuid}`}>
|
|
181
|
+
|
|
182
|
+
<span aria-hidden="true">{spacer}</span>
|
|
183
|
+
<a
|
|
184
|
+
aria-current="page"
|
|
185
|
+
aria-label={
|
|
186
|
+
name.length > truncateLength ? name : undefined
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
{Truncate(decodeURIComponent(name), truncateLength)}
|
|
190
|
+
</a>
|
|
191
|
+
|
|
192
|
+
</Items>
|
|
193
|
+
)}
|
|
194
|
+
</>
|
|
195
|
+
) : (
|
|
196
|
+
<Items key={`${currentSegment?.name}-${uuid}`}>
|
|
197
|
+
<span aria-hidden="true">{spacer}</span>
|
|
198
|
+
<span>
|
|
199
|
+
<Link
|
|
200
|
+
href={url}
|
|
201
|
+
aria-label={name.length > truncateLength ? name : undefined}
|
|
202
|
+
{...linkProps}
|
|
203
|
+
>
|
|
204
|
+
{Truncate(decodeURIComponent(name), truncateLength)}
|
|
205
|
+
</Link>
|
|
206
|
+
</span>
|
|
207
|
+
</Items>
|
|
208
|
+
);
|
|
203
209
|
})
|
|
204
210
|
) : (
|
|
205
|
-
|
|
211
|
+
null
|
|
206
212
|
)}
|
|
213
|
+
</>
|
|
207
214
|
</Nav>
|
|
208
215
|
) : (
|
|
209
216
|
<></>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within, userEvent } from '@storybook/
|
|
3
|
-
|
|
2
|
+
import { within, userEvent, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Button from './button'
|
|
6
6
|
import './button.scss'
|
|
@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react'
|
|
|
3
3
|
import { Button } from './button'
|
|
4
4
|
import user from '@testing-library/user-event'
|
|
5
5
|
import jest from 'jest-mock'
|
|
6
|
-
import { userEvent } from '@storybook/
|
|
6
|
+
import { userEvent } from '@storybook/test'
|
|
7
7
|
|
|
8
8
|
describe('Button', () => {
|
|
9
9
|
it('renders a button element with the correct label', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within, userEvent, screen } from '@storybook/
|
|
3
|
-
|
|
2
|
+
import { within, userEvent, screen } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Card from './card'
|
|
6
6
|
// import './card.scss'
|
|
@@ -4,8 +4,8 @@ details {
|
|
|
4
4
|
--details-border: 1px solid #dfdfdf;
|
|
5
5
|
--details-display: flex;
|
|
6
6
|
--details-justify: flex-start;
|
|
7
|
-
--details-direction:
|
|
8
|
-
--details-gap:
|
|
7
|
+
--details-direction: column;
|
|
8
|
+
--details-gap: 0rem;
|
|
9
9
|
--details-px: 1.5rem;
|
|
10
10
|
--details-py: 1.5rem;
|
|
11
11
|
--details-radius: 0.5rem;
|
|
@@ -41,11 +41,19 @@ details {
|
|
|
41
41
|
padding-block: var(--summary-py, var(--details-py));
|
|
42
42
|
gap: var(--summary-gap);
|
|
43
43
|
list-style: none;
|
|
44
|
+
border-top-left-radius: var(--details-radius);
|
|
45
|
+
border-top-right-radius: var(--details-radius);
|
|
44
46
|
|
|
45
47
|
&::-webkit-details-marker {
|
|
46
48
|
display: none;
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
&:focus-within {
|
|
52
|
+
outline: none;
|
|
53
|
+
border-bottom: solid 2px var(--details-border);
|
|
54
|
+
background-color: whitesmoke;
|
|
55
|
+
}
|
|
56
|
+
|
|
49
57
|
/* This ensures no bullet points are shown */
|
|
50
58
|
|
|
51
59
|
&:hover {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect, userEvent } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Details from './details'
|
|
6
6
|
import Icons from '../icons/icon'
|
|
7
|
-
import '../../styles/details/details.css'
|
|
8
7
|
|
|
9
8
|
const content = (
|
|
10
9
|
<>
|
|
@@ -56,7 +55,7 @@ export const DetailsDropdown: Story = {
|
|
|
56
55
|
args: {},
|
|
57
56
|
play: async ({ canvasElement }) => {
|
|
58
57
|
const canvas = within(canvasElement)
|
|
59
|
-
expect(canvas.getByRole('group')).toBeInTheDocument()
|
|
58
|
+
expect(canvas.getByRole('group', { name: /details dropdown/i })).toBeInTheDocument()
|
|
60
59
|
},
|
|
61
60
|
} as Story
|
|
62
61
|
|
|
@@ -120,3 +119,20 @@ export const DetailsAccordion: Story = {
|
|
|
120
119
|
</>
|
|
121
120
|
)
|
|
122
121
|
} as Story
|
|
122
|
+
|
|
123
|
+
export const DetailsInteractionTest: Story = {
|
|
124
|
+
args: {},
|
|
125
|
+
play: async ({ canvasElement }) => {
|
|
126
|
+
const canvas = within(canvasElement);
|
|
127
|
+
|
|
128
|
+
// Find the summary element
|
|
129
|
+
const summaryElement = canvas.getByText('Summary Section');
|
|
130
|
+
|
|
131
|
+
// Simulate a click on the summary element
|
|
132
|
+
await userEvent.click(summaryElement);
|
|
133
|
+
|
|
134
|
+
// Assert that the details element is open
|
|
135
|
+
const detailsElement = canvas.getByRole('group', { name: /details dropdown/i });
|
|
136
|
+
expect(detailsElement).toHaveAttribute('open');
|
|
137
|
+
},
|
|
138
|
+
}
|
|
@@ -61,10 +61,11 @@ export const Details = ({
|
|
|
61
61
|
ref={ref}
|
|
62
62
|
open={open}
|
|
63
63
|
aria-label={ariaLabel || 'Details dropdown'}
|
|
64
|
+
// aria-roledescription="detail accordion"
|
|
64
65
|
name={name}
|
|
65
66
|
{...props}
|
|
66
67
|
>
|
|
67
|
-
<UI as="summary"
|
|
68
|
+
<UI as="summary" onPointerDown={onPointerDownCallback}>
|
|
68
69
|
{icon}
|
|
69
70
|
{summary}
|
|
70
71
|
</UI>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Form from './form'
|
|
6
6
|
import './form.scss'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within, userEvent,
|
|
3
|
-
|
|
2
|
+
import { within, userEvent, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Input from './inputs'
|
|
6
6
|
import './form.scss'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within, userEvent, screen } from '@storybook/
|
|
3
|
-
|
|
2
|
+
import { within, userEvent, screen } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Select from './select'
|
|
6
6
|
import React from 'react'
|
|
@@ -70,41 +70,31 @@ export const Select = ({
|
|
|
70
70
|
|
|
71
71
|
const handleOnBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
72
72
|
if (onBlur && !disabled) onBlur?.(e)
|
|
73
|
-
const handleOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
|
|
74
|
-
if (onSelectionChange && !disabled) onSelectionChange?.(e)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const handlePointerDown = (e: React.PointerEvent<HTMLSelectElement>) => {
|
|
78
|
-
if (onPointerDown && !disabled) onPointerDown?.(e)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const handleOnBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
|
|
82
|
-
if (onBlur && !disabled) onBlur?.(e)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<UI
|
|
87
|
-
as="select"
|
|
88
|
-
id={id}
|
|
89
|
-
ref={ref}
|
|
90
|
-
name={name}
|
|
91
|
-
className={classes}
|
|
92
|
-
selected={selected}
|
|
93
|
-
onChange={handleOnChange}
|
|
94
|
-
onPointerDown={handlePointerDown}
|
|
95
|
-
onBlur={handleOnBlur}
|
|
96
|
-
required={required}
|
|
97
|
-
aria-required={required} // Accessibility
|
|
98
|
-
disabled={disabled}
|
|
99
|
-
aria-disabled={disabled ? true : false}
|
|
100
|
-
style={styles}
|
|
101
|
-
{...props} // Accessibility
|
|
102
|
-
>
|
|
103
|
-
<option value="" />
|
|
104
|
-
</UI>
|
|
105
|
-
)
|
|
106
73
|
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<UI
|
|
77
|
+
as="select"
|
|
78
|
+
id={id}
|
|
79
|
+
ref={ref}
|
|
80
|
+
name={name}
|
|
81
|
+
className={classes}
|
|
82
|
+
selected={selected}
|
|
83
|
+
onChange={handleOnChange}
|
|
84
|
+
onPointerDown={handlePointerDown}
|
|
85
|
+
onBlur={handleOnBlur}
|
|
86
|
+
required={required}
|
|
87
|
+
aria-required={required} // Accessibility
|
|
88
|
+
disabled={disabled}
|
|
89
|
+
aria-disabled={disabled ? true : false}
|
|
90
|
+
style={styles}
|
|
91
|
+
{...props} // Accessibility
|
|
92
|
+
>
|
|
93
|
+
<option value="" />
|
|
94
|
+
</UI>
|
|
95
|
+
)
|
|
107
96
|
}
|
|
97
|
+
|
|
108
98
|
export default Select
|
|
109
99
|
Select.displayName = 'Select' // Remove this line
|
|
110
100
|
Select.Option = Option // Remove this line
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { render, screen } from '@testing-library/react'
|
|
3
3
|
import FP from '../components/fp'
|
|
4
4
|
import jest from 'jest-mock'
|
|
5
|
-
import { userEvent } from '@storybook/
|
|
5
|
+
import { userEvent } from '@storybook/test'
|
|
6
6
|
|
|
7
7
|
describe('FP component', () => {
|
|
8
8
|
it('renders a div by default', () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Figure from './figure'
|
|
6
6
|
|
|
@@ -25,10 +25,7 @@ export const FigureComponent: Story = {
|
|
|
25
25
|
args: {},
|
|
26
26
|
play: async ({ canvasElement }) => {
|
|
27
27
|
const canvas = within(canvasElement)
|
|
28
|
-
expect(
|
|
29
|
-
canvas.getByText(/caption for the image here.../i),
|
|
30
|
-
).toBeInTheDocument()
|
|
31
|
-
expect(canvas.getByRole('img')).toBeInTheDocument()
|
|
28
|
+
// await expect(canvas.getByRole('img')).toBeInTheDocument()
|
|
32
29
|
expect(canvas.getByRole('figure')).toBeInTheDocument()
|
|
33
30
|
},
|
|
34
31
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Img from './img'
|
|
6
6
|
|
|
@@ -19,6 +19,6 @@ export const ImgComponent: Story = {
|
|
|
19
19
|
args: {},
|
|
20
20
|
play: async ({ canvasElement }) => {
|
|
21
21
|
const canvas = within(canvasElement)
|
|
22
|
-
expect(canvas.getByRole('img')).toBeInTheDocument()
|
|
22
|
+
await expect(canvas.getByRole('img')).toBeInTheDocument()
|
|
23
23
|
},
|
|
24
24
|
}
|
|
@@ -2,12 +2,12 @@ import { StoryObj, Meta } from '@storybook/react'
|
|
|
2
2
|
/**
|
|
3
3
|
* Import testing library dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { within, userEvent } from '@storybook/
|
|
5
|
+
import { within, userEvent } from '@storybook/test'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Import jest matchers
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
|
|
12
12
|
import { Footer } from './landmarks'
|
|
13
13
|
|
|
@@ -2,12 +2,12 @@ import { StoryObj, Meta } from '@storybook/react'
|
|
|
2
2
|
/**
|
|
3
3
|
* Import testing library dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { within,
|
|
5
|
+
import { within, expect } from '@storybook/test'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Import jest matchers
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
|
|
12
12
|
import { Header } from './landmarks'
|
|
13
13
|
|
|
@@ -2,12 +2,12 @@ import { StoryObj, Meta } from '@storybook/react'
|
|
|
2
2
|
/**
|
|
3
3
|
* Import testing library dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { within, userEvent } from '@storybook/
|
|
5
|
+
import { within, userEvent, expect } from '@storybook/test'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Import jest matchers
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
|
|
12
12
|
import { Main } from './landmarks'
|
|
13
13
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
2
|
|
|
3
|
-
import { within,
|
|
3
|
+
import { within, expect } from '@storybook/test'
|
|
4
|
+
|
|
4
5
|
|
|
5
|
-
import { expect } from '@storybook/jest'
|
|
6
6
|
|
|
7
7
|
import Link from './link'
|
|
8
8
|
import '../../styles/link/link.css'
|
|
@@ -2,9 +2,8 @@ import React from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { StoryObj, Meta } from '@storybook/react'
|
|
4
4
|
|
|
5
|
-
import { within, userEvent } from '@storybook/
|
|
5
|
+
import { within, userEvent } from '@storybook/test'
|
|
6
6
|
|
|
7
|
-
import { expect } from '@storybook/jest'
|
|
8
7
|
|
|
9
8
|
import List from './list'
|
|
10
9
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within } from '@storybook/
|
|
3
|
-
|
|
2
|
+
import { within, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
import React from 'react'
|
|
5
5
|
|
|
6
6
|
import Nav from './nav'
|
|
@@ -40,7 +40,8 @@ export const NavComponent: Story = {
|
|
|
40
40
|
args: {},
|
|
41
41
|
play: async ({ canvasElement }) => {
|
|
42
42
|
const canvas = within(canvasElement)
|
|
43
|
-
expect(canvas.
|
|
43
|
+
expect(canvas.getAllByRole('link')).toHaveLength(2)
|
|
44
|
+
expect(canvas.getByText(/link 1/i)).toBeInTheDocument()
|
|
44
45
|
},
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect, userEvent } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Popover from './popover'
|
|
6
6
|
import { getByText } from '@testing-library/react'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within, userEvent, screen } from '@storybook/
|
|
3
|
-
|
|
2
|
+
import { within, userEvent, screen } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import '../../styles/progress/progress.css'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StoryObj, Meta } from '@storybook/react'
|
|
2
|
-
import { within,
|
|
3
|
-
|
|
2
|
+
import { within, expect } from '@storybook/test'
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
import Tag from './tag'
|
|
6
6
|
import './tag.scss'
|
|
@@ -22,7 +22,7 @@ export const TagComponent: Story = {
|
|
|
22
22
|
args: {},
|
|
23
23
|
play: async ({ canvasElement }) => {
|
|
24
24
|
const canvas = within(canvasElement)
|
|
25
|
-
expect(canvas.queryByText(/basic
|
|
25
|
+
expect(canvas.queryByText(/basic tag/i)).toBeInTheDocument()
|
|
26
26
|
},
|
|
27
27
|
}
|
|
28
28
|
|