agroptima-design-system 0.25.7 → 0.26.0-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 +13 -13
- package/src/atoms/Badge.tsx +1 -1
- package/src/atoms/CheckableTag/CheckableTag.scss +47 -0
- package/src/atoms/CheckableTag/CheckableTag.tsx +54 -0
- package/src/atoms/CheckableTag/CheckableTagGroup.tsx +19 -0
- package/src/atoms/CheckableTag/index.ts +4 -0
- package/src/atoms/Form/Form.scss +4 -10
- package/src/atoms/Input.scss +0 -19
- package/src/atoms/Input.tsx +0 -2
- package/src/icons/filter.svg +1 -0
- package/src/icons/index.tsx +2 -0
- package/src/stories/Changelog.mdx +3 -6
- package/src/stories/CheckableTag.stories.js +103 -0
- package/src/stories/Input.stories.ts +0 -12
- package/tests/Badge.spec.tsx +1 -1
- package/tests/CheckableTag.spec.tsx +26 -0
- package/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agroptima-design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0-beta.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "npm run storybook",
|
|
6
6
|
"storybook": "storybook dev -p 6006 --ci",
|
|
@@ -16,23 +16,23 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@storybook/addon-designs": "^8.0.3",
|
|
19
|
-
"@storybook/addon-viewport": "^8.
|
|
19
|
+
"@storybook/addon-viewport": "^8.2.9",
|
|
20
20
|
"next": "^14.0.3",
|
|
21
21
|
"react": "^18.2.0",
|
|
22
22
|
"react-dom": "^18.2.0",
|
|
23
23
|
"sass": "^1.69.4"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@chromatic-com/storybook": "^
|
|
27
|
-
"@storybook/addon-a11y": "^8.
|
|
28
|
-
"@storybook/addon-essentials": "^8.
|
|
29
|
-
"@storybook/addon-interactions": "^8.
|
|
30
|
-
"@storybook/addon-links": "^8.
|
|
31
|
-
"@storybook/addon-mdx-gfm": "^8.
|
|
32
|
-
"@storybook/blocks": "^8.
|
|
33
|
-
"@storybook/nextjs": "^8.
|
|
34
|
-
"@storybook/react": "^8.
|
|
35
|
-
"@storybook/test": "^8.
|
|
26
|
+
"@chromatic-com/storybook": "^1.8.0",
|
|
27
|
+
"@storybook/addon-a11y": "^8.2.9",
|
|
28
|
+
"@storybook/addon-essentials": "^8.2.9",
|
|
29
|
+
"@storybook/addon-interactions": "^8.2.9",
|
|
30
|
+
"@storybook/addon-links": "^8.2.9",
|
|
31
|
+
"@storybook/addon-mdx-gfm": "^8.2.9",
|
|
32
|
+
"@storybook/blocks": "^8.2.9",
|
|
33
|
+
"@storybook/nextjs": "^8.2.9",
|
|
34
|
+
"@storybook/react": "^8.2.9",
|
|
35
|
+
"@storybook/test": "^8.2.9",
|
|
36
36
|
"@svgr/webpack": "^8.1.0",
|
|
37
37
|
"@testing-library/jest-dom": "^6.4.2",
|
|
38
38
|
"@testing-library/react": "^16.0.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"jest": "^29.7.0",
|
|
51
51
|
"jest-axe": "^9.0.0",
|
|
52
52
|
"jest-environment-jsdom": "^29.7.0",
|
|
53
|
-
"storybook": "^8.
|
|
53
|
+
"storybook": "^8.2.9",
|
|
54
54
|
"ts-node": "^10.9.2",
|
|
55
55
|
"typescript": "^5"
|
|
56
56
|
},
|
package/src/atoms/Badge.tsx
CHANGED
|
@@ -11,7 +11,7 @@ export type Variant =
|
|
|
11
11
|
| 'warning-outlined'
|
|
12
12
|
| 'error-outlined'
|
|
13
13
|
|
|
14
|
-
export interface BadgeProps extends React.ComponentPropsWithoutRef<'
|
|
14
|
+
export interface BadgeProps extends React.ComponentPropsWithoutRef<'span'> {
|
|
15
15
|
variant?: Variant
|
|
16
16
|
text: string
|
|
17
17
|
accessibilityLabel: string
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
@use '../../settings/color_alias';
|
|
2
|
+
@use '../../settings/typography/content' as typography;
|
|
3
|
+
@use '../../settings/config';
|
|
4
|
+
@use '../../settings/depth';
|
|
5
|
+
|
|
6
|
+
.checkable-tag-group {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
gap: config.$space-2x;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
|
|
12
|
+
.checkable-tag {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: config.$space-2x;
|
|
16
|
+
padding: config.$space-1x config.$space-3x;
|
|
17
|
+
width: fit-content;
|
|
18
|
+
cursor: default;
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
|
|
21
|
+
&.primary {
|
|
22
|
+
@include typography.footnote-primary;
|
|
23
|
+
color: color_alias.$neutral-color-1000;
|
|
24
|
+
|
|
25
|
+
border-radius: config.$corner-radius-m;
|
|
26
|
+
border: 1px solid color_alias.$neutral-color-200;
|
|
27
|
+
background: color_alias.$neutral-white;
|
|
28
|
+
|
|
29
|
+
&:hover {
|
|
30
|
+
background: color_alias.$neutral-color-50;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.checked {
|
|
34
|
+
color: color_alias.$neutral-white;
|
|
35
|
+
border: 1px solid color_alias.$primary-color-600;
|
|
36
|
+
background: color_alias.$primary-color-600;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.disabled {
|
|
40
|
+
color: color_alias.$neutral-color-200;
|
|
41
|
+
|
|
42
|
+
border: 1px solid color_alias.$neutral-color-200;
|
|
43
|
+
background: color_alias.$neutral-color-50;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { classNames } from '../../utils/classNames'
|
|
2
|
+
import './CheckableTag.scss'
|
|
3
|
+
|
|
4
|
+
export type Variant = 'primary'
|
|
5
|
+
|
|
6
|
+
type CheckableTagPropsWithoutOnChangeOnSelect = Omit<
|
|
7
|
+
React.ComponentPropsWithoutRef<'span'>,
|
|
8
|
+
'onChange' | 'onSelect'
|
|
9
|
+
>
|
|
10
|
+
|
|
11
|
+
export interface CheckableTagProps
|
|
12
|
+
extends CheckableTagPropsWithoutOnChangeOnSelect {
|
|
13
|
+
variant?: Variant
|
|
14
|
+
isDisabled?: boolean
|
|
15
|
+
isChecked?: boolean
|
|
16
|
+
label: string
|
|
17
|
+
onSelect: (label: string) => void
|
|
18
|
+
onChange: (checked: boolean) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function CheckableTag({
|
|
22
|
+
variant = 'primary',
|
|
23
|
+
className,
|
|
24
|
+
isDisabled = false,
|
|
25
|
+
label,
|
|
26
|
+
isChecked = false,
|
|
27
|
+
onSelect,
|
|
28
|
+
onChange,
|
|
29
|
+
...props
|
|
30
|
+
}: CheckableTagProps): React.JSX.Element {
|
|
31
|
+
const cssClasses = classNames('checkable-tag', variant, className, {
|
|
32
|
+
disabled: isDisabled,
|
|
33
|
+
checked: isChecked,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
function handleClick() {
|
|
37
|
+
onChange(!isChecked)
|
|
38
|
+
onSelect(label)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<span
|
|
43
|
+
className={cssClasses}
|
|
44
|
+
role="checkbox"
|
|
45
|
+
aria-checked={false}
|
|
46
|
+
tabIndex={0}
|
|
47
|
+
aria-label={props['aria-label']}
|
|
48
|
+
onClick={handleClick}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
{label}
|
|
52
|
+
</span>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { classNames } from '../../utils/classNames'
|
|
2
|
+
import './CheckableTag.scss'
|
|
3
|
+
|
|
4
|
+
export interface CheckableTagGroupProps
|
|
5
|
+
extends React.ComponentPropsWithoutRef<'div'> {}
|
|
6
|
+
|
|
7
|
+
export function CheckableTagGroup({
|
|
8
|
+
className,
|
|
9
|
+
children,
|
|
10
|
+
...props
|
|
11
|
+
}: CheckableTagGroupProps): React.JSX.Element {
|
|
12
|
+
const cssClasses = classNames('checkable-tag-group', className)
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<div className={cssClasses} {...props}>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
)
|
|
19
|
+
}
|
package/src/atoms/Form/Form.scss
CHANGED
|
@@ -44,17 +44,11 @@
|
|
|
44
44
|
padding-bottom: 9rem;
|
|
45
45
|
}
|
|
46
46
|
.actions {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
flex-direction: row;
|
|
50
|
-
justify-content: space-between;
|
|
51
|
-
gap: config.$space-2x;
|
|
47
|
+
padding: 0;
|
|
48
|
+
flex-direction: column;
|
|
52
49
|
box-shadow: none;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.button {
|
|
56
|
-
width: 50%;
|
|
57
|
-
}
|
|
50
|
+
background-color: transparent;
|
|
51
|
+
inset: auto config.$space-4x config.$space-4x config.$space-4x;
|
|
58
52
|
}
|
|
59
53
|
}
|
|
60
54
|
}
|
package/src/atoms/Input.scss
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
@use '../settings/color_alias';
|
|
2
2
|
@use '../settings/typography/form' as typography;
|
|
3
3
|
@use '../settings/config';
|
|
4
|
-
@import 'button/Button.scss';
|
|
5
4
|
|
|
6
5
|
.input-group {
|
|
7
6
|
@include typography.input-text;
|
|
@@ -125,22 +124,4 @@
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
|
-
&.file .input-container {
|
|
129
|
-
padding: 0;
|
|
130
|
-
border: none;
|
|
131
|
-
input {
|
|
132
|
-
color: color_alias.$neutral-color-600;
|
|
133
|
-
&::before {
|
|
134
|
-
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='12' fill='none'%3E%3Cpath d='M2.943 8.718h4.114V4.694H9.8L5 0 .2 4.694h2.743v4.024ZM5 1.898l1.488 1.455h-.802v4.023H4.314V3.353h-.802L5 1.898Zm-4.8 8.16h9.6V11.4H.2v-1.341Z' fill='%23EB004D'/%3E%3C/svg%3E");
|
|
135
|
-
position: absolute;
|
|
136
|
-
left: config.$space-3x;
|
|
137
|
-
bottom: config.$space-2x;
|
|
138
|
-
}
|
|
139
|
-
&::file-selector-button {
|
|
140
|
-
margin-right: config.$space-2x;
|
|
141
|
-
padding-left: config.$space-3x + config.$icon-size-2x + config.$space-1x;
|
|
142
|
-
@extend .button;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
127
|
}
|
package/src/atoms/Input.tsx
CHANGED
|
@@ -57,7 +57,6 @@ export function Input({
|
|
|
57
57
|
return (
|
|
58
58
|
<div
|
|
59
59
|
className={classNames('input-group', variant, className, {
|
|
60
|
-
file: type === 'file',
|
|
61
60
|
invalid: errors?.length,
|
|
62
61
|
})}
|
|
63
62
|
>
|
|
@@ -74,7 +73,6 @@ export function Input({
|
|
|
74
73
|
type={handleInputType()}
|
|
75
74
|
name={name}
|
|
76
75
|
aria-label={accessibilityLabel || label}
|
|
77
|
-
className={classNames({ 'primary-outlined': type === 'file' })}
|
|
78
76
|
{...props}
|
|
79
77
|
/>
|
|
80
78
|
{suffix && <span className="input-suffix">{suffix}</span>}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.556 7.143c1.11 0 1.666-.572 1.666-1.714 0-1.143-.555-1.715-1.666-1.715-1.112 0-1.667.572-1.667 1.715 0 1.142.555 1.714 1.667 1.714Zm0 1.714c1.45 0 2.686-.954 3.143-2.286H20V4.286H8.7C8.241 2.954 7.006 2 5.555 2c-1.452 0-2.687.954-3.144 2.286H0V6.57h2.412c.457 1.332 1.692 2.286 3.144 2.286Zm8.888 7.429c-1.227 0-1.666-.452-1.666-1.715 0-1.262.44-1.714 1.666-1.714 1.228 0 1.667.452 1.667 1.714 0 1.263-.44 1.715-1.667 1.715Zm0 1.714c-1.45 0-2.686-.954-3.143-2.286H0V13.43h11.3c.458-1.332 1.693-2.286 3.144-2.286 1.452 0 2.687.954 3.144 2.286H20v2.285h-2.412C17.131 17.046 15.896 18 14.444 18Z" fill="#161C26"/></svg>
|
package/src/icons/index.tsx
CHANGED
|
@@ -22,6 +22,7 @@ import EditColumns from './edit-columns.svg'
|
|
|
22
22
|
import EmptyState from './empty-customize.svg'
|
|
23
23
|
import Error from './error.svg'
|
|
24
24
|
import Export from './export.svg'
|
|
25
|
+
import Filter from './filter.svg'
|
|
25
26
|
import Import from './import.svg'
|
|
26
27
|
import Info from './info.svg'
|
|
27
28
|
import Invoice from './invoice.svg'
|
|
@@ -67,6 +68,7 @@ export {
|
|
|
67
68
|
EmptyState,
|
|
68
69
|
Error,
|
|
69
70
|
Export,
|
|
71
|
+
Filter,
|
|
70
72
|
Import,
|
|
71
73
|
Info,
|
|
72
74
|
Invoice,
|
|
@@ -4,13 +4,10 @@ import { Meta } from "@storybook/blocks";
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
-
# 0.
|
|
7
|
+
# 0.26.0
|
|
8
8
|
|
|
9
|
-
* Add
|
|
10
|
-
|
|
11
|
-
# 0.25.6
|
|
12
|
-
|
|
13
|
-
* Align Form Action buttons horizontally
|
|
9
|
+
* Add CheckableTag & CheckableTagGroup components.
|
|
10
|
+
* Add Filter icon.
|
|
14
11
|
|
|
15
12
|
# 0.25.5
|
|
16
13
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { CheckableTag, CheckableTagGroup } from '../atoms/CheckableTag'
|
|
2
|
+
|
|
3
|
+
const figmaPrimaryDesign = {
|
|
4
|
+
design: {
|
|
5
|
+
type: 'figma',
|
|
6
|
+
url: 'https://www.figma.com/design/DN2ova21vWqCRvPspBXgI1/Design-System?node-id=3287-999&m=dev',
|
|
7
|
+
},
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: 'Design System/Atoms/CheckableTag',
|
|
12
|
+
component: CheckableTag,
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: {
|
|
15
|
+
variant: {
|
|
16
|
+
description: 'Component variant used',
|
|
17
|
+
},
|
|
18
|
+
label: {
|
|
19
|
+
description: 'Component label',
|
|
20
|
+
},
|
|
21
|
+
isDisabled: {
|
|
22
|
+
description: 'Is the component disabled?',
|
|
23
|
+
},
|
|
24
|
+
isChecked: {
|
|
25
|
+
description: 'Is the component checked?',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
parameters: figmaPrimaryDesign,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default meta
|
|
32
|
+
|
|
33
|
+
export const TagGroup = {
|
|
34
|
+
render: () => (
|
|
35
|
+
<CheckableTagGroup>
|
|
36
|
+
<CheckableTag
|
|
37
|
+
variant="primary"
|
|
38
|
+
label="RPG"
|
|
39
|
+
aria-label="RPG games"
|
|
40
|
+
onSelect={() => {}}
|
|
41
|
+
onChange={() => {}}
|
|
42
|
+
isChecked={false}
|
|
43
|
+
/>
|
|
44
|
+
<CheckableTag
|
|
45
|
+
variant="primary"
|
|
46
|
+
label="Sports"
|
|
47
|
+
aria-label="Sport games"
|
|
48
|
+
onSelect={() => {}}
|
|
49
|
+
onChange={() => {}}
|
|
50
|
+
isChecked={false}
|
|
51
|
+
/>
|
|
52
|
+
<CheckableTag
|
|
53
|
+
variant="primary"
|
|
54
|
+
label="Party"
|
|
55
|
+
aria-label="Party games"
|
|
56
|
+
onSelect={() => {}}
|
|
57
|
+
onChange={() => {}}
|
|
58
|
+
isChecked={false}
|
|
59
|
+
isDisabled={true}
|
|
60
|
+
/>
|
|
61
|
+
<CheckableTag
|
|
62
|
+
variant="primary"
|
|
63
|
+
label="Survival horror"
|
|
64
|
+
aria-label="Survival horror games"
|
|
65
|
+
onSelect={() => {}}
|
|
66
|
+
onChange={() => {}}
|
|
67
|
+
isChecked={true}
|
|
68
|
+
/>
|
|
69
|
+
<CheckableTag
|
|
70
|
+
variant="primary"
|
|
71
|
+
label="Action"
|
|
72
|
+
aria-label="Action games"
|
|
73
|
+
onSelect={() => {}}
|
|
74
|
+
onChange={() => {}}
|
|
75
|
+
isChecked={false}
|
|
76
|
+
/>
|
|
77
|
+
<CheckableTag
|
|
78
|
+
variant="primary"
|
|
79
|
+
label="Platform"
|
|
80
|
+
aria-label="Platform games"
|
|
81
|
+
onSelect={() => {}}
|
|
82
|
+
onChange={() => {}}
|
|
83
|
+
isChecked={false}
|
|
84
|
+
/>
|
|
85
|
+
<CheckableTag
|
|
86
|
+
variant="primary"
|
|
87
|
+
label="Graphic adventure"
|
|
88
|
+
aria-label="Graphic adventure games"
|
|
89
|
+
onSelect={() => {}}
|
|
90
|
+
onChange={() => {}}
|
|
91
|
+
isChecked={false}
|
|
92
|
+
/>
|
|
93
|
+
<CheckableTag
|
|
94
|
+
variant="primary"
|
|
95
|
+
label="FPS"
|
|
96
|
+
aria-label="First Person Shooter games"
|
|
97
|
+
onSelect={() => {}}
|
|
98
|
+
onChange={() => {}}
|
|
99
|
+
isChecked={false}
|
|
100
|
+
/>
|
|
101
|
+
</CheckableTagGroup>
|
|
102
|
+
),
|
|
103
|
+
}
|
|
@@ -86,18 +86,6 @@ export const Password: Story = {
|
|
|
86
86
|
parameters: figmaPrimaryDesign,
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
export const File: Story = {
|
|
90
|
-
args: {
|
|
91
|
-
label: 'Label for input file',
|
|
92
|
-
variant: 'primary',
|
|
93
|
-
disabled: false,
|
|
94
|
-
helpText: 'This text can help you',
|
|
95
|
-
name: 'file',
|
|
96
|
-
type: 'file',
|
|
97
|
-
},
|
|
98
|
-
parameters: figmaPrimaryDesign,
|
|
99
|
-
}
|
|
100
|
-
|
|
101
89
|
export const WithErrors: Story = {
|
|
102
90
|
args: {
|
|
103
91
|
label: 'Email',
|
package/tests/Badge.spec.tsx
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Variant } from '@/atoms/CheckableTag'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { render } from '@testing-library/react'
|
|
4
|
+
import { CheckableTag } from '@/atoms/CheckableTag'
|
|
5
|
+
|
|
6
|
+
describe('CheckableTag', () => {
|
|
7
|
+
const variants = ['primary']
|
|
8
|
+
|
|
9
|
+
it.each(variants)('renders the %s variant with text', (variant) => {
|
|
10
|
+
const label = `${variant} checkable-tag label`
|
|
11
|
+
const accessibilityLabel = `${variant} checkable-tag label`
|
|
12
|
+
|
|
13
|
+
const { getByRole, getByText } = render(
|
|
14
|
+
<CheckableTag
|
|
15
|
+
id={`${variant}-checkabletag`}
|
|
16
|
+
aria-label={accessibilityLabel}
|
|
17
|
+
label={label}
|
|
18
|
+
variant={variant as Variant}
|
|
19
|
+
onSelect={() => jest.fn()}
|
|
20
|
+
onChange={() => jest.fn()}
|
|
21
|
+
/>,
|
|
22
|
+
)
|
|
23
|
+
expect(getByText(label)).toBeInTheDocument()
|
|
24
|
+
expect(getByRole('checkbox')).toHaveClass(`checkable-tag ${variant}`)
|
|
25
|
+
})
|
|
26
|
+
})
|