agroptima-design-system 0.28.4 → 0.28.5-beta.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 +1 -1
- package/src/atoms/Dialog/Dialog.scss +88 -0
- package/src/atoms/Dialog/Dialog.tsx +99 -0
- package/src/atoms/Form/Actions.tsx +2 -2
- package/src/atoms/Form/{Actions.scss → Form.scss} +27 -0
- package/src/atoms/Form/Form.tsx +16 -5
- package/src/atoms/Form/index.ts +3 -4
- package/src/atoms/Icon.scss +26 -13
- package/src/atoms/Modal/Modal.scss +1 -12
- package/src/atoms/Modal/Modal.tsx +7 -7
- package/src/atoms/Modal/ModalDialog.tsx +0 -2
- package/src/atoms/Modal/ModalHeader.tsx +1 -1
- package/src/atoms/Modal/index.tsx +1 -1
- package/src/settings/_mixins.scss +0 -14
- package/src/stories/Changelog.mdx +0 -9
- package/src/stories/Collapsible.stories.js +66 -55
- package/src/stories/Modal.stories.js +26 -34
- package/tests/Modal.spec.tsx +3 -4
- package/src/atoms/Form/FormContainer.scss +0 -35
- package/src/atoms/Form/FormContainer.tsx +0 -25
package/package.json
CHANGED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
@use '../../settings/color_alias';
|
|
2
|
+
@use '../../settings/breakpoints';
|
|
3
|
+
@use '../../settings/depth';
|
|
4
|
+
@use '../../settings/config';
|
|
5
|
+
|
|
6
|
+
$modal-margin: config.$space-4x;
|
|
7
|
+
$modal-width: 34.5rem;
|
|
8
|
+
$modal-background-color: color_alias.$neutral-white;
|
|
9
|
+
$modal-boder-color: color_alias.$neutral-color-200;
|
|
10
|
+
$backdrop-opacity: 0.4;
|
|
11
|
+
$backdrop-background-color: color_alias.$neutral-color-900;
|
|
12
|
+
|
|
13
|
+
.modal {
|
|
14
|
+
position: fixed;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
z-index: depth.$z-modal;
|
|
18
|
+
width: 100%;
|
|
19
|
+
height: 100%;
|
|
20
|
+
overflow-x: hidden;
|
|
21
|
+
overflow-y: auto;
|
|
22
|
+
outline: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.modal-dialog {
|
|
26
|
+
transition: transform 0.3s ease-out;
|
|
27
|
+
max-width: $modal-width;
|
|
28
|
+
position: relative;
|
|
29
|
+
width: auto;
|
|
30
|
+
margin-block: $modal-margin;
|
|
31
|
+
margin-inline: auto;
|
|
32
|
+
pointer-events: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.modal-content {
|
|
36
|
+
position: relative;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
width: 100%;
|
|
40
|
+
pointer-events: auto;
|
|
41
|
+
background-color: $modal-background-color;
|
|
42
|
+
background-clip: padding-box;
|
|
43
|
+
outline: 0;
|
|
44
|
+
border-radius: config.$corner-radius-xxs;
|
|
45
|
+
box-shadow:
|
|
46
|
+
0px 3px 6px -4px rgba(0, 0, 0, 0.12),
|
|
47
|
+
0px 6px 16px 0px rgba(0, 0, 0, 0.08),
|
|
48
|
+
0px 9px 28px 8px rgba(0, 0, 0, 0.05);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.modal-header {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-shrink: 0;
|
|
54
|
+
align-items: center;
|
|
55
|
+
padding: 1rem 1rem;
|
|
56
|
+
border-bottom: 1px solid $modal-boder-color;
|
|
57
|
+
button {
|
|
58
|
+
margin-left: auto;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.modal-body {
|
|
63
|
+
position: relative;
|
|
64
|
+
flex: 1 1 auto;
|
|
65
|
+
padding: 1rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.modal-footer {
|
|
69
|
+
display: flex;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
flex-wrap: wrap;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: flex-end;
|
|
74
|
+
padding: calc(1rem - 0.5rem * 0.5);
|
|
75
|
+
border-top: 1px solid $modal-boder-color;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.modal-backdrop {
|
|
79
|
+
opacity: $backdrop-opacity;
|
|
80
|
+
position: fixed;
|
|
81
|
+
top: 0;
|
|
82
|
+
left: 0;
|
|
83
|
+
z-index: depth.$z-modal;
|
|
84
|
+
width: 100vw;
|
|
85
|
+
height: 100vh;
|
|
86
|
+
background-color: $backdrop-background-color;
|
|
87
|
+
transition: opacity 0.15s linear;
|
|
88
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Button, IconButton } from '../Button'
|
|
2
|
+
import { Select } from '../Select'
|
|
3
|
+
|
|
4
|
+
export function Dialog() {
|
|
5
|
+
return (
|
|
6
|
+
<>
|
|
7
|
+
<div className="modal-backdrop"></div>
|
|
8
|
+
<div className="modal modal-open">
|
|
9
|
+
<div className="modal-dialog">
|
|
10
|
+
<div className="modal-content">
|
|
11
|
+
<div className="modal-header">
|
|
12
|
+
<h1>Modal title</h1>
|
|
13
|
+
<IconButton accessibilityLabel="close" icon="Close" />
|
|
14
|
+
</div>
|
|
15
|
+
<div className="modal-body">
|
|
16
|
+
<p>
|
|
17
|
+
This is some placeholder content to show the scrolling behavior
|
|
18
|
+
for modals. Instead of repeating the text in the modal, we use
|
|
19
|
+
an inline style to set a minimum height, thereby extending the
|
|
20
|
+
length of the overall modal and demonstrating the overflow
|
|
21
|
+
scrolling. When content becomes longer than the height of the
|
|
22
|
+
viewport, scrolling will move the modal as needed.
|
|
23
|
+
</p>
|
|
24
|
+
<p>
|
|
25
|
+
This is some placeholder content to show the scrolling behavior
|
|
26
|
+
for modals. Instead of repeating the text in the modal, we use
|
|
27
|
+
an inline style to set a minimum height, thereby extending the
|
|
28
|
+
length of the overall modal and demonstrating the overflow
|
|
29
|
+
scrolling. When content becomes longer than the height of the
|
|
30
|
+
viewport, scrolling will move the modal as needed.
|
|
31
|
+
</p>
|
|
32
|
+
<p>
|
|
33
|
+
This is some placeholder content to show the scrolling behavior
|
|
34
|
+
for modals. Instead of repeating the text in the modal, we use
|
|
35
|
+
an inline style to set a minimum height, thereby extending the
|
|
36
|
+
length of the overall modal and demonstrating the overflow
|
|
37
|
+
scrolling. When content becomes longer than the height of the
|
|
38
|
+
viewport, scrolling will move the modal as needed.
|
|
39
|
+
</p>
|
|
40
|
+
<p>
|
|
41
|
+
This is some placeholder content to show the scrolling behavior
|
|
42
|
+
for modals. Instead of repeating the text in the modal, we use
|
|
43
|
+
an inline style to set a minimum height, thereby extending the
|
|
44
|
+
length of the overall modal and demonstrating the overflow
|
|
45
|
+
scrolling. When content becomes longer than the height of the
|
|
46
|
+
viewport, scrolling will move the modal as needed.
|
|
47
|
+
</p>
|
|
48
|
+
<p>
|
|
49
|
+
This is some placeholder content to show the scrolling behavior
|
|
50
|
+
for modals. Instead of repeating the text in the modal, we use
|
|
51
|
+
an inline style to set a minimum height, thereby extending the
|
|
52
|
+
length of the overall modal and demonstrating the overflow
|
|
53
|
+
scrolling. When content becomes longer than the height of the
|
|
54
|
+
viewport, scrolling will move the modal as needed.
|
|
55
|
+
</p>
|
|
56
|
+
<p>
|
|
57
|
+
This is some placeholder content to show the scrolling behavior
|
|
58
|
+
for modals. Instead of repeating the text in the modal, we use
|
|
59
|
+
an inline style to set a minimum height, thereby extending the
|
|
60
|
+
length of the overall modal and demonstrating the overflow
|
|
61
|
+
scrolling. When content becomes longer than the height of the
|
|
62
|
+
viewport, scrolling will move the modal as needed.
|
|
63
|
+
</p>
|
|
64
|
+
<div>
|
|
65
|
+
<Select
|
|
66
|
+
id="select"
|
|
67
|
+
label="Select"
|
|
68
|
+
helpText="This is a help text"
|
|
69
|
+
placeholder="Select an option"
|
|
70
|
+
options={[
|
|
71
|
+
{ id: '1', label: 'Option 1' },
|
|
72
|
+
{ id: '2', label: 'Option 2' },
|
|
73
|
+
{ id: '3', label: 'Option 3' },
|
|
74
|
+
{ id: '4', label: 'Option 4' },
|
|
75
|
+
{ id: '5', label: 'Option 5' },
|
|
76
|
+
{ id: '6', label: 'Option 6' },
|
|
77
|
+
{ id: '7', label: 'Option 7' },
|
|
78
|
+
{ id: '8', label: 'Option 8' },
|
|
79
|
+
{ id: '9', label: 'Option 9' },
|
|
80
|
+
{ id: '10', label: 'Option 10' },
|
|
81
|
+
{ id: '11', label: 'Option 11' },
|
|
82
|
+
{ id: '12', label: 'Option 12' },
|
|
83
|
+
{ id: '13', label: 'Option 13' },
|
|
84
|
+
{ id: '14', label: 'Option 14' },
|
|
85
|
+
{ id: '15', label: 'Option 15' },
|
|
86
|
+
]}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<div className="modal-footer">
|
|
91
|
+
<Button label="Close" variant="neutral-ghost" />
|
|
92
|
+
<Button label="Save" />
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
</>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import './
|
|
1
|
+
import './Form.scss'
|
|
2
2
|
import { classNames } from '../../utils/classNames'
|
|
3
3
|
|
|
4
4
|
export interface ActionsProps extends React.ComponentPropsWithoutRef<'div'> {
|
|
5
5
|
children: React.ReactNode
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export function Actions({ className, children }: ActionsProps) {
|
|
8
|
+
export default function Actions({ className, children }: ActionsProps) {
|
|
9
9
|
return (
|
|
10
10
|
<div className={classNames('footer-actions', className)}>{children}</div>
|
|
11
11
|
)
|
|
@@ -4,6 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
$gap: config.$space-4x;
|
|
6
6
|
|
|
7
|
+
.form {
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
margin: 0 auto;
|
|
11
|
+
gap: $gap;
|
|
12
|
+
padding: 0;
|
|
13
|
+
|
|
14
|
+
width: breakpoints.$medium;
|
|
15
|
+
max-width: breakpoints.$medium;
|
|
16
|
+
|
|
17
|
+
&.full-width {
|
|
18
|
+
width: 100%;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:has(.footer-actions) {
|
|
23
|
+
padding-bottom: 6.25rem;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
.footer-actions {
|
|
8
28
|
display: flex;
|
|
9
29
|
justify-content: flex-end;
|
|
@@ -19,6 +39,13 @@ $gap: config.$space-4x;
|
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
@media only screen and (max-width: breakpoints.$large) {
|
|
42
|
+
.form {
|
|
43
|
+
max-width: 100%;
|
|
44
|
+
width: 100%;
|
|
45
|
+
&:has(.footer-actions) {
|
|
46
|
+
padding-bottom: 9rem;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
22
49
|
.footer-actions {
|
|
23
50
|
background-color: color_alias.$neutral-white;
|
|
24
51
|
border-top: 1px solid color_alias.$neutral-color-200;
|
package/src/atoms/Form/Form.tsx
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './Form.scss'
|
|
2
|
+
import { classNames } from '../../utils/classNames'
|
|
2
3
|
|
|
3
4
|
export interface FormProps extends React.ComponentPropsWithoutRef<'form'> {
|
|
4
|
-
|
|
5
|
+
fullWidth?: boolean
|
|
5
6
|
children: React.ReactNode
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export function Form({
|
|
9
|
+
export default function Form({
|
|
10
|
+
className,
|
|
11
|
+
fullWidth,
|
|
12
|
+
children,
|
|
13
|
+
...props
|
|
14
|
+
}: FormProps) {
|
|
9
15
|
return (
|
|
10
|
-
<form
|
|
11
|
-
|
|
16
|
+
<form
|
|
17
|
+
className={classNames(className, 'form', {
|
|
18
|
+
'full-width': fullWidth,
|
|
19
|
+
})}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
12
23
|
</form>
|
|
13
24
|
)
|
|
14
25
|
}
|
package/src/atoms/Form/index.ts
CHANGED
package/src/atoms/Icon.scss
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
@use '../settings/color_alias';
|
|
2
2
|
@use '../settings/config';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
@mixin color($color) {
|
|
5
|
+
svg {
|
|
6
|
+
fill: $color;
|
|
7
|
+
path {
|
|
8
|
+
fill: $color;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@mixin size($size) {
|
|
14
|
+
width: $size;
|
|
15
|
+
height: $size;
|
|
16
|
+
}
|
|
4
17
|
|
|
5
18
|
.icon {
|
|
6
19
|
display: inline-flex;
|
|
@@ -13,41 +26,41 @@
|
|
|
13
26
|
}
|
|
14
27
|
|
|
15
28
|
&.size-1 {
|
|
16
|
-
@include
|
|
29
|
+
@include size(config.$icon-size-1x);
|
|
17
30
|
}
|
|
18
31
|
&.size-2 {
|
|
19
|
-
@include
|
|
32
|
+
@include size(config.$icon-size-2x);
|
|
20
33
|
}
|
|
21
34
|
&.size-3 {
|
|
22
|
-
@include
|
|
35
|
+
@include size(config.$icon-size-3x);
|
|
23
36
|
}
|
|
24
37
|
&.size-4 {
|
|
25
|
-
@include
|
|
38
|
+
@include size(config.$icon-size-4x);
|
|
26
39
|
}
|
|
27
40
|
&.size-5 {
|
|
28
|
-
@include
|
|
41
|
+
@include size(config.$icon-size-5x);
|
|
29
42
|
}
|
|
30
43
|
&.size-6 {
|
|
31
|
-
@include
|
|
44
|
+
@include size(config.$icon-size-6x);
|
|
32
45
|
}
|
|
33
46
|
&.size-7 {
|
|
34
|
-
@include
|
|
47
|
+
@include size(config.$icon-size-7x);
|
|
35
48
|
}
|
|
36
49
|
&.size-8 {
|
|
37
|
-
@include
|
|
50
|
+
@include size(config.$icon-size-8x);
|
|
38
51
|
}
|
|
39
52
|
|
|
40
53
|
&.info {
|
|
41
|
-
@include
|
|
54
|
+
@include color(color_alias.$info-color-1000);
|
|
42
55
|
}
|
|
43
56
|
&.success {
|
|
44
|
-
@include
|
|
57
|
+
@include color(color_alias.$success-color-1000);
|
|
45
58
|
}
|
|
46
59
|
&.warning {
|
|
47
|
-
@include
|
|
60
|
+
@include color(color_alias.$warning-color-1000);
|
|
48
61
|
}
|
|
49
62
|
&.error {
|
|
50
|
-
@include
|
|
63
|
+
@include color(color_alias.$error-color-1000);
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
@keyframes rotate {
|
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
@use '../../settings/depth';
|
|
6
6
|
@use '../../settings/config';
|
|
7
7
|
|
|
8
|
-
$modal-margin:
|
|
8
|
+
$modal-margin: config.$space-4x;
|
|
9
9
|
$modal-width: 34.5rem;
|
|
10
|
-
$modal-detail-width: 50rem;
|
|
11
10
|
$modal-background-color: color_alias.$neutral-white;
|
|
12
11
|
$modal-boder-color: color_alias.$neutral-color-200;
|
|
13
12
|
$backdrop-opacity: 0.4;
|
|
@@ -32,7 +31,6 @@ $backdrop-background-color: color_alias.$neutral-color-900;
|
|
|
32
31
|
width: auto;
|
|
33
32
|
margin-block: $modal-margin;
|
|
34
33
|
margin-inline: auto;
|
|
35
|
-
padding-inline: config.$space-4x;
|
|
36
34
|
pointer-events: none;
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -97,10 +95,6 @@ $backdrop-background-color: color_alias.$neutral-color-900;
|
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
.modal-details {
|
|
100
|
-
.modal-dialog {
|
|
101
|
-
max-width: 50rem;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
98
|
.modal-header {
|
|
105
99
|
border-bottom: 1px solid $modal-boder-color;
|
|
106
100
|
padding-bottom: config.$space-3x;
|
|
@@ -128,11 +122,6 @@ $backdrop-background-color: color_alias.$neutral-color-900;
|
|
|
128
122
|
}
|
|
129
123
|
}
|
|
130
124
|
|
|
131
|
-
.modal-icon {
|
|
132
|
-
margin-top: config.$space-1x;
|
|
133
|
-
align-self: flex-start;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
125
|
body:has(.modal-backdrop) {
|
|
137
126
|
overflow: hidden;
|
|
138
127
|
padding-right: 0px;
|
|
@@ -33,21 +33,21 @@ export interface ModalProps {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const ICONS: { [key: string]: ReactNode } = {
|
|
36
|
-
info: <Icon
|
|
37
|
-
success: <Icon
|
|
38
|
-
warning: <Icon
|
|
39
|
-
error: <Icon
|
|
40
|
-
discard: <Icon
|
|
36
|
+
info: <Icon name="Check" size="5" variant="info" />,
|
|
37
|
+
success: <Icon name="Check" size="5" variant="success" />,
|
|
38
|
+
warning: <Icon name="Warning" size="5" variant="warning" />,
|
|
39
|
+
error: <Icon name="Error" size="5" variant="error" />,
|
|
40
|
+
discard: <Icon name="Warning" size="5" variant="warning" />,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export function Modal({
|
|
44
44
|
id,
|
|
45
|
+
variant = 'details',
|
|
45
46
|
title,
|
|
46
47
|
buttons,
|
|
48
|
+
closeButton = false,
|
|
47
49
|
onClose,
|
|
48
50
|
children,
|
|
49
|
-
closeButton = false,
|
|
50
|
-
variant = 'details',
|
|
51
51
|
...props
|
|
52
52
|
}: ModalProps) {
|
|
53
53
|
return (
|
|
@@ -15,7 +15,6 @@ export function ModalDialog({
|
|
|
15
15
|
children,
|
|
16
16
|
details = false,
|
|
17
17
|
scrollable = false,
|
|
18
|
-
...props
|
|
19
18
|
}: ModalDialogProps) {
|
|
20
19
|
const handleClick = (event: React.MouseEvent) => {
|
|
21
20
|
if (event.target !== event.currentTarget) return
|
|
@@ -42,7 +41,6 @@ export function ModalDialog({
|
|
|
42
41
|
role="dialog"
|
|
43
42
|
className={classNames('modal', className, { 'modal-details': details })}
|
|
44
43
|
onClick={handleClick}
|
|
45
|
-
{...props}
|
|
46
44
|
>
|
|
47
45
|
<div
|
|
48
46
|
className={classNames('modal-dialog', {
|
|
@@ -4,15 +4,6 @@ import { Meta } from "@storybook/blocks";
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
-
## 0.28.4
|
|
8
|
-
|
|
9
|
-
* Update Modal component to adapt to the content height.
|
|
10
|
-
* Add a scrollable body property to the Modal component.
|
|
11
|
-
* Add onClose property to Modal component to close it when the background is clicked.
|
|
12
|
-
* Add closeButton property to Modal component to show or hide the close button.
|
|
13
|
-
* Create component FormContainer for reuse.
|
|
14
|
-
* Rename FormContainer component `fullWidth` property to `fluid`.
|
|
15
|
-
|
|
16
7
|
## 0.28.3
|
|
17
8
|
|
|
18
9
|
* Add tertiary variant to IconButton component
|
|
@@ -3,7 +3,6 @@ import { Button } from '../atoms/Button'
|
|
|
3
3
|
import { Card } from '../atoms/Card'
|
|
4
4
|
import { Collapsible } from '../atoms/Collapsible'
|
|
5
5
|
import { Actions, Form as FormComponent } from '../atoms/Form'
|
|
6
|
-
import { FormContainer } from '../atoms/Form'
|
|
7
6
|
import { Input } from '../atoms/Input'
|
|
8
7
|
import { Select } from '../atoms/Select'
|
|
9
8
|
|
|
@@ -40,7 +39,14 @@ export default meta
|
|
|
40
39
|
export const Primary = {
|
|
41
40
|
render: () => (
|
|
42
41
|
<Collapsible title="My personal data" name="personal-data">
|
|
43
|
-
<
|
|
42
|
+
<div
|
|
43
|
+
style={{
|
|
44
|
+
display: 'flex',
|
|
45
|
+
flexDirection: 'column',
|
|
46
|
+
width: '100%',
|
|
47
|
+
gap: '1rem',
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
44
50
|
<Input
|
|
45
51
|
accessibilityLabel="Fill the form name"
|
|
46
52
|
helpText="This text can help you"
|
|
@@ -85,7 +91,7 @@ export const Primary = {
|
|
|
85
91
|
placeholder="Select your favourite gaming system..."
|
|
86
92
|
variant="primary"
|
|
87
93
|
/>
|
|
88
|
-
</
|
|
94
|
+
</div>
|
|
89
95
|
</Collapsible>
|
|
90
96
|
),
|
|
91
97
|
}
|
|
@@ -94,7 +100,14 @@ export const PrimaryOpened = {
|
|
|
94
100
|
render: () => (
|
|
95
101
|
<>
|
|
96
102
|
<Collapsible title="My personal data" name="personal-data" open>
|
|
97
|
-
<
|
|
103
|
+
<div
|
|
104
|
+
style={{
|
|
105
|
+
display: 'flex',
|
|
106
|
+
flexDirection: 'column',
|
|
107
|
+
width: '100%',
|
|
108
|
+
gap: '1rem',
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
98
111
|
<Input
|
|
99
112
|
accessibilityLabel="Fill the form name"
|
|
100
113
|
helpText="This text can help you"
|
|
@@ -139,7 +152,7 @@ export const PrimaryOpened = {
|
|
|
139
152
|
placeholder="Select your favourite gaming system..."
|
|
140
153
|
variant="primary"
|
|
141
154
|
/>
|
|
142
|
-
</
|
|
155
|
+
</div>
|
|
143
156
|
</Collapsible>
|
|
144
157
|
<Collapsible title="Another data" name="another-data">
|
|
145
158
|
<Input label="Another data" name="anotherData" placeholder="..." />
|
|
@@ -160,67 +173,65 @@ export const PrimaryOpened = {
|
|
|
160
173
|
export const PrimaryDisabled = {
|
|
161
174
|
render: () => (
|
|
162
175
|
<Collapsible title="My personal data" name="personal-data" disabled>
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
/>
|
|
208
|
-
</FormContainer>
|
|
176
|
+
<Input
|
|
177
|
+
accessibilityLabel="Fill the form name"
|
|
178
|
+
helpText="This text can help you"
|
|
179
|
+
id="name_input"
|
|
180
|
+
label="Name"
|
|
181
|
+
name="name"
|
|
182
|
+
placeholder="name..."
|
|
183
|
+
type="name"
|
|
184
|
+
variant="primary"
|
|
185
|
+
/>
|
|
186
|
+
<Input
|
|
187
|
+
accessibilityLabel="Fill the form email"
|
|
188
|
+
helpText="This text can help you"
|
|
189
|
+
id="email_input"
|
|
190
|
+
label="Email"
|
|
191
|
+
name="email"
|
|
192
|
+
placeholder="Email..."
|
|
193
|
+
type="email"
|
|
194
|
+
variant="primary"
|
|
195
|
+
/>
|
|
196
|
+
<Select
|
|
197
|
+
accessibilityLabel="Select your favourite gaming system options"
|
|
198
|
+
helpText="This text can help you"
|
|
199
|
+
id="select-videogames"
|
|
200
|
+
label="Videogames"
|
|
201
|
+
name="example"
|
|
202
|
+
onChange={() => {}}
|
|
203
|
+
options={[
|
|
204
|
+
{
|
|
205
|
+
id: '1',
|
|
206
|
+
label: 'Nintendo Switch',
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: '2',
|
|
210
|
+
label: 'PlayStation 5',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: '3',
|
|
214
|
+
label: 'Xbox Series S/X',
|
|
215
|
+
},
|
|
216
|
+
]}
|
|
217
|
+
placeholder="Select your favourite gaming system..."
|
|
218
|
+
variant="primary"
|
|
219
|
+
/>
|
|
209
220
|
</Collapsible>
|
|
210
221
|
),
|
|
211
222
|
}
|
|
212
223
|
|
|
213
224
|
export const Form = {
|
|
214
225
|
render: () => (
|
|
215
|
-
<
|
|
216
|
-
<
|
|
226
|
+
<FormComponent>
|
|
227
|
+
<Collapsible open form title="User">
|
|
217
228
|
<Input label="First Name" placeholder="First Name" name="firstName" />
|
|
218
229
|
<Input label="Last Name" placeholder="Last Name" name="lastName" />
|
|
219
230
|
<Actions>
|
|
220
231
|
<Button type="button" label="Cancel" variant="primary-outlined" />
|
|
221
232
|
<Button type="submit" label="Sign in" variant="primary" />
|
|
222
233
|
</Actions>
|
|
223
|
-
</
|
|
224
|
-
</
|
|
234
|
+
</Collapsible>
|
|
235
|
+
</FormComponent>
|
|
225
236
|
),
|
|
226
237
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { Button, IconButton } from '../atoms/Button'
|
|
3
3
|
import { Card } from '../atoms/Card'
|
|
4
|
+
import { Collapsible } from '../atoms/Collapsible'
|
|
4
5
|
import { DetailItem } from '../atoms/DetailItem'
|
|
5
|
-
import { FormContainer } from '../atoms/Form'
|
|
6
6
|
import { Input } from '../atoms/Input'
|
|
7
7
|
import {
|
|
8
8
|
ModalBody,
|
|
@@ -232,7 +232,7 @@ export const ScrollableModal = () => (
|
|
|
232
232
|
</Modal>
|
|
233
233
|
)
|
|
234
234
|
|
|
235
|
-
const
|
|
235
|
+
export const OpenAndCloseModal = () => {
|
|
236
236
|
const [isOpen, setIsOpen] = React.useState(false)
|
|
237
237
|
const closeModal = () => setIsOpen(false)
|
|
238
238
|
return (
|
|
@@ -257,12 +257,6 @@ const OpenAndCloseModalComponent = () => {
|
|
|
257
257
|
)
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
export const OpenAndCloseModal = {
|
|
261
|
-
render: () => {
|
|
262
|
-
return <OpenAndCloseModalComponent />
|
|
263
|
-
},
|
|
264
|
-
}
|
|
265
|
-
|
|
266
260
|
export const FormModal = () => (
|
|
267
261
|
<form
|
|
268
262
|
onSubmit={(e) => {
|
|
@@ -285,32 +279,30 @@ export const FormModal = () => (
|
|
|
285
279
|
{ label: 'Save', type: 'submit' },
|
|
286
280
|
]}
|
|
287
281
|
>
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
/>
|
|
313
|
-
</FormContainer>
|
|
282
|
+
<Input name="input" label="Input" placeholder="Type something" />
|
|
283
|
+
<Select
|
|
284
|
+
label="Select"
|
|
285
|
+
name="select"
|
|
286
|
+
helpText="This is a help text"
|
|
287
|
+
placeholder="Select an option"
|
|
288
|
+
options={[
|
|
289
|
+
{ id: '1', label: 'Option 1' },
|
|
290
|
+
{ id: '2', label: 'Option 2' },
|
|
291
|
+
{ id: '3', label: 'Option 3' },
|
|
292
|
+
{ id: '4', label: 'Option 4' },
|
|
293
|
+
{ id: '5', label: 'Option 5' },
|
|
294
|
+
{ id: '6', label: 'Option 6' },
|
|
295
|
+
{ id: '7', label: 'Option 7' },
|
|
296
|
+
{ id: '8', label: 'Option 8' },
|
|
297
|
+
{ id: '9', label: 'Option 9' },
|
|
298
|
+
{ id: '10', label: 'Option 10' },
|
|
299
|
+
{ id: '11', label: 'Option 11' },
|
|
300
|
+
{ id: '12', label: 'Option 12' },
|
|
301
|
+
{ id: '13', label: 'Option 13' },
|
|
302
|
+
{ id: '14', label: 'Option 14' },
|
|
303
|
+
{ id: '15', label: 'Option 15' },
|
|
304
|
+
]}
|
|
305
|
+
/>
|
|
314
306
|
</Modal>
|
|
315
307
|
</form>
|
|
316
308
|
)
|
package/tests/Modal.spec.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { Modal
|
|
3
|
+
import { Modal } from '../src/atoms/Modal/Modal'
|
|
4
4
|
|
|
5
5
|
describe('Modal', () => {
|
|
6
6
|
const variants = ['info', 'success', 'warning', 'error']
|
|
@@ -11,7 +11,6 @@ describe('Modal', () => {
|
|
|
11
11
|
const content = `${variant} modal content`
|
|
12
12
|
const { getByRole, getByText } = render(
|
|
13
13
|
<Modal
|
|
14
|
-
variant={variant as Variant}
|
|
15
14
|
id={`${variant}-modal`}
|
|
16
15
|
title={title}
|
|
17
16
|
buttons={[
|
|
@@ -23,7 +22,7 @@ describe('Modal', () => {
|
|
|
23
22
|
{content}
|
|
24
23
|
</Modal>,
|
|
25
24
|
)
|
|
26
|
-
expect(getByRole('img')).toHaveClass(
|
|
25
|
+
expect(getByRole('img')).toHaveClass('info')
|
|
27
26
|
expect(getByText(title)).toBeInTheDocument()
|
|
28
27
|
expect(getByText(content)).toBeInTheDocument()
|
|
29
28
|
expect(getByRole('button')).toHaveTextContent('Done')
|
|
@@ -53,7 +52,7 @@ describe('Modal', () => {
|
|
|
53
52
|
{content}
|
|
54
53
|
</Modal>,
|
|
55
54
|
)
|
|
56
|
-
expect(getByRole('img')).toHaveClass('
|
|
55
|
+
expect(getByRole('img')).toHaveClass('discard')
|
|
57
56
|
expect(getByText(title)).toBeInTheDocument()
|
|
58
57
|
expect(getByText(content)).toBeInTheDocument()
|
|
59
58
|
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Cancel')
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
@use '../../settings/config';
|
|
2
|
-
@use '../../settings/breakpoints';
|
|
3
|
-
@use '../../settings/color_alias';
|
|
4
|
-
|
|
5
|
-
$gap: config.$space-4x;
|
|
6
|
-
|
|
7
|
-
.form-container {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
margin: 0 auto;
|
|
11
|
-
gap: $gap;
|
|
12
|
-
padding: 0;
|
|
13
|
-
|
|
14
|
-
width: breakpoints.$medium;
|
|
15
|
-
max-width: breakpoints.$medium;
|
|
16
|
-
|
|
17
|
-
&.fluid {
|
|
18
|
-
width: 100%;
|
|
19
|
-
max-width: 100%;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
&:has(.footer-actions) {
|
|
23
|
-
padding-bottom: 6.25rem;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@media only screen and (max-width: breakpoints.$large) {
|
|
28
|
-
.form-container {
|
|
29
|
-
max-width: 100%;
|
|
30
|
-
width: 100%;
|
|
31
|
-
&:has(.footer-actions) {
|
|
32
|
-
padding-bottom: 9rem;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import './FormContainer.scss'
|
|
2
|
-
import { classNames } from '../../utils/classNames'
|
|
3
|
-
|
|
4
|
-
export interface FormContainerProps
|
|
5
|
-
extends React.ComponentPropsWithoutRef<'div'> {
|
|
6
|
-
fluid?: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function FormContainer({
|
|
10
|
-
fluid,
|
|
11
|
-
className,
|
|
12
|
-
children,
|
|
13
|
-
...props
|
|
14
|
-
}: FormContainerProps) {
|
|
15
|
-
return (
|
|
16
|
-
<div
|
|
17
|
-
className={classNames(className, 'form-container', {
|
|
18
|
-
fluid,
|
|
19
|
-
})}
|
|
20
|
-
{...props}
|
|
21
|
-
>
|
|
22
|
-
{children}
|
|
23
|
-
</div>
|
|
24
|
-
)
|
|
25
|
-
}
|