agroptima-design-system 0.2.1 â 0.3.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 -3
- package/src/atoms/EmptyState.scss +36 -0
- package/src/atoms/EmptyState.tsx +35 -0
- 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/icons/empty-customize.svg +1 -0
- package/src/icons/index.tsx +2 -0
- package/src/settings/_depth.scss +8 -0
- package/src/settings/_typography.scss +10 -0
- package/src/stories/Changelog.stories.mdx +10 -0
- package/src/stories/EmptyState.stories.ts +52 -0
- package/src/stories/Icons.stories.mdx +1 -1
- 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.
|
|
3
|
+
"version": "0.3.0",
|
|
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",
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@use '../settings/color_alias';
|
|
2
|
+
@use '../settings/typography';
|
|
3
|
+
@use '../settings/config';
|
|
4
|
+
@use '../settings/depth';
|
|
5
|
+
|
|
6
|
+
.empty-state {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
align-items: center;
|
|
10
|
+
width: 100%;
|
|
11
|
+
|
|
12
|
+
> p {
|
|
13
|
+
margin-top: config.$space-2x;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&:not(:has(> .button)) {
|
|
17
|
+
> p {
|
|
18
|
+
margin-top: 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.primary {
|
|
23
|
+
> .icon {
|
|
24
|
+
width: 4.25rem;
|
|
25
|
+
height: 4.25rem;
|
|
26
|
+
> svg {
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
> p {
|
|
33
|
+
@include typography.empty-state-text;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Button } from './Button'
|
|
2
|
+
import './EmptyState.scss'
|
|
3
|
+
import { Icon, IconType } from './Icon'
|
|
4
|
+
|
|
5
|
+
export type Variant = 'primary'
|
|
6
|
+
|
|
7
|
+
interface callToAction {
|
|
8
|
+
(event: React.MouseEvent<HTMLButtonElement, MouseEvent>): any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface EmptyStateProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
12
|
+
icon?: IconType
|
|
13
|
+
text?: string
|
|
14
|
+
variant?: Variant
|
|
15
|
+
buttonLabel?: string
|
|
16
|
+
action?: callToAction
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function EmptyState({
|
|
20
|
+
icon = 'EmptyState',
|
|
21
|
+
text = 'No data',
|
|
22
|
+
variant = 'primary',
|
|
23
|
+
buttonLabel,
|
|
24
|
+
action,
|
|
25
|
+
}: EmptyStateProps): React.JSX.Element {
|
|
26
|
+
const cssClasses = ['empty-state', variant].join(' ')
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className={cssClasses}>
|
|
30
|
+
<Icon name={icon} />
|
|
31
|
+
<p>{text}</p>
|
|
32
|
+
{buttonLabel && action && <Button label={buttonLabel} onClick={action} />}
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -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}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 69 68"><g clip-path="url(#empty-customize__a)"><path d="M68.5 30.468 53.503 11.646a3.858 3.858 0 0 0-1.293-1.06 3.6 3.6 0 0 0-1.586-.386H18.376c-1.106 0-2.158.545-2.879 1.446L.5 30.468V40.8h68V30.468Z" fill="url(#empty-customize__b)"/><path d="M65.1 39.549 51.599 24.89a3.439 3.439 0 0 0-1.18-.81 3.656 3.656 0 0 0-1.434-.28h-28.97c-.994 0-1.966.385-2.614 1.09L3.9 39.55v8.05h61.2v-8.051Z" fill="url(#empty-customize__c)"/><path d="M68.498 50.22c0 1.277-.601 2.424-1.55 3.193l-.194.15a4.458 4.458 0 0 1-2.616.837H4.862a4.48 4.48 0 0 1-1.521-.263l-.235-.09a4.342 4.342 0 0 1-1.897-1.545A4.055 4.055 0 0 1 .5 50.219V30.6h16.498c1.822 0 3.29 1.431 3.29 3.168v.022c0 1.738 1.486 3.14 3.308 3.14h21.806c.876 0 1.716-.333 2.336-.924.62-.59.97-1.392.972-2.228 0-1.744 1.47-3.178 3.29-3.178h16.5l-.002 19.62Z" fill="url(#empty-customize__d)"/></g><defs><linearGradient id="empty-customize__b" x1="34.5" y1="10.2" x2="34.5" y2="23.955" gradientUnits="userSpaceOnUse"><stop stop-color="#5F0F40"/><stop offset="1" stop-color="#90446D"/></linearGradient><linearGradient id="empty-customize__c" x1="42.667" y1="47.6" x2="42.667" y2="22.535" gradientUnits="userSpaceOnUse"><stop stop-color="#FCF0F6"/><stop offset="1" stop-color="#EDB8D1"/></linearGradient><linearGradient id="empty-customize__d" x1="34.5" y1="30.6" x2="34.5" y2="54.4" gradientUnits="userSpaceOnUse"><stop stop-color="#BF6C97"/><stop offset="1" stop-color="#EDB8D1"/></linearGradient><clipPath id="empty-customize__a"><path fill="#fff" transform="translate(.5)" d="M0 0h68v68H0z"/></clipPath></defs></svg>
|
package/src/icons/index.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import CheckboxInactive from './checkbox-inactive.svg'
|
|
|
9
9
|
import Close from './close.svg'
|
|
10
10
|
import Done from './done.svg'
|
|
11
11
|
import EditColumns from './edit-columns.svg'
|
|
12
|
+
import EmptyState from './empty-customize.svg'
|
|
12
13
|
import Error from './error.svg'
|
|
13
14
|
import Export from './export.svg'
|
|
14
15
|
import Info from './info.svg'
|
|
@@ -31,6 +32,7 @@ export {
|
|
|
31
32
|
Close,
|
|
32
33
|
Done,
|
|
33
34
|
EditColumns,
|
|
35
|
+
EmptyState,
|
|
34
36
|
Error,
|
|
35
37
|
Export,
|
|
36
38
|
Info,
|
|
@@ -104,3 +104,13 @@ $font-primary: $font-base-stretch $text-base-style $font-base-weight #{$text-bas
|
|
|
104
104
|
font-size: 1rem;
|
|
105
105
|
line-height: 1.5rem; /* 150% */
|
|
106
106
|
}
|
|
107
|
+
|
|
108
|
+
@mixin empty-state-text {
|
|
109
|
+
font-style: $text-base-style;
|
|
110
|
+
font-variant: $text-base-style;
|
|
111
|
+
font-weight: 400;
|
|
112
|
+
font-family: $font-base-family;
|
|
113
|
+
color: color_alias.$neutral-color-1000;
|
|
114
|
+
font-size: 1rem;
|
|
115
|
+
text-align: center;
|
|
116
|
+
}
|
|
@@ -3,6 +3,16 @@ import { Meta } from "@storybook/addon-docs";
|
|
|
3
3
|
<Meta title="Changelog" />
|
|
4
4
|
# Changelog
|
|
5
5
|
|
|
6
|
+
## 0.3.0
|
|
7
|
+
|
|
8
|
+
- Empty State component is added to Storybook.
|
|
9
|
+
|
|
10
|
+
## 0.2.2
|
|
11
|
+
|
|
12
|
+
- Select and Multiselect options dropdown have a higher z-index.
|
|
13
|
+
- Select and Multiselect can hide its label with `hideLabel` prop.
|
|
14
|
+
- Select and Multiselect can load preselected options with `selected` prop.
|
|
15
|
+
|
|
6
16
|
## 0.2.1
|
|
7
17
|
|
|
8
18
|
- Colors have been updated due to accessibility issues.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { EmptyState } from '../atoms/EmptyState'
|
|
2
|
+
import { StoryObj } from '@storybook/react'
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Atoms/EmptyState',
|
|
6
|
+
component: EmptyState,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
icon: {
|
|
10
|
+
description: 'A default icon is set for the empty state.',
|
|
11
|
+
},
|
|
12
|
+
text: {
|
|
13
|
+
description: 'Label used to describe the empty state.',
|
|
14
|
+
},
|
|
15
|
+
variant: {
|
|
16
|
+
description: 'Variant used.',
|
|
17
|
+
},
|
|
18
|
+
buttonLabel: {
|
|
19
|
+
description: 'Label used on the button.',
|
|
20
|
+
},
|
|
21
|
+
action: {
|
|
22
|
+
description: 'Action called when button is pressed.',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const figmaPrimaryDesign = {
|
|
28
|
+
design: {
|
|
29
|
+
type: 'figma',
|
|
30
|
+
url: 'https://www.figma.com/file/DN2ova21vWqCRvPspBXgI1/Design-System?type=design&node-id=1719-258&mode=dev',
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default meta
|
|
35
|
+
type Story = StoryObj<typeof meta>
|
|
36
|
+
|
|
37
|
+
export const PrimaryCustom: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
variant: 'primary',
|
|
40
|
+
text: 'There are no videogames yet. You can import videogames to your list.',
|
|
41
|
+
buttonLabel: 'Import videogames',
|
|
42
|
+
action: (event) => console.log('click: ', event),
|
|
43
|
+
},
|
|
44
|
+
parameters: figmaPrimaryDesign,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const PrimaryBasic: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
variant: 'primary',
|
|
50
|
+
},
|
|
51
|
+
parameters: figmaPrimaryDesign,
|
|
52
|
+
}
|
|
@@ -5,7 +5,7 @@ import * as Icons from '../icons'
|
|
|
5
5
|
|
|
6
6
|
# Icons
|
|
7
7
|
|
|
8
|
-
đ You can find the source icons on this [link](
|
|
8
|
+
đ You can find the source icons on this [link](https://groupeisagri.sharepoint.com/sites/Maya_Espana/Drive%20Agroptima/Forms/AllItems.aspx?id=%2Fsites%2FMaya%5FEspana%2FDrive%20Agroptima%2F06%20%2D%20DESIGN%2F01%2E%20Bodegas%2FDesign%20system%2FRecursos%2Ficons&viewid=c0618b1a%2Dc398%2D461b%2D85e6%2Df088fc5fee72).
|
|
9
9
|
|
|
10
10
|
âšī¸ If you need to edit the svgo default options, check this [link](https://stackoverflow.com/a/70360615).
|
|
11
11
|
|
|
@@ -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
|
}
|