agroptima-design-system 0.2.1 → 0.2.2
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 -3
- package/src/atoms/Multiselect.scss +2 -0
- package/src/atoms/Multiselect.tsx +8 -2
- package/src/atoms/Select.scss +2 -0
- package/src/atoms/Select.tsx +7 -3
- package/src/settings/_depth.scss +8 -0
- package/src/stories/Changelog.stories.mdx +6 -0
- package/src/stories/Multiselect.stories.ts +31 -0
- package/src/stories/Select.stories.ts +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agroptima-design-system",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "npm run storybook",
|
|
6
6
|
"storybook": "storybook dev -p 6006 --ci",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"build-storybook": "storybook build",
|
|
9
9
|
"lint": "eslint",
|
|
10
10
|
"lint:fix": "eslint src --fix",
|
|
11
|
-
"publish-chromatic": "npx chromatic --exit-zero-on-changes"
|
|
12
|
-
"chromatic": "npx chromatic --exit-zero-on-changes"
|
|
11
|
+
"publish-chromatic": "npx chromatic --exit-zero-on-changes"
|
|
13
12
|
},
|
|
14
13
|
"dependencies": {
|
|
15
14
|
"@storybook/addon-designs": "^7.0.5",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@use '../settings/color_alias';
|
|
2
2
|
@use '../settings/typography';
|
|
3
3
|
@use '../settings/config';
|
|
4
|
+
@use '../settings/depth';
|
|
4
5
|
|
|
5
6
|
.multiselect-group {
|
|
6
7
|
display: flex;
|
|
@@ -124,6 +125,7 @@
|
|
|
124
125
|
}
|
|
125
126
|
|
|
126
127
|
.multiselect-options {
|
|
128
|
+
z-index: depth.$z-dropdown-options;
|
|
127
129
|
margin: 0;
|
|
128
130
|
padding: config.$space-1x 0rem;
|
|
129
131
|
text-align: left;
|
|
@@ -14,6 +14,8 @@ export interface MultiselectProps
|
|
|
14
14
|
invalid?: boolean
|
|
15
15
|
label: string
|
|
16
16
|
selectedLabel?: string
|
|
17
|
+
hideLabel?: boolean
|
|
18
|
+
selected?: Option[]
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export function Multiselect({
|
|
@@ -26,9 +28,13 @@ export function Multiselect({
|
|
|
26
28
|
options,
|
|
27
29
|
label,
|
|
28
30
|
selectedLabel = 'items selected',
|
|
31
|
+
hideLabel = false,
|
|
32
|
+
selected,
|
|
29
33
|
}: MultiselectProps): React.JSX.Element {
|
|
30
34
|
const [showOptionsList, setShowOptionsList] = useState(false)
|
|
31
|
-
const [selectedOptionsIds, setSelectedOptionsIds] = useState<string[]>(
|
|
35
|
+
const [selectedOptionsIds, setSelectedOptionsIds] = useState<string[]>(
|
|
36
|
+
selected?.map((option) => option.id) || [],
|
|
37
|
+
)
|
|
32
38
|
|
|
33
39
|
const optionsListOpenClass = showOptionsList ? 'open' : ''
|
|
34
40
|
const filledSelectClass = selectedOptionsIds.length > 0 ? 'filled' : ''
|
|
@@ -70,7 +76,7 @@ export function Multiselect({
|
|
|
70
76
|
|
|
71
77
|
return (
|
|
72
78
|
<div className={`multiselect-group ${variant}`}>
|
|
73
|
-
<span className="multiselect-label">{label}</span>
|
|
79
|
+
{!hideLabel && <span className="multiselect-label">{label}</span>}
|
|
74
80
|
<div className="multiselect-container">
|
|
75
81
|
<div
|
|
76
82
|
className={cssClasses}
|
package/src/atoms/Select.scss
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@use '../settings/color_alias';
|
|
2
2
|
@use '../settings/typography';
|
|
3
3
|
@use '../settings/config';
|
|
4
|
+
@use '../settings/depth';
|
|
4
5
|
|
|
5
6
|
.select-group {
|
|
6
7
|
display: flex;
|
|
@@ -63,6 +64,7 @@
|
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
.select-options {
|
|
67
|
+
z-index: depth.$z-dropdown-options;
|
|
66
68
|
border-radius: config.$corner-radius-xxs;
|
|
67
69
|
background: color_alias.$neutral-white;
|
|
68
70
|
box-shadow:
|
package/src/atoms/Select.tsx
CHANGED
|
@@ -12,6 +12,8 @@ export interface SelectProps extends React.ComponentPropsWithoutRef<'select'> {
|
|
|
12
12
|
options: Option[]
|
|
13
13
|
invalid?: boolean
|
|
14
14
|
label: string
|
|
15
|
+
hideLabel?: boolean
|
|
16
|
+
selected?: Option
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export function Select({
|
|
@@ -23,11 +25,13 @@ export function Select({
|
|
|
23
25
|
name,
|
|
24
26
|
options,
|
|
25
27
|
label,
|
|
28
|
+
hideLabel = false,
|
|
29
|
+
selected,
|
|
26
30
|
}: SelectProps): React.JSX.Element {
|
|
27
31
|
const [showOptionsList, setShowOptionsList] = useState(false)
|
|
28
32
|
const [selectedOption, setSelectedOption] = useState<Option>({
|
|
29
|
-
id: '',
|
|
30
|
-
label: '',
|
|
33
|
+
id: selected?.id || '',
|
|
34
|
+
label: selected?.label || '',
|
|
31
35
|
})
|
|
32
36
|
|
|
33
37
|
const optionsListOpenClass = showOptionsList ? 'open' : ''
|
|
@@ -58,7 +62,7 @@ export function Select({
|
|
|
58
62
|
|
|
59
63
|
return (
|
|
60
64
|
<div className={`select-group ${variant}`}>
|
|
61
|
-
<span className="select-label">{label}</span>
|
|
65
|
+
{!hideLabel && <span className="select-label">{label}</span>}
|
|
62
66
|
<div className="select-container">
|
|
63
67
|
<div
|
|
64
68
|
className={cssClasses}
|
|
@@ -3,6 +3,12 @@ import { Meta } from "@storybook/addon-docs";
|
|
|
3
3
|
<Meta title="Changelog" />
|
|
4
4
|
# Changelog
|
|
5
5
|
|
|
6
|
+
## 0.2.2
|
|
7
|
+
|
|
8
|
+
- Select and Multiselect options dropdown have a higher z-index.
|
|
9
|
+
- Select and Multiselect can hide its label with `hideLabel` prop.
|
|
10
|
+
- Select and Multiselect can load preselected options with `selected` prop.
|
|
11
|
+
|
|
6
12
|
## 0.2.1
|
|
7
13
|
|
|
8
14
|
- Colors have been updated due to accessibility issues.
|
|
@@ -33,6 +33,9 @@ const meta = {
|
|
|
33
33
|
options: {
|
|
34
34
|
description: 'Array of values to be displayed on the select list',
|
|
35
35
|
},
|
|
36
|
+
selected: {
|
|
37
|
+
description: 'Array of values to be displayed as selected',
|
|
38
|
+
},
|
|
36
39
|
},
|
|
37
40
|
}
|
|
38
41
|
|
|
@@ -51,6 +54,7 @@ export const Primary: Story = {
|
|
|
51
54
|
variant: 'primary',
|
|
52
55
|
disabled: false,
|
|
53
56
|
invalid: false,
|
|
57
|
+
hideLabel: false,
|
|
54
58
|
helpText: 'This text can help you',
|
|
55
59
|
name: 'example',
|
|
56
60
|
label: 'Videogames',
|
|
@@ -67,3 +71,30 @@ export const Primary: Story = {
|
|
|
67
71
|
},
|
|
68
72
|
parameters: figmaPrimaryDesign,
|
|
69
73
|
}
|
|
74
|
+
|
|
75
|
+
export const PrimaryWithSelectedOptions: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
variant: 'primary',
|
|
78
|
+
disabled: false,
|
|
79
|
+
invalid: false,
|
|
80
|
+
hideLabel: false,
|
|
81
|
+
helpText: 'This text can help you',
|
|
82
|
+
name: 'example',
|
|
83
|
+
label: 'Videogames',
|
|
84
|
+
selectedLabel: 'videogames selected',
|
|
85
|
+
placeholder: 'Select your favourite videogames...',
|
|
86
|
+
options: [
|
|
87
|
+
{ id: '1', label: 'The Legend of Zelda: Ocarina of Time' },
|
|
88
|
+
{ id: '2', label: 'Spyro the Dragon' },
|
|
89
|
+
{ id: '3', label: 'Halo' },
|
|
90
|
+
{ id: '4', label: 'Tetris' },
|
|
91
|
+
{ id: '5', label: 'Super Mario Bros' },
|
|
92
|
+
{ id: '6', label: 'Red Dead Redemption' },
|
|
93
|
+
],
|
|
94
|
+
selected: [
|
|
95
|
+
{ id: '2', label: 'Spyro the Dragon' },
|
|
96
|
+
{ id: '1', label: 'The Legend of Zelda: Ocarina of Time' },
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
parameters: figmaPrimaryDesign,
|
|
100
|
+
}
|
|
@@ -30,6 +30,9 @@ const meta = {
|
|
|
30
30
|
options: {
|
|
31
31
|
description: 'Array of values to be displayed on the select list',
|
|
32
32
|
},
|
|
33
|
+
selected: {
|
|
34
|
+
description: 'Value to be displayed as selected',
|
|
35
|
+
},
|
|
33
36
|
},
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -51,12 +54,33 @@ export const Primary: Story = {
|
|
|
51
54
|
helpText: 'This text can help you',
|
|
52
55
|
name: 'example',
|
|
53
56
|
label: 'Videogames',
|
|
57
|
+
hideLabel: false,
|
|
58
|
+
placeholder: 'Select your favourite gaming system...',
|
|
59
|
+
options: [
|
|
60
|
+
{ id: '1', label: 'Nintendo Switch' },
|
|
61
|
+
{ id: '2', label: 'PlayStation 5' },
|
|
62
|
+
{ id: '3', label: 'Xbox Series S/X' },
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
parameters: figmaPrimaryDesign,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const PrimaryWithSelectedOptions: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
variant: 'primary',
|
|
71
|
+
disabled: false,
|
|
72
|
+
invalid: false,
|
|
73
|
+
helpText: 'This text can help you',
|
|
74
|
+
name: 'example',
|
|
75
|
+
label: 'Videogames',
|
|
76
|
+
hideLabel: false,
|
|
54
77
|
placeholder: 'Select your favourite gaming system...',
|
|
55
78
|
options: [
|
|
56
79
|
{ id: '1', label: 'Nintendo Switch' },
|
|
57
80
|
{ id: '2', label: 'PlayStation 5' },
|
|
58
81
|
{ id: '3', label: 'Xbox Series S/X' },
|
|
59
82
|
],
|
|
83
|
+
selected: { id: '2', label: 'PlayStation 5' },
|
|
60
84
|
},
|
|
61
85
|
parameters: figmaPrimaryDesign,
|
|
62
86
|
}
|