agroptima-design-system 0.16.2 → 0.17.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/atoms/Card/Card.scss +5 -9
- package/src/atoms/Card/Card.tsx +5 -2
- package/src/atoms/CardMenu/CardMenu.scss +14 -1
- package/src/atoms/CardMenu/CardMenuOption.tsx +17 -7
- package/src/atoms/QuantitySelector.scss +97 -0
- package/src/atoms/QuantitySelector.tsx +54 -0
- package/src/icons/index.tsx +2 -0
- package/src/icons/minus.svg +1 -0
- package/src/stories/Card.stories.js +27 -3
- package/src/stories/CardMenu.stories.js +40 -11
- package/src/stories/Changelog.stories.mdx +7 -0
- package/src/stories/QuantitySelector.stories.ts +113 -0
- package/tests/CardMenuOption.spec.tsx +2 -1
- package/tests/QuantitySelector.spec.tsx +44 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agroptima-design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1-beta.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "npm run storybook",
|
|
6
6
|
"storybook": "storybook dev -p 6006 --ci",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"lint:fix": "eslint src --fix",
|
|
11
11
|
"types": "tsc --noEmit",
|
|
12
12
|
"chromatic": "npx chromatic --exit-zero-on-changes",
|
|
13
|
-
"test": "jest"
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"publish:beta": "npm publish --tag beta"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@storybook/addon-designs": "^7.0.5",
|
package/src/atoms/Card/Card.scss
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
flex-direction: column;
|
|
9
9
|
gap: config.$space-1x;
|
|
10
10
|
padding: config.$space-3x;
|
|
11
|
+
width: 100%;
|
|
11
12
|
|
|
12
13
|
p {
|
|
13
14
|
margin: 0;
|
|
@@ -57,15 +58,10 @@
|
|
|
57
58
|
@include typography.body-regular-disabled;
|
|
58
59
|
background: color_alias.$neutral-color-50;
|
|
59
60
|
}
|
|
60
|
-
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
// Tablet & Desktop cases
|
|
68
|
-
@media only screen and (min-width: breakpoints.$medium) {
|
|
69
|
-
width: 18.625rem;
|
|
62
|
+
&.active {
|
|
63
|
+
border: 1px solid color_alias.$primary-color-1000;
|
|
64
|
+
box-shadow: none;
|
|
65
|
+
}
|
|
70
66
|
}
|
|
71
67
|
}
|
package/src/atoms/Card/Card.tsx
CHANGED
|
@@ -7,22 +7,25 @@ export type Variant = 'primary'
|
|
|
7
7
|
export interface CardProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
8
8
|
variant?: Variant
|
|
9
9
|
isDisabled?: boolean
|
|
10
|
+
isActive?: boolean
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export function Card({
|
|
13
14
|
className,
|
|
14
15
|
variant = 'primary',
|
|
15
16
|
isDisabled = false,
|
|
17
|
+
isActive = false,
|
|
16
18
|
children,
|
|
17
19
|
...props
|
|
18
20
|
}: CardProps): React.JSX.Element {
|
|
19
21
|
const cssClasses = classNames('card', className, variant, {
|
|
20
22
|
disabled: isDisabled,
|
|
23
|
+
active: isActive,
|
|
21
24
|
})
|
|
22
25
|
|
|
23
26
|
return (
|
|
24
|
-
<
|
|
27
|
+
<article className={cssClasses} {...props}>
|
|
25
28
|
{children}
|
|
26
|
-
</
|
|
29
|
+
</article>
|
|
27
30
|
)
|
|
28
31
|
}
|
|
@@ -13,12 +13,16 @@
|
|
|
13
13
|
gap: config.$space-3x;
|
|
14
14
|
border-radius: config.$corner-radius-xxs;
|
|
15
15
|
border-bottom: 1px solid color_alias.$neutral-color-200;
|
|
16
|
+
text-decoration: none;
|
|
16
17
|
cursor: default;
|
|
17
|
-
|
|
18
|
+
&:hover {
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
}
|
|
18
21
|
@include typography.body-regular-primary;
|
|
19
22
|
|
|
20
23
|
.icon {
|
|
21
24
|
width: config.$icon-size-4x;
|
|
25
|
+
min-width: config.$icon-size-4x;
|
|
22
26
|
height: config.$icon-size-4x;
|
|
23
27
|
> svg {
|
|
24
28
|
width: 100%;
|
|
@@ -54,6 +58,15 @@
|
|
|
54
58
|
&.primary {
|
|
55
59
|
background: color_alias.$neutral-white;
|
|
56
60
|
|
|
61
|
+
&.active {
|
|
62
|
+
background-color: color_alias.$primary-color-50;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
&.error {
|
|
66
|
+
border: 1px solid color_alias.$error-color-600;
|
|
67
|
+
background-color: color_alias.$error-color-50;
|
|
68
|
+
}
|
|
69
|
+
|
|
57
70
|
.icon {
|
|
58
71
|
> svg {
|
|
59
72
|
fill: color_alias.$primary-color-600;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { Icon, IconType } from '../Icon'
|
|
2
2
|
import './CardMenu.scss'
|
|
3
3
|
import { classNames } from '../../utils/classNames'
|
|
4
|
+
import Link, { LinkProps as NextLinkProps } from 'next/link'
|
|
4
5
|
|
|
5
6
|
export type Variant = 'primary'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
type LinkProps = NextLinkProps & React.AnchorHTMLAttributes<HTMLAnchorElement>
|
|
9
|
+
export interface CardMenuOptionProps extends LinkProps {
|
|
9
10
|
id?: string
|
|
10
11
|
variant?: Variant
|
|
11
12
|
icon: IconType
|
|
12
13
|
title: string
|
|
13
14
|
description?: string
|
|
14
15
|
disabled?: boolean
|
|
16
|
+
href: string
|
|
17
|
+
active?: boolean
|
|
18
|
+
error?: boolean
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export function CardMenuOption({
|
|
@@ -22,29 +26,35 @@ export function CardMenuOption({
|
|
|
22
26
|
title,
|
|
23
27
|
description,
|
|
24
28
|
disabled,
|
|
29
|
+
href,
|
|
30
|
+
active,
|
|
31
|
+
error,
|
|
25
32
|
...props
|
|
26
33
|
}: CardMenuOptionProps): React.JSX.Element {
|
|
27
34
|
const cssClasses = classNames('card-menu-option', variant, className, {
|
|
28
|
-
disabled
|
|
35
|
+
disabled,
|
|
36
|
+
active,
|
|
37
|
+
error,
|
|
29
38
|
})
|
|
30
39
|
|
|
31
40
|
return (
|
|
32
|
-
<
|
|
41
|
+
<Link
|
|
33
42
|
role="menuitem"
|
|
34
43
|
className={cssClasses}
|
|
35
|
-
{
|
|
44
|
+
href={disabled ? '#' : href}
|
|
36
45
|
aria-disabled={disabled}
|
|
46
|
+
{...props}
|
|
37
47
|
>
|
|
38
48
|
<div className="left">
|
|
39
49
|
<div className="title-container">
|
|
40
50
|
<Icon name={icon} className={variant} />
|
|
41
51
|
<span className="title">{title}</span>
|
|
42
52
|
</div>
|
|
43
|
-
<p className="content">{description}</p>
|
|
53
|
+
{description && <p className="content">{description}</p>}
|
|
44
54
|
</div>
|
|
45
55
|
<div className="right">
|
|
46
56
|
<Icon name="AngleRight" className={variant} />
|
|
47
57
|
</div>
|
|
48
|
-
</
|
|
58
|
+
</Link>
|
|
49
59
|
)
|
|
50
60
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@use '../settings/color_alias';
|
|
2
|
+
@use '../settings/typography/form' as form-typography;
|
|
3
|
+
@use '../settings/typography/content' as typography;
|
|
4
|
+
@use '../settings/config';
|
|
5
|
+
|
|
6
|
+
.quantity-selector-group {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: config.$space-2x;
|
|
10
|
+
|
|
11
|
+
.quantity-selector {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
|
|
15
|
+
.input-group {
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.primary {
|
|
21
|
+
.quantity-selector {
|
|
22
|
+
.input-container {
|
|
23
|
+
// Remove default arrows
|
|
24
|
+
/* Chrome, Safari, Edge, Opera */
|
|
25
|
+
input::-webkit-outer-spin-button,
|
|
26
|
+
input::-webkit-inner-spin-button {
|
|
27
|
+
-webkit-appearance: none;
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Firefox */
|
|
32
|
+
input[type='number'] {
|
|
33
|
+
-moz-appearance: textfield;
|
|
34
|
+
}
|
|
35
|
+
.input {
|
|
36
|
+
border-radius: 0;
|
|
37
|
+
border-right: 0;
|
|
38
|
+
border-left: 0;
|
|
39
|
+
background: color_alias.$neutral-white;
|
|
40
|
+
text-align: center;
|
|
41
|
+
|
|
42
|
+
@include form-typography.input-text;
|
|
43
|
+
|
|
44
|
+
&::placeholder {
|
|
45
|
+
@include form-typography.input-placeholder-text;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&:focus {
|
|
49
|
+
outline: color_alias.$primary-color-600;
|
|
50
|
+
border: 1px solid color_alias.$primary-color-600;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&:disabled {
|
|
54
|
+
border: 1px solid color_alias.$neutral-color-400;
|
|
55
|
+
background: color_alias.$neutral-color-50;
|
|
56
|
+
color: color_alias.$neutral-color-400;
|
|
57
|
+
|
|
58
|
+
&::placeholder {
|
|
59
|
+
color: color_alias.$neutral-color-400;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
.button {
|
|
65
|
+
@include typography.body-regular-primary;
|
|
66
|
+
color: color_alias.$neutral-white;
|
|
67
|
+
height: 42px;
|
|
68
|
+
|
|
69
|
+
&:disabled {
|
|
70
|
+
border: 1px solid color_alias.$neutral-color-400;
|
|
71
|
+
color: color_alias.$neutral-color-400;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
.decrement-button {
|
|
75
|
+
border-top-right-radius: 0;
|
|
76
|
+
border-bottom-right-radius: 0;
|
|
77
|
+
|
|
78
|
+
&:disabled {
|
|
79
|
+
border-right: 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.increment-button {
|
|
84
|
+
border-top-left-radius: 0;
|
|
85
|
+
border-bottom-left-radius: 0;
|
|
86
|
+
|
|
87
|
+
&:disabled {
|
|
88
|
+
border-left: 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.quantity-selector-label {
|
|
94
|
+
@include form-typography.form-label;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Icon } from './Icon'
|
|
3
|
+
import { classNames } from '../utils/classNames'
|
|
4
|
+
import './QuantitySelector.scss'
|
|
5
|
+
import { Input, InputProps } from './Input'
|
|
6
|
+
import { Button, ButtonProps } from './Button'
|
|
7
|
+
|
|
8
|
+
export type Variant = 'primary'
|
|
9
|
+
|
|
10
|
+
export interface QuantitySelectorProps
|
|
11
|
+
extends React.ComponentPropsWithoutRef<'div'> {
|
|
12
|
+
label: string
|
|
13
|
+
accessibilityLabel?: string
|
|
14
|
+
hideLabel?: boolean
|
|
15
|
+
id?: string
|
|
16
|
+
variant?: Variant
|
|
17
|
+
decrementButton: ButtonProps
|
|
18
|
+
incrementButton: ButtonProps
|
|
19
|
+
quantityInput: InputProps
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function QuantitySelector({
|
|
23
|
+
decrementButton,
|
|
24
|
+
incrementButton,
|
|
25
|
+
quantityInput,
|
|
26
|
+
label,
|
|
27
|
+
accessibilityLabel,
|
|
28
|
+
id,
|
|
29
|
+
className,
|
|
30
|
+
hideLabel = false,
|
|
31
|
+
variant = 'primary',
|
|
32
|
+
...props
|
|
33
|
+
}: QuantitySelectorProps): React.JSX.Element {
|
|
34
|
+
const cssClasses = classNames('quantity-selector', className)
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className={`quantity-selector-group ${variant}`} {...props}>
|
|
38
|
+
{!hideLabel && (
|
|
39
|
+
<label className="quantity-selector-label" htmlFor={id}>
|
|
40
|
+
{label}
|
|
41
|
+
</label>
|
|
42
|
+
)}
|
|
43
|
+
<div className={cssClasses}>
|
|
44
|
+
<Button className="decrement-button" {...decrementButton} />
|
|
45
|
+
<Input
|
|
46
|
+
{...quantityInput}
|
|
47
|
+
label={label}
|
|
48
|
+
accessibilityLabel={accessibilityLabel}
|
|
49
|
+
/>
|
|
50
|
+
<Button className="increment-button" {...incrementButton} />
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
)
|
|
54
|
+
}
|
package/src/icons/index.tsx
CHANGED
|
@@ -25,6 +25,7 @@ import Import from './import.svg'
|
|
|
25
25
|
import Info from './info.svg'
|
|
26
26
|
import Loading from './loading.svg'
|
|
27
27
|
import Logout from './logout.svg'
|
|
28
|
+
import Minus from './minus.svg'
|
|
28
29
|
import Product from './product.svg'
|
|
29
30
|
import Salesman from './salesman.svg'
|
|
30
31
|
import Search from './search.svg'
|
|
@@ -62,6 +63,7 @@ export {
|
|
|
62
63
|
Info,
|
|
63
64
|
Loading,
|
|
64
65
|
Logout,
|
|
66
|
+
Minus,
|
|
65
67
|
Product,
|
|
66
68
|
Salesman,
|
|
67
69
|
Search,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 11H0V8h20v3Z" fill="#444"/></svg>
|
|
@@ -399,7 +399,13 @@ export const Primary = {
|
|
|
399
399
|
/>
|
|
400
400
|
</CardHeader>
|
|
401
401
|
<CardContent>
|
|
402
|
-
<p>
|
|
402
|
+
<p>
|
|
403
|
+
TEKKEN 8 will feature exciting new gameplay focused on “Aggressive”
|
|
404
|
+
tactics. Retaining TEKKEN's unique fighting game identity, the game
|
|
405
|
+
will provide both players and spectators with the series' most
|
|
406
|
+
thrilling experience yet with visceral screen-jarring attacks and
|
|
407
|
+
environments that are both dynamic and destructible.
|
|
408
|
+
</p>
|
|
403
409
|
</CardContent>
|
|
404
410
|
<CardFooter>
|
|
405
411
|
<Button variant="primary-outlined" label="Add to wishlist" />
|
|
@@ -412,12 +418,18 @@ export const Primary = {
|
|
|
412
418
|
export const Disabled = {
|
|
413
419
|
render: () => (
|
|
414
420
|
<div style={{ display: 'flex' }}>
|
|
415
|
-
<Card isDisabled
|
|
421
|
+
<Card isDisabled variant="primary">
|
|
416
422
|
<CardHeader title="Tekken 8">
|
|
417
423
|
<IconButton disabled icon="Delete" accessibilityLabel="Delete game" />
|
|
418
424
|
</CardHeader>
|
|
419
425
|
<CardContent>
|
|
420
|
-
<p>
|
|
426
|
+
<p>
|
|
427
|
+
TEKKEN 8 will feature exciting new gameplay focused on “Aggressive”
|
|
428
|
+
tactics. Retaining TEKKEN's unique fighting game identity, the game
|
|
429
|
+
will provide both players and spectators with the series' most
|
|
430
|
+
thrilling experience yet with visceral screen-jarring attacks and
|
|
431
|
+
environments that are both dynamic and destructible.
|
|
432
|
+
</p>
|
|
421
433
|
</CardContent>
|
|
422
434
|
<CardFooter>
|
|
423
435
|
<Button variant="primary-outlined" disabled label="Add to wishlist" />
|
|
@@ -426,3 +438,15 @@ export const Disabled = {
|
|
|
426
438
|
</div>
|
|
427
439
|
),
|
|
428
440
|
}
|
|
441
|
+
|
|
442
|
+
export const Active = {
|
|
443
|
+
render: () => (
|
|
444
|
+
<div style={{ display: 'flex' }}>
|
|
445
|
+
<Card isActive>
|
|
446
|
+
<CardHeader title="Fallout 3">
|
|
447
|
+
<IconButton icon="Delete" accessibilityLabel="Delete game" />
|
|
448
|
+
</CardHeader>
|
|
449
|
+
</Card>
|
|
450
|
+
</div>
|
|
451
|
+
),
|
|
452
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
3
|
import { CardMenu, CardMenuOption } from '../atoms/CardMenu'
|
|
4
|
+
import { isErrored } from 'stream'
|
|
4
5
|
|
|
5
6
|
const figmaPrimaryDesign = {
|
|
6
7
|
design: {
|
|
@@ -29,11 +30,14 @@ const meta = {
|
|
|
29
30
|
description: {
|
|
30
31
|
description: 'Component description text',
|
|
31
32
|
},
|
|
32
|
-
|
|
33
|
+
disabled: {
|
|
33
34
|
description: 'Is the component disabled?',
|
|
34
35
|
},
|
|
35
|
-
|
|
36
|
-
description: '
|
|
36
|
+
active: {
|
|
37
|
+
description: 'Is the component active?',
|
|
38
|
+
},
|
|
39
|
+
error: {
|
|
40
|
+
description: 'Is the component error?',
|
|
37
41
|
},
|
|
38
42
|
},
|
|
39
43
|
parameters: figmaPrimaryDesign,
|
|
@@ -45,12 +49,11 @@ export const Option = {
|
|
|
45
49
|
render: () => (
|
|
46
50
|
<CardMenuOption
|
|
47
51
|
id="first-menu-option"
|
|
52
|
+
href="#"
|
|
48
53
|
icon="Info"
|
|
49
54
|
variant="primary"
|
|
50
55
|
title="It's dangerous to go alone!"
|
|
51
56
|
description="Take this 🗡️ and this 🛡️ and this 💣 and this 🏹 and this 🔪 and this 🐴 and this 🔫 and this 🔪"
|
|
52
|
-
isDisabled={false}
|
|
53
|
-
onClick={() => alert('click')}
|
|
54
57
|
/>
|
|
55
58
|
),
|
|
56
59
|
}
|
|
@@ -59,6 +62,7 @@ export const DisabledOption = {
|
|
|
59
62
|
render: () => (
|
|
60
63
|
<CardMenuOption
|
|
61
64
|
id="first-menu-option"
|
|
65
|
+
href="#"
|
|
62
66
|
icon="Info"
|
|
63
67
|
variant="primary"
|
|
64
68
|
title="It's dangerous to go alone!"
|
|
@@ -68,35 +72,60 @@ export const DisabledOption = {
|
|
|
68
72
|
),
|
|
69
73
|
}
|
|
70
74
|
|
|
75
|
+
export const ActiveOption = {
|
|
76
|
+
render: () => (
|
|
77
|
+
<CardMenuOption
|
|
78
|
+
id="first-menu-option"
|
|
79
|
+
href="#"
|
|
80
|
+
icon="Info"
|
|
81
|
+
variant="primary"
|
|
82
|
+
title="It's dangerous to go alone!"
|
|
83
|
+
description="Take this 🗡️"
|
|
84
|
+
active
|
|
85
|
+
/>
|
|
86
|
+
),
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const ErrorOption = {
|
|
90
|
+
render: () => (
|
|
91
|
+
<CardMenuOption
|
|
92
|
+
id="first-menu-option"
|
|
93
|
+
href="#"
|
|
94
|
+
icon="Info"
|
|
95
|
+
variant="primary"
|
|
96
|
+
title="It's dangerous to go alone!"
|
|
97
|
+
description="Take this 🗡️"
|
|
98
|
+
error
|
|
99
|
+
/>
|
|
100
|
+
),
|
|
101
|
+
}
|
|
102
|
+
|
|
71
103
|
export const Menu = {
|
|
72
104
|
render: () => (
|
|
73
105
|
<CardMenu>
|
|
74
106
|
<CardMenuOption
|
|
75
107
|
id="first-menu-option"
|
|
108
|
+
href="#"
|
|
76
109
|
icon="AddCircle"
|
|
77
110
|
variant="primary"
|
|
78
111
|
title="Title"
|
|
79
112
|
description="Name of the videogame"
|
|
80
|
-
isDisabled={false}
|
|
81
|
-
onClick={() => alert('click title')}
|
|
82
113
|
/>
|
|
83
114
|
<CardMenuOption
|
|
84
115
|
id="second-menu-option"
|
|
116
|
+
href="#"
|
|
85
117
|
icon="Edit"
|
|
86
118
|
variant="primary"
|
|
87
119
|
title="Address"
|
|
88
120
|
description="Videogame company address"
|
|
89
|
-
isDisabled={false}
|
|
90
|
-
onClick={() => alert('click address')}
|
|
91
121
|
/>
|
|
92
122
|
<CardMenuOption
|
|
93
123
|
id="third-menu-option"
|
|
124
|
+
href="#"
|
|
94
125
|
icon="Info"
|
|
95
126
|
variant="primary"
|
|
96
127
|
title="Email"
|
|
97
128
|
description="Videogame company email"
|
|
98
|
-
isDisabled={false}
|
|
99
|
-
onClick={() => alert('click email')}
|
|
100
129
|
/>
|
|
101
130
|
</CardMenu>
|
|
102
131
|
),
|
|
@@ -3,6 +3,13 @@ import { Meta } from "@storybook/addon-docs";
|
|
|
3
3
|
<Meta title="Changelog" />
|
|
4
4
|
# Changelog
|
|
5
5
|
|
|
6
|
+
## Beta
|
|
7
|
+
- Add link to CardMenuOption component
|
|
8
|
+
- Add active and error state to CardMenuOption component
|
|
9
|
+
|
|
10
|
+
## 0.17.0
|
|
11
|
+
- Added QuantitySelector component to Storybook
|
|
12
|
+
|
|
6
13
|
## 0.16.2
|
|
7
14
|
- Fixed some icons missing ViewBox
|
|
8
15
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { QuantitySelector } from '../atoms/QuantitySelector'
|
|
2
|
+
import { StoryObj } from '@storybook/react'
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Atoms/QuantitySelector',
|
|
6
|
+
component: QuantitySelector,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
label: {
|
|
10
|
+
description: 'Label for the component',
|
|
11
|
+
},
|
|
12
|
+
accessibilityLabel: {
|
|
13
|
+
description:
|
|
14
|
+
'Describes the component purpose. If empty, label content will be used',
|
|
15
|
+
},
|
|
16
|
+
variant: {
|
|
17
|
+
description: 'Component variant used',
|
|
18
|
+
},
|
|
19
|
+
disabled: {
|
|
20
|
+
description: 'Is the input in disabled state?',
|
|
21
|
+
},
|
|
22
|
+
name: {
|
|
23
|
+
description: 'Component name property',
|
|
24
|
+
},
|
|
25
|
+
id: {
|
|
26
|
+
description: 'Value needed for the label relation',
|
|
27
|
+
},
|
|
28
|
+
decrementButton: {
|
|
29
|
+
description: 'Button component props for decrementButton',
|
|
30
|
+
},
|
|
31
|
+
incrementButton: {
|
|
32
|
+
description: 'Button component props for incrementButton',
|
|
33
|
+
},
|
|
34
|
+
quantityInput: {
|
|
35
|
+
description: 'Input component props for quantityInput',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const figmaPrimaryDesign = {
|
|
41
|
+
design: {
|
|
42
|
+
type: 'figma',
|
|
43
|
+
url: 'https://www.figma.com/design/DN2ova21vWqCRvPspBXgI1/Design-System?node-id=2701-275&m=dev',
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default meta
|
|
48
|
+
type Story = StoryObj<typeof meta>
|
|
49
|
+
|
|
50
|
+
export const Primary: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
label: 'Quantity',
|
|
53
|
+
accessibilityLabel: 'Quantity of items to wishlist',
|
|
54
|
+
id: 'quantity-selector',
|
|
55
|
+
decrementButton: {
|
|
56
|
+
label: '',
|
|
57
|
+
leftIcon: 'Minus',
|
|
58
|
+
onClick: () => alert('decrement'),
|
|
59
|
+
},
|
|
60
|
+
incrementButton: {
|
|
61
|
+
label: '',
|
|
62
|
+
leftIcon: 'Add',
|
|
63
|
+
onClick: () => alert('increment'),
|
|
64
|
+
},
|
|
65
|
+
quantityInput: {
|
|
66
|
+
label: 'Quantity input',
|
|
67
|
+
hideLabel: true,
|
|
68
|
+
name: 'quantity',
|
|
69
|
+
value: 1,
|
|
70
|
+
onChange: () => alert('onChange'),
|
|
71
|
+
type: 'number',
|
|
72
|
+
max: 10,
|
|
73
|
+
step: 0.0001,
|
|
74
|
+
min: 1,
|
|
75
|
+
required: true,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
parameters: figmaPrimaryDesign,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const Disabled: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
label: 'Quantity',
|
|
84
|
+
accessibilityLabel: 'Quantity of items to wishlist',
|
|
85
|
+
id: 'quantity-selector',
|
|
86
|
+
decrementButton: {
|
|
87
|
+
label: '',
|
|
88
|
+
leftIcon: 'Minus',
|
|
89
|
+
onClick: () => alert('decrement'),
|
|
90
|
+
disabled: true,
|
|
91
|
+
},
|
|
92
|
+
incrementButton: {
|
|
93
|
+
label: '',
|
|
94
|
+
leftIcon: 'Add',
|
|
95
|
+
onClick: () => alert('increment'),
|
|
96
|
+
disabled: true,
|
|
97
|
+
},
|
|
98
|
+
quantityInput: {
|
|
99
|
+
label: 'Quantity input',
|
|
100
|
+
hideLabel: true,
|
|
101
|
+
name: 'quantity',
|
|
102
|
+
value: 1,
|
|
103
|
+
onChange: () => alert('onChange'),
|
|
104
|
+
type: 'number',
|
|
105
|
+
max: 10,
|
|
106
|
+
step: 0.0001,
|
|
107
|
+
min: 1,
|
|
108
|
+
required: true,
|
|
109
|
+
disabled: true,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
parameters: figmaPrimaryDesign,
|
|
113
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
3
|
import { CardMenuOption } from '@/atoms/CardMenu/CardMenuOption'
|
|
4
4
|
|
|
5
5
|
describe('CardMenuOption', () => {
|
|
@@ -7,6 +7,7 @@ describe('CardMenuOption', () => {
|
|
|
7
7
|
const { getByRole, getByText, getAllByRole } = render(
|
|
8
8
|
<CardMenuOption
|
|
9
9
|
id="option-one"
|
|
10
|
+
href="#"
|
|
10
11
|
icon="Info"
|
|
11
12
|
title="It's dangerous to go alone!"
|
|
12
13
|
description="Take this sword!"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { screen, render } from '@testing-library/react'
|
|
3
|
+
import { QuantitySelector } from '@/atoms/QuantitySelector'
|
|
4
|
+
|
|
5
|
+
describe('QuantitySelector', () => {
|
|
6
|
+
it('renders', () => {
|
|
7
|
+
const { getByRole, getByText, getAllByRole } = render(
|
|
8
|
+
<QuantitySelector
|
|
9
|
+
label="Quantity"
|
|
10
|
+
accessibilityLabel="Quantity of items to wishlist"
|
|
11
|
+
id="quantity-selector"
|
|
12
|
+
decrementButton={{
|
|
13
|
+
label: '-',
|
|
14
|
+
onClick: () => alert('decrement'),
|
|
15
|
+
}}
|
|
16
|
+
incrementButton={{
|
|
17
|
+
label: '+',
|
|
18
|
+
onClick: () => alert('increment'),
|
|
19
|
+
}}
|
|
20
|
+
quantityInput={{
|
|
21
|
+
label: 'Quantity input',
|
|
22
|
+
hideLabel: true,
|
|
23
|
+
name: 'quantity',
|
|
24
|
+
value: 1,
|
|
25
|
+
onChange: () => alert('onChange'),
|
|
26
|
+
type: 'number',
|
|
27
|
+
max: 10,
|
|
28
|
+
step: 0.0001,
|
|
29
|
+
min: 1,
|
|
30
|
+
required: true,
|
|
31
|
+
}}
|
|
32
|
+
/>,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
expect(getByText(/Quantity/i)).toBeInTheDocument()
|
|
36
|
+
expect(getAllByRole('button')[0]).toHaveClass(
|
|
37
|
+
`button primary decrement-button`,
|
|
38
|
+
)
|
|
39
|
+
expect(getAllByRole('button')[1]).toHaveClass(
|
|
40
|
+
`button primary increment-button`,
|
|
41
|
+
)
|
|
42
|
+
expect(getByRole('spinbutton')).toHaveValue(1)
|
|
43
|
+
})
|
|
44
|
+
})
|