@faststore/ui 1.4.3 → 1.4.7
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/CHANGELOG.md +38 -0
- package/dist/molecules/IconButton/IconButton.d.ts +5 -1
- package/dist/molecules/QuantitySelector/QuantitySelector.d.ts +2 -2
- package/dist/ui.cjs.development.js +26 -27
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +26 -27
- package/dist/ui.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/atoms/Checkbox/stories/Checkbox.stories.tsx +13 -8
- package/src/atoms/List/List.test.tsx +21 -2
- package/src/atoms/List/List.tsx +1 -2
- package/src/atoms/List/stories/List.mdx +2 -11
- package/src/atoms/Radio/stories/Radio.stories.tsx +6 -1
- package/src/atoms/Select/stories/Select.stories.tsx +12 -9
- package/src/atoms/Slider/Slider.tsx +3 -3
- package/src/atoms/Slider/stories/Slider.mdx +2 -2
- package/src/atoms/TextArea/stories/TextArea.stories.tsx +1 -1
- package/src/molecules/Accordion/Accordion.test.tsx +6 -6
- package/src/molecules/Accordion/AccordionButton.tsx +1 -1
- package/src/molecules/Accordion/AccordionItem.tsx +1 -6
- package/src/molecules/Accordion/AccordionPanel.tsx +1 -1
- package/src/molecules/Accordion/stories/Accordion.mdx +3 -3
- package/src/molecules/Banner/Banner.test.tsx +6 -6
- package/src/molecules/Banner/BannerContent.tsx +1 -6
- package/src/molecules/Banner/BannerImage.tsx +1 -6
- package/src/molecules/Banner/BannerLink.tsx +1 -6
- package/src/molecules/Banner/stories/Banner.mdx +4 -4
- package/src/molecules/Breadcrumb/Breadcrumb.test.tsx +12 -7
- package/src/molecules/Breadcrumb/Breadcrumb.tsx +3 -3
- package/src/molecules/Breadcrumb/stories/Breadcrumb.mdx +4 -2
- package/src/molecules/Carousel/Carousel.tsx +2 -2
- package/src/molecules/IconButton/IconButton.test.tsx +6 -2
- package/src/molecules/IconButton/IconButton.tsx +6 -1
- package/src/molecules/IconButton/stories/IconButton.stories.tsx +7 -2
- package/src/molecules/PriceRange/PriceRange.tsx +3 -3
- package/src/molecules/PriceRange/stories/PriceRange.mdx +2 -2
- package/src/molecules/QuantitySelector/QuantitySelector.tsx +2 -2
- package/src/molecules/Table/Table.test.tsx +7 -11
- package/src/molecules/Table/TableBody.tsx +1 -6
- package/src/molecules/Table/TableCell.tsx +1 -1
- package/src/molecules/Table/TableFooter.tsx +1 -6
- package/src/molecules/Table/TableHead.tsx +1 -6
- package/src/molecules/Table/TableRow.tsx +1 -1
- package/src/molecules/Table/stories/Table.mdx +5 -7
- package/src/organisms/Card/Card.test.tsx +6 -6
- package/src/organisms/Card/CardActions.tsx +1 -6
- package/src/organisms/Card/CardContent.tsx +1 -6
- package/src/organisms/Card/CardImage.tsx +1 -1
- package/src/organisms/Card/stories/Card.mdx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.7",
|
|
4
4
|
"description": "A lightweight, framework agnostic component library for React",
|
|
5
5
|
"author": "emersonlaurentino",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/jest-axe": "^3.5.3",
|
|
77
77
|
"@types/tabbable": "^3.1.1",
|
|
78
78
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
79
|
-
"@vtex/theme-b2c-tailwind": "^1.4.
|
|
79
|
+
"@vtex/theme-b2c-tailwind": "^1.4.7",
|
|
80
80
|
"@vtex/tsconfig": "^0.5.0",
|
|
81
81
|
"chalk": "^5.0.0",
|
|
82
82
|
"jest-axe": "^5.0.1",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"tsdx": "^0.14.1",
|
|
90
90
|
"typescript": "^4.2.4"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "91f90091909f47b5e0e737e6b870740fb47627aa"
|
|
93
93
|
}
|
|
@@ -18,14 +18,19 @@ const CheckboxTemplate: Story<CheckboxProps> = ({
|
|
|
18
18
|
}, [checked])
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
onClick
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
<>
|
|
22
|
+
<Component
|
|
23
|
+
{...otherProps}
|
|
24
|
+
checked={localChecked}
|
|
25
|
+
onClick={(e) => {
|
|
26
|
+
onClick?.(e)
|
|
27
|
+
setLocalChecked(!localChecked)
|
|
28
|
+
}}
|
|
29
|
+
id="checkbox"
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
<label htmlFor="checkbox">Checkbox</label>
|
|
33
|
+
</>
|
|
29
34
|
)
|
|
30
35
|
}
|
|
31
36
|
|
|
@@ -34,7 +34,10 @@ describe('List', () => {
|
|
|
34
34
|
</List>
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
-
expect(getByTestId('store-list')).toHaveAttribute(
|
|
37
|
+
expect(getByTestId('store-list')).toHaveAttribute(
|
|
38
|
+
'data-store-list',
|
|
39
|
+
'ordered'
|
|
40
|
+
)
|
|
38
41
|
|
|
39
42
|
rerender(
|
|
40
43
|
<List variant="unordered">
|
|
@@ -44,7 +47,23 @@ describe('List', () => {
|
|
|
44
47
|
</List>
|
|
45
48
|
)
|
|
46
49
|
|
|
47
|
-
expect(getByTestId('store-list')).toHaveAttribute(
|
|
50
|
+
expect(getByTestId('store-list')).toHaveAttribute(
|
|
51
|
+
'data-store-list',
|
|
52
|
+
'unordered'
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
rerender(
|
|
56
|
+
<List variant="description">
|
|
57
|
+
{optionsArray.map((value) => {
|
|
58
|
+
return <li key={value}>{value}</li>
|
|
59
|
+
})}
|
|
60
|
+
</List>
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
expect(getByTestId('store-list')).toHaveAttribute(
|
|
64
|
+
'data-store-list',
|
|
65
|
+
'description'
|
|
66
|
+
)
|
|
48
67
|
})
|
|
49
68
|
|
|
50
69
|
it('should render the expected HTML tag for each variant', () => {
|
package/src/atoms/List/List.tsx
CHANGED
|
@@ -27,8 +27,7 @@ const List = forwardRef<HTMLUListElement, ListProps>(function List(
|
|
|
27
27
|
) {
|
|
28
28
|
const dataAttributes = {
|
|
29
29
|
'data-testid': testId,
|
|
30
|
-
'data-store-list':
|
|
31
|
-
[`data-${variant}`]: true,
|
|
30
|
+
'data-store-list': variant,
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
const Component = MaybeComponent ?? variantToElement[variant] ?? 'ul'
|
|
@@ -28,15 +28,6 @@ import List from '../List'
|
|
|
28
28
|
## CSS Selectors
|
|
29
29
|
|
|
30
30
|
```css
|
|
31
|
-
[data-store-list] {
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
[data-store-list][data-unordered] {
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[data-store-list][data-ordered] {
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[data-store-list][data-description] {
|
|
41
|
-
}
|
|
31
|
+
[data-store-list] {}
|
|
32
|
+
[data-store-list='(description|ordered|unordered)'] {}
|
|
42
33
|
```
|
|
@@ -6,7 +6,12 @@ import type { RadioProps } from '../Radio'
|
|
|
6
6
|
import Component from '../Radio'
|
|
7
7
|
import mdx from './Radio.mdx'
|
|
8
8
|
|
|
9
|
-
const RadioTemplate: Story<RadioProps> = (props) =>
|
|
9
|
+
const RadioTemplate: Story<RadioProps> = (props) => (
|
|
10
|
+
<>
|
|
11
|
+
<Component {...props} id="radio" />
|
|
12
|
+
<label htmlFor="radio">Radio</label>
|
|
13
|
+
</>
|
|
14
|
+
)
|
|
10
15
|
|
|
11
16
|
export const Radio = RadioTemplate.bind({})
|
|
12
17
|
|
|
@@ -9,15 +9,18 @@ import mdx from './Select.mdx'
|
|
|
9
9
|
type SelectStoryProps = SelectProps & { options: string[][] }
|
|
10
10
|
const SelectTemplate: Story<SelectStoryProps> = ({ options, ...props }) => {
|
|
11
11
|
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
<>
|
|
13
|
+
<label htmlFor="select">Select:</label>
|
|
14
|
+
<Component {...props} name="select" id="select">
|
|
15
|
+
{options.map(([value, label]) => {
|
|
16
|
+
return (
|
|
17
|
+
<option key={value} value={value}>
|
|
18
|
+
{label}
|
|
19
|
+
</option>
|
|
20
|
+
)
|
|
21
|
+
})}
|
|
22
|
+
</Component>
|
|
23
|
+
</>
|
|
21
24
|
)
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -80,7 +80,7 @@ const Slider = ({
|
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
82
|
<div data-store-slider data-testid={testId} className={className}>
|
|
83
|
-
<div ref={range} data-
|
|
83
|
+
<div ref={range} data-slider-range />
|
|
84
84
|
<input
|
|
85
85
|
type="range"
|
|
86
86
|
min={min}
|
|
@@ -92,7 +92,7 @@ const Slider = ({
|
|
|
92
92
|
setMinVal(value)
|
|
93
93
|
minValRef.current = value
|
|
94
94
|
}}
|
|
95
|
-
data-
|
|
95
|
+
data-slider-thumb="left"
|
|
96
96
|
aria-valuemin={min}
|
|
97
97
|
aria-valuemax={max}
|
|
98
98
|
aria-valuenow={minVal}
|
|
@@ -112,7 +112,7 @@ const Slider = ({
|
|
|
112
112
|
setMaxVal(value)
|
|
113
113
|
maxValRef.current = value
|
|
114
114
|
}}
|
|
115
|
-
data-
|
|
115
|
+
data-slider-thumb="right"
|
|
116
116
|
aria-valuemin={min}
|
|
117
117
|
aria-valuemax={max}
|
|
118
118
|
aria-valuenow={maxVal}
|
|
@@ -7,7 +7,7 @@ import mdx from './TextArea.mdx'
|
|
|
7
7
|
import type { ComponentArgTypes } from '../../../typings/utils'
|
|
8
8
|
|
|
9
9
|
const TextAreaTemplate: Story<TextAreaProps> = (props) => (
|
|
10
|
-
<Component {...props} />
|
|
10
|
+
<Component {...props} aria-label="Textarea" />
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
export const Textarea = TextAreaTemplate.bind({})
|
|
@@ -99,21 +99,21 @@ describe('Accordion', () => {
|
|
|
99
99
|
expect(accordion).toHaveAttribute('data-store-accordion')
|
|
100
100
|
})
|
|
101
101
|
|
|
102
|
-
it('`AccordionItem` component should have `data-
|
|
102
|
+
it('`AccordionItem` component should have `data-accordion-item` attribute', () => {
|
|
103
103
|
for (const item of items) {
|
|
104
|
-
expect(item).toHaveAttribute('data-
|
|
104
|
+
expect(item).toHaveAttribute('data-accordion-item')
|
|
105
105
|
}
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
-
it('`AccordionButton` component should have `data-
|
|
108
|
+
it('`AccordionButton` component should have `data-accordion-button` attribute', () => {
|
|
109
109
|
for (const button of buttons) {
|
|
110
|
-
expect(button).toHaveAttribute('data-
|
|
110
|
+
expect(button).toHaveAttribute('data-accordion-button')
|
|
111
111
|
}
|
|
112
112
|
})
|
|
113
113
|
|
|
114
|
-
it('`AccordionPanel` component should have `data-
|
|
114
|
+
it('`AccordionPanel` component should have `data-accordion-panel` attribute', () => {
|
|
115
115
|
for (const panel of panels) {
|
|
116
|
-
expect(panel).toHaveAttribute('data-
|
|
116
|
+
expect(panel).toHaveAttribute('data-accordion-panel')
|
|
117
117
|
}
|
|
118
118
|
})
|
|
119
119
|
})
|
|
@@ -60,7 +60,7 @@ const AccordionButton = forwardRef<HTMLButtonElement, AccordionButtonProps>(
|
|
|
60
60
|
id={button}
|
|
61
61
|
aria-expanded={indices.has(index)}
|
|
62
62
|
aria-controls={panel}
|
|
63
|
-
data-
|
|
63
|
+
data-accordion-button
|
|
64
64
|
data-testid={testId}
|
|
65
65
|
onKeyDown={onKeyDown}
|
|
66
66
|
onClick={() => {
|
|
@@ -36,12 +36,7 @@ const AccordionItem = forwardRef<HTMLDivElement, AccordionItemProps>(
|
|
|
36
36
|
|
|
37
37
|
return (
|
|
38
38
|
<AccordionItemContext.Provider value={context}>
|
|
39
|
-
<div
|
|
40
|
-
ref={ref}
|
|
41
|
-
data-store-accordion-item
|
|
42
|
-
data-testid={testId}
|
|
43
|
-
{...otherProps}
|
|
44
|
-
>
|
|
39
|
+
<div ref={ref} data-accordion-item data-testid={testId} {...otherProps}>
|
|
45
40
|
{children}
|
|
46
41
|
</div>
|
|
47
42
|
</AccordionItemContext.Provider>
|
|
@@ -54,9 +54,9 @@ Besides those attributes, the following props are also supported:
|
|
|
54
54
|
|
|
55
55
|
```css
|
|
56
56
|
[data-store-accordion] {}
|
|
57
|
-
[data-
|
|
58
|
-
[data-
|
|
59
|
-
[data-
|
|
57
|
+
[data-accordion-item] {}
|
|
58
|
+
[data-accordion-button] {}
|
|
59
|
+
[data-accordion-panel] {}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
The `AccordionButton` component inherits [Button](?path=/docs/atoms-button--button#css-selectors) css selectors.
|
|
@@ -40,16 +40,16 @@ describe('Banner', () => {
|
|
|
40
40
|
expect(banner).toHaveAttribute('data-store-banner')
|
|
41
41
|
})
|
|
42
42
|
|
|
43
|
-
it('`BannerImage` component should have `data-
|
|
44
|
-
expect(bannerImage).toHaveAttribute('data-
|
|
43
|
+
it('`BannerImage` component should have `data-banner-image` attribute', () => {
|
|
44
|
+
expect(bannerImage).toHaveAttribute('data-banner-image')
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
it('`BannerContent` component should have `data-
|
|
48
|
-
expect(bannerContent).toHaveAttribute('data-
|
|
47
|
+
it('`BannerContent` component should have `data-banner-content` attribute', () => {
|
|
48
|
+
expect(bannerContent).toHaveAttribute('data-banner-content')
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
it('`BannerLink` component should have `data-
|
|
52
|
-
expect(bannerLink).toHaveAttribute('data-
|
|
51
|
+
it('`BannerLink` component should have `data-banner-link` attribute', () => {
|
|
52
|
+
expect(bannerLink).toHaveAttribute('data-banner-link')
|
|
53
53
|
})
|
|
54
54
|
})
|
|
55
55
|
|
|
@@ -14,12 +14,7 @@ const BannerContent = forwardRef<HTMLDivElement, BannerContentProps>(
|
|
|
14
14
|
ref
|
|
15
15
|
) {
|
|
16
16
|
return (
|
|
17
|
-
<div
|
|
18
|
-
ref={ref}
|
|
19
|
-
data-store-banner-content
|
|
20
|
-
data-testid={testId}
|
|
21
|
-
{...otherProps}
|
|
22
|
-
>
|
|
17
|
+
<div ref={ref} data-banner-content data-testid={testId} {...otherProps}>
|
|
23
18
|
{children}
|
|
24
19
|
</div>
|
|
25
20
|
)
|
|
@@ -14,12 +14,7 @@ const BannerImage = forwardRef<HTMLDivElement, BannerImageProps>(
|
|
|
14
14
|
ref
|
|
15
15
|
) {
|
|
16
16
|
return (
|
|
17
|
-
<div
|
|
18
|
-
ref={ref}
|
|
19
|
-
data-store-banner-image
|
|
20
|
-
data-testid={testId}
|
|
21
|
-
{...otherProps}
|
|
22
|
-
>
|
|
17
|
+
<div ref={ref} data-banner-image data-testid={testId} {...otherProps}>
|
|
23
18
|
{children}
|
|
24
19
|
</div>
|
|
25
20
|
)
|
|
@@ -14,12 +14,7 @@ const BannerLink = forwardRef<HTMLDivElement, BannerLinkProps>(
|
|
|
14
14
|
ref
|
|
15
15
|
) {
|
|
16
16
|
return (
|
|
17
|
-
<div
|
|
18
|
-
ref={ref}
|
|
19
|
-
data-store-banner-link
|
|
20
|
-
data-testid={testId}
|
|
21
|
-
{...otherProps}
|
|
22
|
-
>
|
|
17
|
+
<div ref={ref} data-banner-link data-testid={testId} {...otherProps}>
|
|
23
18
|
{children}
|
|
24
19
|
</div>
|
|
25
20
|
)
|
|
@@ -52,12 +52,12 @@ Besides those attributes, the following props are also supported:
|
|
|
52
52
|
```css
|
|
53
53
|
[data-store-banner] {
|
|
54
54
|
}
|
|
55
|
-
[data-store-banner=(
|
|
55
|
+
[data-store-banner='(vertical|horizontal)'] {
|
|
56
56
|
}
|
|
57
|
-
[data-
|
|
57
|
+
[data-banner-image] {
|
|
58
58
|
}
|
|
59
|
-
[data-
|
|
59
|
+
[data-banner-content] {
|
|
60
60
|
}
|
|
61
|
-
[data-
|
|
61
|
+
[data-banner-link] {
|
|
62
62
|
}
|
|
63
63
|
```
|
|
@@ -38,19 +38,24 @@ describe('Breadcrumb', () => {
|
|
|
38
38
|
|
|
39
39
|
// Validate that breadcrumb is rendering with the correct size.
|
|
40
40
|
expect(breadcrumbItems).toHaveLength(breadcrumbSize)
|
|
41
|
-
// Validate if the last element has the active attribute.
|
|
41
|
+
// Validate if the last element has the 'data-breadcrumb-item=current' active attribute.
|
|
42
42
|
expect(breadcrumbItems[breadcrumbSize - 1]).toHaveAttribute(
|
|
43
|
-
'data-
|
|
43
|
+
'data-breadcrumb-item',
|
|
44
|
+
'current'
|
|
44
45
|
)
|
|
45
46
|
|
|
46
47
|
// Get all elements except the last one.
|
|
47
48
|
breadcrumbItems.pop()
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
// Validate that no other element has the 'data-breadcrumb-item=current' attribute
|
|
51
|
+
breadcrumbItems.forEach((item) => {
|
|
52
|
+
expect(item).not.toHaveAttribute('data-breadcrumb-item', 'current')
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
// Validate that all elements have the 'data-breadcrumb-item' attribute,
|
|
56
|
+
// regardless of value
|
|
49
57
|
breadcrumbItems.forEach((item) => {
|
|
50
|
-
expect(item).
|
|
51
|
-
'data-store-breadcrumb-item',
|
|
52
|
-
'current'
|
|
53
|
-
)
|
|
58
|
+
expect(item).toHaveAttribute('data-breadcrumb-item')
|
|
54
59
|
})
|
|
55
60
|
}
|
|
56
61
|
})
|
|
@@ -16,7 +16,7 @@ export interface BreadcrumbProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
16
16
|
|
|
17
17
|
const Divider: FC<BreadcrumbProps> = ({ divider, testId }) => {
|
|
18
18
|
const props = {
|
|
19
|
-
'data-
|
|
19
|
+
'data-breadcrumb-divider': true,
|
|
20
20
|
'aria-hidden': true,
|
|
21
21
|
'data-testid': `${testId}-divider`,
|
|
22
22
|
}
|
|
@@ -37,7 +37,7 @@ type ListItemProps = {
|
|
|
37
37
|
const ListItem: FC<ListItemProps> = ({ children, isLastItem, testId }) => {
|
|
38
38
|
const props = {
|
|
39
39
|
'data-testid': `${testId}-item`,
|
|
40
|
-
'data-
|
|
40
|
+
'data-breadcrumb-item': isLastItem ? 'current' : true,
|
|
41
41
|
'aria-current': isLastItem ? ('page' as const) : undefined,
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -73,7 +73,7 @@ const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbProps>(
|
|
|
73
73
|
data-testid={testId}
|
|
74
74
|
{...otherProps}
|
|
75
75
|
>
|
|
76
|
-
<List data-
|
|
76
|
+
<List data-breadcrumb-list variant="ordered">
|
|
77
77
|
{React.Children.map(children, (child, index) => {
|
|
78
78
|
const isLastItem = index === lastIndex - 1
|
|
79
79
|
|
|
@@ -17,7 +17,9 @@ import Breadcrumb from '../Breadcrumb'
|
|
|
17
17
|
```css
|
|
18
18
|
[data-store-breadcrumb] {}
|
|
19
19
|
|
|
20
|
-
[data-breadcrumb-
|
|
20
|
+
[data-breadcrumb-list] {}
|
|
21
21
|
|
|
22
|
-
[data-breadcrumb-item
|
|
22
|
+
[data-breadcrumb-item='(current|true)'] {}
|
|
23
|
+
|
|
24
|
+
[data-breadcrumb-divider] {}
|
|
23
25
|
```
|
|
@@ -208,16 +208,16 @@ function Carousel({
|
|
|
208
208
|
{showNavigationArrows && (
|
|
209
209
|
<div data-carousel-controls>
|
|
210
210
|
<IconButton
|
|
211
|
+
aria-label="previous"
|
|
211
212
|
data-arrow="left"
|
|
212
213
|
aria-controls={id}
|
|
213
|
-
aria-label="previous"
|
|
214
214
|
onClick={slidePrevious}
|
|
215
215
|
icon={<LeftArrowIcon />}
|
|
216
216
|
/>
|
|
217
217
|
<IconButton
|
|
218
|
+
aria-label="next"
|
|
218
219
|
data-arrow="right"
|
|
219
220
|
aria-controls={id}
|
|
220
|
-
aria-label="next"
|
|
221
221
|
onClick={slideNext}
|
|
222
222
|
icon={<RightArrowIcon />}
|
|
223
223
|
/>
|
|
@@ -8,7 +8,7 @@ describe('IconButton', () => {
|
|
|
8
8
|
|
|
9
9
|
it('data-store-icon-button is present', () => {
|
|
10
10
|
const { getByTestId } = render(
|
|
11
|
-
<IconButton testId={testId} icon={<div>foo</div>} />
|
|
11
|
+
<IconButton testId={testId} aria-label="foo" icon={<div>foo</div>} />
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
const iconButton = getByTestId(testId)
|
|
@@ -19,7 +19,11 @@ describe('IconButton', () => {
|
|
|
19
19
|
|
|
20
20
|
it('icon is present', () => {
|
|
21
21
|
const { getByTestId } = render(
|
|
22
|
-
<IconButton
|
|
22
|
+
<IconButton
|
|
23
|
+
testId={testId}
|
|
24
|
+
aria-label="foo"
|
|
25
|
+
icon={<div data-testid="icon">foo</div>}
|
|
26
|
+
/>
|
|
23
27
|
)
|
|
24
28
|
|
|
25
29
|
expect(getByTestId('icon')).toBeInTheDocument()
|
|
@@ -5,7 +5,7 @@ import Button from '../../atoms/Button'
|
|
|
5
5
|
import type { ButtonProps } from '../../atoms/Button'
|
|
6
6
|
import Icon from '../../atoms/Icon'
|
|
7
7
|
|
|
8
|
-
export interface Props extends Omit<ButtonProps, 'children'> {
|
|
8
|
+
export interface Props extends Omit<ButtonProps, 'children' | 'aria-label'> {
|
|
9
9
|
/**
|
|
10
10
|
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
11
11
|
*/
|
|
@@ -14,6 +14,11 @@ export interface Props extends Omit<ButtonProps, 'children'> {
|
|
|
14
14
|
* A React component that will be rendered as an icon.
|
|
15
15
|
*/
|
|
16
16
|
icon: ReactNode
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Label to be required for accessibility.
|
|
20
|
+
*/
|
|
21
|
+
'aria-label': string
|
|
17
22
|
}
|
|
18
23
|
|
|
19
24
|
const IconButton = forwardRef<HTMLButtonElement, Props>(function IconButton(
|
|
@@ -7,14 +7,19 @@ import ShoppingCartIcon from '../../../atoms/Icon/stories/assets/ShoppingCart'
|
|
|
7
7
|
import mdx from './IconButton.mdx'
|
|
8
8
|
|
|
9
9
|
const IconButtonTemplate: Story<IconButtonProps> = (props) => (
|
|
10
|
-
<Component {...props} icon={<ShoppingCartIcon />} />
|
|
10
|
+
<Component {...props} icon={<ShoppingCartIcon />} aria-label="Buy" />
|
|
11
11
|
)
|
|
12
12
|
|
|
13
13
|
export const Default = IconButtonTemplate.bind({})
|
|
14
14
|
|
|
15
15
|
const IconButtonCustomTemplate: Story<IconButtonProps> = (props) => {
|
|
16
16
|
return (
|
|
17
|
-
<Component
|
|
17
|
+
<Component
|
|
18
|
+
{...props}
|
|
19
|
+
className="iconButton"
|
|
20
|
+
icon={<ShoppingCartIcon />}
|
|
21
|
+
aria-label="Buy"
|
|
22
|
+
/>
|
|
18
23
|
)
|
|
19
24
|
}
|
|
20
25
|
|
|
@@ -58,16 +58,16 @@ const PriceRange = ({
|
|
|
58
58
|
onChange={handleChange}
|
|
59
59
|
aria-label={ariaLabel}
|
|
60
60
|
/>
|
|
61
|
-
<div data-
|
|
61
|
+
<div data-price-range-values>
|
|
62
62
|
<Price
|
|
63
63
|
formatter={formatter}
|
|
64
|
-
data-
|
|
64
|
+
data-price-range-value="min"
|
|
65
65
|
value={minVal}
|
|
66
66
|
variant={variant}
|
|
67
67
|
/>
|
|
68
68
|
<Price
|
|
69
69
|
formatter={formatter}
|
|
70
|
-
data-
|
|
70
|
+
data-price-range-value="max"
|
|
71
71
|
value={maxVal}
|
|
72
72
|
variant={variant}
|
|
73
73
|
/>
|
|
@@ -17,9 +17,9 @@ import PriceRange from '../PriceRange'
|
|
|
17
17
|
```css
|
|
18
18
|
[data-store-price-range] {
|
|
19
19
|
}
|
|
20
|
-
[data-
|
|
20
|
+
[data-price-range-values] {
|
|
21
21
|
}
|
|
22
|
-
[data-
|
|
22
|
+
[data-price-range-value='(min|max)'] {
|
|
23
23
|
}
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -16,7 +16,7 @@ export interface QuantitySelectorProps
|
|
|
16
16
|
/**
|
|
17
17
|
* Object with properties that will be passed forward the inner IconButton atom at the left of the input.
|
|
18
18
|
*/
|
|
19
|
-
leftButtonProps: IconButtonProps
|
|
19
|
+
leftButtonProps: Omit<IconButtonProps, 'aria-label'>
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Object with properties that will be passed forward the inner Input atom between the two buttons.
|
|
@@ -26,7 +26,7 @@ export interface QuantitySelectorProps
|
|
|
26
26
|
/**
|
|
27
27
|
* Object with properties that will be passed forward the inner IconButton atom at the right of the input.
|
|
28
28
|
*/
|
|
29
|
-
rightButtonProps: IconButtonProps
|
|
29
|
+
rightButtonProps: Omit<IconButtonProps, 'aria-label'>
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
@@ -45,21 +45,21 @@ describe('Table', () => {
|
|
|
45
45
|
|
|
46
46
|
const tableHead = getByTestId('store-table-head')
|
|
47
47
|
|
|
48
|
-
expect(tableHead).toHaveAttribute('data-
|
|
48
|
+
expect(tableHead).toHaveAttribute('data-table-head')
|
|
49
49
|
|
|
50
50
|
const tableBody = getByTestId('store-table-body')
|
|
51
51
|
|
|
52
|
-
expect(tableBody).toHaveAttribute('data-
|
|
52
|
+
expect(tableBody).toHaveAttribute('data-table-body')
|
|
53
53
|
|
|
54
54
|
const tableFooter = getByTestId('store-table-footer')
|
|
55
55
|
|
|
56
|
-
expect(tableFooter).toHaveAttribute('data-
|
|
56
|
+
expect(tableFooter).toHaveAttribute('data-table-footer')
|
|
57
57
|
|
|
58
58
|
const tableRows = queryAllByTestId('store-table-row')
|
|
59
59
|
|
|
60
60
|
expect(tableRows).toHaveLength(4)
|
|
61
61
|
tableRows.forEach((row) => {
|
|
62
|
-
expect(row).toHaveAttribute('data-
|
|
62
|
+
expect(row).toHaveAttribute('data-table-row')
|
|
63
63
|
})
|
|
64
64
|
|
|
65
65
|
const tableCells = queryAllByTestId('store-table-cell')
|
|
@@ -68,17 +68,13 @@ describe('Table', () => {
|
|
|
68
68
|
// data-store-table-cell attribute.
|
|
69
69
|
expect(tableCells).toHaveLength(8)
|
|
70
70
|
tableCells.forEach((row) => {
|
|
71
|
-
expect(row).toHaveAttribute('data-
|
|
71
|
+
expect(row).toHaveAttribute('data-table-cell')
|
|
72
72
|
})
|
|
73
73
|
|
|
74
74
|
// Make sure that 2 header cells and 6 data cells were rendered, with their
|
|
75
75
|
// corresponding attributes.
|
|
76
|
-
expect(
|
|
77
|
-
|
|
78
|
-
).toHaveLength(2)
|
|
79
|
-
expect(
|
|
80
|
-
table.querySelectorAll('[data-store-table-cell=data]')
|
|
81
|
-
).toHaveLength(6)
|
|
76
|
+
expect(table.querySelectorAll('[data-table-cell=header]')).toHaveLength(2)
|
|
77
|
+
expect(table.querySelectorAll('[data-table-cell=data]')).toHaveLength(6)
|
|
82
78
|
})
|
|
83
79
|
})
|
|
84
80
|
|
|
@@ -16,12 +16,7 @@ const TableBody = forwardRef<HTMLTableSectionElement, TableBodyProps>(
|
|
|
16
16
|
ref
|
|
17
17
|
) {
|
|
18
18
|
return (
|
|
19
|
-
<tbody
|
|
20
|
-
ref={ref}
|
|
21
|
-
data-testid={testId}
|
|
22
|
-
data-store-table-body
|
|
23
|
-
{...otherProps}
|
|
24
|
-
>
|
|
19
|
+
<tbody ref={ref} data-testid={testId} data-table-body {...otherProps}>
|
|
25
20
|
{children}
|
|
26
21
|
</tbody>
|
|
27
22
|
)
|