@beydesign/storybook 0.0.1 → 0.0.4
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/README.md +49 -40
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/stories/Avatar.d.ts +4 -0
- package/dist/stories/Avatar.js +79 -0
- package/dist/stories/Avatar.stories.d.ts +8 -0
- package/dist/stories/Avatar.stories.js +76 -0
- package/dist/stories/Badge.stories.d.ts +11 -0
- package/dist/stories/Badge.stories.js +98 -0
- package/dist/stories/Bagde.d.ts +3 -0
- package/dist/stories/Bagde.js +113 -0
- package/dist/stories/Button.js +62 -23
- package/dist/stories/Button.stories.d.ts +27 -0
- package/dist/stories/Button.stories.js +295 -0
- package/dist/stories/Checkbox.d.ts +3 -0
- package/dist/stories/Checkbox.js +66 -0
- package/dist/stories/Checkbox.stories.d.ts +13 -0
- package/dist/stories/Checkbox.stories.js +121 -0
- package/dist/stories/Colors.d.ts +1 -4
- package/dist/stories/Colors.js +251 -6
- package/dist/stories/Colors.stories.d.ts +6 -0
- package/dist/stories/Colors.stories.js +10 -0
- package/dist/stories/Typography.d.ts +4 -0
- package/dist/stories/Typography.js +36 -0
- package/dist/stories/Typography.stories.d.ts +25 -0
- package/dist/stories/Typography.stories.js +189 -0
- package/dist/stories/types/avatar.d.ts +44 -0
- package/dist/stories/types/avatar.js +28 -0
- package/dist/stories/types/badge.d.ts +47 -0
- package/dist/stories/types/badge.js +25 -0
- package/dist/stories/types/checkbox.d.ts +26 -0
- package/dist/stories/types/checkbox.js +5 -0
- package/dist/stories/types/typography.d.ts +43 -0
- package/dist/stories/types/typography.js +27 -0
- package/package.json +10 -5
- package/dist/stories/Header.d.ts +0 -12
- package/dist/stories/Header.js +0 -4
- package/dist/stories/Header.stories.d.ts +0 -18
- package/dist/stories/Header.stories.js +0 -26
- package/dist/stories/Page.d.ts +0 -3
- package/dist/stories/Page.js +0 -8
- package/dist/stories/Page.stories.d.ts +0 -12
- package/dist/stories/Page.stories.js +0 -24
package/dist/stories/Button.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, CircularProgress } from '@mui/material';
|
|
3
3
|
import * as PhosphorIcons from '@phosphor-icons/react';
|
|
4
|
-
import { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType } from './types/button';
|
|
4
|
+
import { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, } from './types/button';
|
|
5
|
+
import { Typography } from './Typography';
|
|
6
|
+
import { TypographySize, TypographyWeight } from './types/typography';
|
|
5
7
|
const getIconComponent = (iconName, props) => {
|
|
6
8
|
const Icon = PhosphorIcons[iconName];
|
|
7
9
|
return Icon ? _jsx(Icon, { ...props }) : null;
|
|
8
10
|
};
|
|
9
|
-
export const MainButton = ({ onClick, text, disabled = false, loading = false, type = ButtonType.Button, style, size = ButtonSize.xl, hierarchy = ButtonHierarchy.Primary, displayIcon, displayIconMode = ButtonDisplayMode.Default, state = ButtonState.Default, shape = ButtonShape.Square, destructive = false, showLeadingIcon =
|
|
11
|
+
export const MainButton = ({ onClick, text, disabled = false, loading = false, type = ButtonType.Button, style, size = ButtonSize.xl, hierarchy = ButtonHierarchy.Primary, displayIcon, displayIconMode = ButtonDisplayMode.Default, state = ButtonState.Default, shape = ButtonShape.Square, destructive = false, showLeadingIcon = false, showTrailingIcon = false, leadingIcon = 'Circle', trailingIcon = 'Circle', }) => {
|
|
10
12
|
const getBackgroundColor = (isHover = false) => {
|
|
11
13
|
if (destructive) {
|
|
12
14
|
if (state === ButtonState.Disabled || disabled)
|
|
@@ -42,16 +44,16 @@ export const MainButton = ({ onClick, text, disabled = false, loading = false, t
|
|
|
42
44
|
return 'var(--primitives-desktop-primary-transparent-violet-50)';
|
|
43
45
|
case ButtonHierarchy.Tetriary:
|
|
44
46
|
if (state === ButtonState.Disabled || disabled)
|
|
45
|
-
return 'var(--
|
|
47
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
46
48
|
if (state === ButtonState.Hover || isHover)
|
|
47
49
|
return 'var(--primitives-desktop-primary-white-40)';
|
|
48
|
-
return 'var(--
|
|
50
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
49
51
|
case ButtonHierarchy.TetriaryColor:
|
|
50
52
|
if (state === ButtonState.Disabled || disabled)
|
|
51
|
-
return 'var(--
|
|
53
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
52
54
|
if (state === ButtonState.Hover || isHover)
|
|
53
55
|
return 'var(--colors-light-background-bg-card-highlight-hover)';
|
|
54
|
-
return '
|
|
56
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
55
57
|
default:
|
|
56
58
|
return 'var(--colors-light-background-bg-brand)';
|
|
57
59
|
}
|
|
@@ -126,12 +128,12 @@ export const MainButton = ({ onClick, text, disabled = false, loading = false, t
|
|
|
126
128
|
return 'var(--colors-light-background-bg-white)';
|
|
127
129
|
case ButtonHierarchy.Tetriary:
|
|
128
130
|
if (state === ButtonState.Disabled || disabled)
|
|
129
|
-
return 'var(--
|
|
130
|
-
return 'var(--
|
|
131
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
132
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
131
133
|
case ButtonHierarchy.TetriaryColor:
|
|
132
134
|
if (state === ButtonState.Disabled || disabled)
|
|
133
|
-
return 'var(--
|
|
134
|
-
return 'var(--
|
|
135
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
136
|
+
return 'var(--primitives-desktop-primary-white-0)';
|
|
135
137
|
default:
|
|
136
138
|
return 'var(--colors-light-background-bg-brand)';
|
|
137
139
|
}
|
|
@@ -141,45 +143,57 @@ export const MainButton = ({ onClick, text, disabled = false, loading = false, t
|
|
|
141
143
|
[ButtonSize.xl]: {
|
|
142
144
|
width: displayIconMode === ButtonDisplayMode.Only ? '3.25rem' : '12.75rem',
|
|
143
145
|
height: '3.25rem',
|
|
144
|
-
padding: displayIconMode === ButtonDisplayMode.Only
|
|
146
|
+
padding: displayIconMode === ButtonDisplayMode.Only
|
|
147
|
+
? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)'
|
|
148
|
+
: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg) var(--spacing-tokens-size-in-px-spacing-spacing-3xl)',
|
|
145
149
|
fontSize: 'var(--global-font-size-3)',
|
|
146
150
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
147
151
|
},
|
|
148
152
|
[ButtonSize.lg]: {
|
|
149
153
|
width: displayIconMode === ButtonDisplayMode.Only ? '3rem' : '11.75rem',
|
|
150
154
|
height: '3rem',
|
|
151
|
-
padding: displayIconMode === ButtonDisplayMode.Only
|
|
155
|
+
padding: displayIconMode === ButtonDisplayMode.Only
|
|
156
|
+
? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)'
|
|
157
|
+
: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg) var(--spacing-tokens-size-in-px-spacing-spacing-2xl)',
|
|
152
158
|
fontSize: 'var(--global-font-size-3)',
|
|
153
159
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
154
160
|
},
|
|
155
161
|
[ButtonSize.md]: {
|
|
156
162
|
width: displayIconMode === ButtonDisplayMode.Only ? '2.75rem' : '10.75rem',
|
|
157
163
|
height: '2.75rem',
|
|
158
|
-
padding: displayIconMode === ButtonDisplayMode.Only
|
|
164
|
+
padding: displayIconMode === ButtonDisplayMode.Only
|
|
165
|
+
? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)'
|
|
166
|
+
: 'var(--spacing-tokens-size-in-px-spacing-spacing-md) var(--spacing-tokens-size-in-px-spacing-spacing-xl)',
|
|
159
167
|
fontSize: 'var(--global-font-size-2)',
|
|
160
168
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
161
169
|
},
|
|
162
170
|
[ButtonSize.sm]: {
|
|
163
171
|
width: displayIconMode === ButtonDisplayMode.Only ? '2.5rem' : '9.75rem',
|
|
164
172
|
height: '2.5rem',
|
|
165
|
-
padding: displayIconMode === ButtonDisplayMode.Only
|
|
173
|
+
padding: displayIconMode === ButtonDisplayMode.Only
|
|
174
|
+
? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)'
|
|
175
|
+
: 'var(--spacing-tokens-size-in-px-spacing-spacing-md) var(--spacing-tokens-size-in-px-spacing-spacing-xl)',
|
|
166
176
|
fontSize: 'var(--global-font-size-1)',
|
|
167
177
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
|
|
168
178
|
},
|
|
169
179
|
[ButtonSize.xs]: {
|
|
170
180
|
width: displayIconMode === ButtonDisplayMode.Only ? '2.25rem' : '8.75rem',
|
|
171
181
|
height: '2.25rem',
|
|
172
|
-
padding: displayIconMode === ButtonDisplayMode.Only
|
|
182
|
+
padding: displayIconMode === ButtonDisplayMode.Only
|
|
183
|
+
? 'var(--spacing-tokens-size-in-px-spacing-spacing-md)'
|
|
184
|
+
: 'var(--spacing-tokens-size-in-px-spacing-spacing-md) var(--spacing-tokens-size-in-px-spacing-spacing-lg)',
|
|
173
185
|
fontSize: 'var(--global-font-size-1)',
|
|
174
186
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
|
|
175
187
|
},
|
|
176
188
|
[ButtonSize.xxs]: {
|
|
177
189
|
width: displayIconMode === ButtonDisplayMode.Only ? '2rem' : '7.75rem',
|
|
178
190
|
height: '2rem',
|
|
179
|
-
padding: displayIconMode === ButtonDisplayMode.Only
|
|
191
|
+
padding: displayIconMode === ButtonDisplayMode.Only
|
|
192
|
+
? 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)'
|
|
193
|
+
: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm) var(--spacing-tokens-size-in-px-spacing-spacing-md)',
|
|
180
194
|
fontSize: 'var(--global-font-size-0)',
|
|
181
195
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
|
|
182
|
-
}
|
|
196
|
+
},
|
|
183
197
|
};
|
|
184
198
|
return sizes[size] || sizes[ButtonSize.xl];
|
|
185
199
|
};
|
|
@@ -200,35 +214,60 @@ export const MainButton = ({ onClick, text, disabled = false, loading = false, t
|
|
|
200
214
|
[ButtonSize.md]: 20,
|
|
201
215
|
[ButtonSize.sm]: 18,
|
|
202
216
|
[ButtonSize.xs]: 16,
|
|
203
|
-
[ButtonSize.xxs]: 14
|
|
217
|
+
[ButtonSize.xxs]: 14,
|
|
204
218
|
};
|
|
205
219
|
return sizes[size] || sizes[ButtonSize.xl];
|
|
206
220
|
};
|
|
207
221
|
const iconProps = {
|
|
208
222
|
size: getIconSize(),
|
|
209
223
|
color: getTextColor(),
|
|
210
|
-
weight:
|
|
224
|
+
weight: 'regular',
|
|
211
225
|
};
|
|
212
226
|
const sizeStyles = getButtonSize();
|
|
213
227
|
const renderContent = () => {
|
|
214
228
|
if (loading) {
|
|
215
229
|
return (_jsx(CircularProgress, { size: 24, sx: {
|
|
216
|
-
color: getTextColor()
|
|
230
|
+
color: getTextColor(),
|
|
217
231
|
} }));
|
|
218
232
|
}
|
|
219
233
|
if (displayIconMode === ButtonDisplayMode.Only && displayIcon) {
|
|
220
234
|
return getIconComponent(displayIcon, iconProps);
|
|
221
235
|
}
|
|
222
|
-
|
|
236
|
+
const getTextSize = () => {
|
|
237
|
+
if (size === ButtonSize.xl)
|
|
238
|
+
return TypographySize.TextL;
|
|
239
|
+
if (size === ButtonSize.lg)
|
|
240
|
+
return TypographySize.TextM;
|
|
241
|
+
if (size === ButtonSize.md)
|
|
242
|
+
return TypographySize.TextS;
|
|
243
|
+
if (size === ButtonSize.sm)
|
|
244
|
+
return TypographySize.TextXS;
|
|
245
|
+
if (size === ButtonSize.xs)
|
|
246
|
+
return TypographySize.Text2XS;
|
|
247
|
+
if (size === ButtonSize.xxs)
|
|
248
|
+
return TypographySize.Text2XS;
|
|
249
|
+
return TypographySize.TextM;
|
|
250
|
+
};
|
|
251
|
+
return (_jsxs("div", { style: {
|
|
252
|
+
display: 'flex',
|
|
253
|
+
alignItems: 'center',
|
|
254
|
+
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
255
|
+
}, children: [showLeadingIcon &&
|
|
256
|
+
leadingIcon &&
|
|
257
|
+
getIconComponent(leadingIcon, iconProps), _jsx(Typography, { text: text, size: getTextSize(), weight: TypographyWeight.SemiBold }), showTrailingIcon &&
|
|
258
|
+
trailingIcon &&
|
|
259
|
+
getIconComponent(trailingIcon, iconProps)] }));
|
|
223
260
|
};
|
|
224
261
|
return (_jsx(Button, { onClick: onClick ? onClick : () => { }, type: type, disabled: state === ButtonState.Disabled || disabled, sx: {
|
|
225
|
-
textTransform:
|
|
262
|
+
textTransform: 'none',
|
|
226
263
|
...sizeStyles,
|
|
227
264
|
borderRadius: getButtonShape(),
|
|
228
265
|
background: getBackgroundColor(),
|
|
229
266
|
color: getTextColor(),
|
|
230
267
|
border: `1px solid ${getBorderColor()}`,
|
|
231
|
-
boxShadow: state === ButtonState.
|
|
268
|
+
boxShadow: state === ButtonState.Hover
|
|
269
|
+
? 'var(--global-shadows-shadow-xs-offset-x) var(--global-shadows-shadow-xs-offset-y) var(--global-shadows-shadow-xs-blur) var(--global-shadows-shadow-xs-spread) var(--global-shadows-shadow-xs-color)'
|
|
270
|
+
: 'none',
|
|
232
271
|
display: 'flex',
|
|
233
272
|
alignItems: 'center',
|
|
234
273
|
justifyContent: 'center',
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { MainButton } from './Button';
|
|
3
|
+
declare const meta: Meta<typeof MainButton>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof MainButton>;
|
|
6
|
+
export declare const Primary: Story;
|
|
7
|
+
export declare const Secondary: Story;
|
|
8
|
+
export declare const SecondaryColor: Story;
|
|
9
|
+
export declare const SecondaryTransparent: Story;
|
|
10
|
+
export declare const Tetriary: Story;
|
|
11
|
+
export declare const TetriaryColor: Story;
|
|
12
|
+
export declare const PrimaryHover: Story;
|
|
13
|
+
export declare const PrimaryDisabled: Story;
|
|
14
|
+
export declare const IconOnly: Story;
|
|
15
|
+
export declare const IconOnlyHover: Story;
|
|
16
|
+
export declare const IconOnlyDisabled: Story;
|
|
17
|
+
export declare const Destructive: Story;
|
|
18
|
+
export declare const DestructiveHover: Story;
|
|
19
|
+
export declare const DestructiveDisabled: Story;
|
|
20
|
+
export declare const Large: Story;
|
|
21
|
+
export declare const Medium: Story;
|
|
22
|
+
export declare const Small: Story;
|
|
23
|
+
export declare const ExtraSmall: Story;
|
|
24
|
+
export declare const ExtraExtraSmall: Story;
|
|
25
|
+
export declare const CircularButton: Story;
|
|
26
|
+
export declare const CircularButtonHover: Story;
|
|
27
|
+
export declare const CircularButtonDisabled: Story;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { MainButton } from './Button';
|
|
2
|
+
import { ButtonShape, ButtonState } from './types/button';
|
|
3
|
+
import { ButtonDisplayMode } from './types/button';
|
|
4
|
+
import { ButtonHierarchy } from './types/button';
|
|
5
|
+
import { ButtonSize } from './types/button';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Design System/Components/Button',
|
|
8
|
+
component: MainButton,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
design: {
|
|
12
|
+
type: 'figspec',
|
|
13
|
+
url: 'https://www.figma.com/design/mIhjz2yJjcpLlIqw6oUivt/Beyond-Presence?node-id=4339-3441&t=21PpejYhkGTLCVlu-4',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
argTypes: {
|
|
18
|
+
text: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Button text content',
|
|
21
|
+
table: {
|
|
22
|
+
type: { summary: 'string' },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
control: 'select',
|
|
27
|
+
options: ['xl', 'lg', 'md', 'sm', 'xs', 'xxs'],
|
|
28
|
+
description: 'Size of the button',
|
|
29
|
+
table: {
|
|
30
|
+
type: { summary: 'string' },
|
|
31
|
+
defaultValue: { summary: 'xl' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
hierarchy: {
|
|
35
|
+
control: 'select',
|
|
36
|
+
options: [
|
|
37
|
+
'Primary',
|
|
38
|
+
'Secondary',
|
|
39
|
+
'Secondary-color',
|
|
40
|
+
'Secondary-transparent',
|
|
41
|
+
'Tetriary',
|
|
42
|
+
'Tetriary-color',
|
|
43
|
+
],
|
|
44
|
+
description: 'Visual hierarchy of the button',
|
|
45
|
+
table: {
|
|
46
|
+
type: { summary: 'string' },
|
|
47
|
+
defaultValue: { summary: 'Primary' },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
displayIcon: {
|
|
51
|
+
control: 'text',
|
|
52
|
+
description: 'Name of the display Phosphor icon (e.g., "Circle", "AndroidLogo", "Armchair")',
|
|
53
|
+
table: {
|
|
54
|
+
type: { summary: 'string' },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
displayIconMode: {
|
|
58
|
+
control: 'select',
|
|
59
|
+
options: ['Default', 'Only'],
|
|
60
|
+
description: 'Icon display mode - Default shows text with icons, Only shows a single icon without text',
|
|
61
|
+
table: {
|
|
62
|
+
type: { summary: 'string' },
|
|
63
|
+
defaultValue: { summary: 'Default' },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
state: {
|
|
67
|
+
control: 'select',
|
|
68
|
+
options: ['Default', 'Hover', 'Disabled'],
|
|
69
|
+
description: 'Current state of the button',
|
|
70
|
+
table: {
|
|
71
|
+
type: { summary: 'string' },
|
|
72
|
+
defaultValue: { summary: 'Default' },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
shape: {
|
|
76
|
+
control: 'select',
|
|
77
|
+
options: ['Square', 'Circle'],
|
|
78
|
+
description: 'Shape of the button',
|
|
79
|
+
table: {
|
|
80
|
+
type: { summary: 'string' },
|
|
81
|
+
defaultValue: { summary: 'Square' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
destructive: {
|
|
85
|
+
control: 'boolean',
|
|
86
|
+
description: 'Whether the button is destructive',
|
|
87
|
+
table: {
|
|
88
|
+
type: { summary: 'boolean' },
|
|
89
|
+
defaultValue: { summary: 'false' },
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
loading: {
|
|
93
|
+
control: 'boolean',
|
|
94
|
+
description: 'Whether the button is in loading state',
|
|
95
|
+
table: {
|
|
96
|
+
type: { summary: 'boolean' },
|
|
97
|
+
defaultValue: { summary: 'false' },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
showLeadingIcon: {
|
|
101
|
+
control: 'boolean',
|
|
102
|
+
description: 'Whether to show the leading icon',
|
|
103
|
+
table: {
|
|
104
|
+
type: { summary: 'boolean' },
|
|
105
|
+
defaultValue: { summary: 'true' },
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
showTrailingIcon: {
|
|
109
|
+
control: 'boolean',
|
|
110
|
+
description: 'Whether to show the trailing icon',
|
|
111
|
+
table: {
|
|
112
|
+
type: { summary: 'boolean' },
|
|
113
|
+
defaultValue: { summary: 'true' },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
leadingIcon: {
|
|
117
|
+
control: 'text',
|
|
118
|
+
description: 'Name of the leading Phosphor icon (e.g., "Circle", "AndroidLogo", "Armchair")',
|
|
119
|
+
table: {
|
|
120
|
+
type: { summary: 'string' },
|
|
121
|
+
defaultValue: { summary: 'Circle' },
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
trailingIcon: {
|
|
125
|
+
control: 'text',
|
|
126
|
+
description: 'Name of the trailing Phosphor icon (e.g., "Circle", "AndroidLogo", "Armchair")',
|
|
127
|
+
table: {
|
|
128
|
+
type: { summary: 'string' },
|
|
129
|
+
defaultValue: { summary: 'Circle' },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
export default meta;
|
|
135
|
+
export const Primary = {
|
|
136
|
+
args: {
|
|
137
|
+
text: 'Button',
|
|
138
|
+
size: ButtonSize.xl,
|
|
139
|
+
hierarchy: ButtonHierarchy.Primary,
|
|
140
|
+
displayIconMode: ButtonDisplayMode.Default,
|
|
141
|
+
state: ButtonState.Default,
|
|
142
|
+
shape: ButtonShape.Square,
|
|
143
|
+
destructive: false,
|
|
144
|
+
showLeadingIcon: true,
|
|
145
|
+
showTrailingIcon: true,
|
|
146
|
+
leadingIcon: 'Circle',
|
|
147
|
+
trailingIcon: 'Circle',
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
export const Secondary = {
|
|
151
|
+
args: {
|
|
152
|
+
...Primary.args,
|
|
153
|
+
text: 'Button',
|
|
154
|
+
hierarchy: ButtonHierarchy.Secondary,
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
export const SecondaryColor = {
|
|
158
|
+
args: {
|
|
159
|
+
...Primary.args,
|
|
160
|
+
text: 'Button',
|
|
161
|
+
hierarchy: ButtonHierarchy.SecondaryColor,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
export const SecondaryTransparent = {
|
|
165
|
+
args: {
|
|
166
|
+
...Primary.args,
|
|
167
|
+
text: 'Button',
|
|
168
|
+
hierarchy: ButtonHierarchy.SecondaryTransparent,
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
export const Tetriary = {
|
|
172
|
+
args: {
|
|
173
|
+
...Primary.args,
|
|
174
|
+
text: 'Button',
|
|
175
|
+
hierarchy: ButtonHierarchy.Tetriary,
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
export const TetriaryColor = {
|
|
179
|
+
args: {
|
|
180
|
+
...Primary.args,
|
|
181
|
+
text: 'Button',
|
|
182
|
+
hierarchy: ButtonHierarchy.TetriaryColor,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
export const PrimaryHover = {
|
|
186
|
+
args: {
|
|
187
|
+
...Primary.args,
|
|
188
|
+
state: ButtonState.Hover,
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
export const PrimaryDisabled = {
|
|
192
|
+
args: {
|
|
193
|
+
...Primary.args,
|
|
194
|
+
state: ButtonState.Disabled,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
export const IconOnly = {
|
|
198
|
+
args: {
|
|
199
|
+
displayIconMode: ButtonDisplayMode.Only,
|
|
200
|
+
displayIcon: 'AndroidLogo',
|
|
201
|
+
size: ButtonSize.xl,
|
|
202
|
+
hierarchy: ButtonHierarchy.Primary,
|
|
203
|
+
state: ButtonState.Default,
|
|
204
|
+
shape: ButtonShape.Square,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
export const IconOnlyHover = {
|
|
208
|
+
args: {
|
|
209
|
+
...IconOnly.args,
|
|
210
|
+
state: ButtonState.Hover,
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
export const IconOnlyDisabled = {
|
|
214
|
+
args: {
|
|
215
|
+
...IconOnly.args,
|
|
216
|
+
state: ButtonState.Disabled,
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
export const Destructive = {
|
|
220
|
+
args: {
|
|
221
|
+
...Primary.args,
|
|
222
|
+
text: 'Button',
|
|
223
|
+
destructive: true,
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
export const DestructiveHover = {
|
|
227
|
+
args: {
|
|
228
|
+
...Destructive.args,
|
|
229
|
+
state: ButtonState.Hover,
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
export const DestructiveDisabled = {
|
|
233
|
+
args: {
|
|
234
|
+
...Destructive.args,
|
|
235
|
+
state: ButtonState.Disabled,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
export const Large = {
|
|
239
|
+
args: {
|
|
240
|
+
...Primary.args,
|
|
241
|
+
size: ButtonSize.lg,
|
|
242
|
+
text: 'Button',
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
export const Medium = {
|
|
246
|
+
args: {
|
|
247
|
+
...Primary.args,
|
|
248
|
+
size: ButtonSize.md,
|
|
249
|
+
text: 'Button',
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
export const Small = {
|
|
253
|
+
args: {
|
|
254
|
+
...Primary.args,
|
|
255
|
+
size: ButtonSize.sm,
|
|
256
|
+
text: 'Button',
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
export const ExtraSmall = {
|
|
260
|
+
args: {
|
|
261
|
+
...Primary.args,
|
|
262
|
+
size: ButtonSize.xs,
|
|
263
|
+
text: 'Button',
|
|
264
|
+
},
|
|
265
|
+
};
|
|
266
|
+
export const ExtraExtraSmall = {
|
|
267
|
+
args: {
|
|
268
|
+
...Primary.args,
|
|
269
|
+
size: ButtonSize.xxs,
|
|
270
|
+
text: 'Button',
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
export const CircularButton = {
|
|
274
|
+
args: {
|
|
275
|
+
text: 'Button',
|
|
276
|
+
size: ButtonSize.xl,
|
|
277
|
+
hierarchy: ButtonHierarchy.Primary,
|
|
278
|
+
displayIconMode: ButtonDisplayMode.Only,
|
|
279
|
+
displayIcon: 'Circle',
|
|
280
|
+
shape: ButtonShape.Circle,
|
|
281
|
+
state: ButtonState.Default,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
export const CircularButtonHover = {
|
|
285
|
+
args: {
|
|
286
|
+
...CircularButton.args,
|
|
287
|
+
state: ButtonState.Hover,
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
export const CircularButtonDisabled = {
|
|
291
|
+
args: {
|
|
292
|
+
...CircularButton.args,
|
|
293
|
+
state: ButtonState.Disabled,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Checkbox as MuiCheckbox } from '@mui/material';
|
|
3
|
+
import { CheckboxType } from './types/checkbox';
|
|
4
|
+
import { Typography } from './Typography';
|
|
5
|
+
import { TypographySize, TypographyWeight } from './types/typography';
|
|
6
|
+
export const Checkbox = ({ type = CheckboxType.Checkbox, label, checked, disabled, required, onChange, }) => {
|
|
7
|
+
const props = {
|
|
8
|
+
checked,
|
|
9
|
+
disabled,
|
|
10
|
+
required,
|
|
11
|
+
onChange,
|
|
12
|
+
disableRipple: true,
|
|
13
|
+
};
|
|
14
|
+
const handleRadioClick = () => {
|
|
15
|
+
if (!disabled && onChange) {
|
|
16
|
+
const event = {
|
|
17
|
+
target: { checked: !checked },
|
|
18
|
+
};
|
|
19
|
+
onChange(event);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [type === CheckboxType.Checkbox ? (_jsx(MuiCheckbox, { ...props, sx: {
|
|
23
|
+
padding: 0,
|
|
24
|
+
'&.Mui-checked': {
|
|
25
|
+
color: disabled
|
|
26
|
+
? 'var(--colors-light-background-bg-button-disabled)'
|
|
27
|
+
: 'var(--colors-light-background-bg-brand)',
|
|
28
|
+
borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
|
|
29
|
+
'&:hover': {
|
|
30
|
+
color: 'var(--colors-light-background-bg-brand-hover)',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
} })) : type === CheckboxType.Radio ? (_jsx(Box, { onClick: handleRadioClick, sx: {
|
|
34
|
+
width: '20px',
|
|
35
|
+
height: '20px',
|
|
36
|
+
borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-full)',
|
|
37
|
+
border: checked ? '6px solid' : '1px solid',
|
|
38
|
+
borderColor: disabled
|
|
39
|
+
? 'var(--colors-light-background-bg-button-disabled)'
|
|
40
|
+
: checked
|
|
41
|
+
? 'var(--colors-light-background-bg-brand)'
|
|
42
|
+
: 'var(--colors-light-background-bg-button-disabled)',
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
47
|
+
position: 'relative',
|
|
48
|
+
backgroundColor: 'transparent',
|
|
49
|
+
boxSizing: 'border-box',
|
|
50
|
+
transition: 'all 0.2s ease-in-out',
|
|
51
|
+
'&:hover': !disabled
|
|
52
|
+
? {
|
|
53
|
+
borderColor: 'var(--colors-light-background-bg-brand-hover)',
|
|
54
|
+
}
|
|
55
|
+
: undefined,
|
|
56
|
+
'&::after': {
|
|
57
|
+
content: '""',
|
|
58
|
+
position: 'absolute',
|
|
59
|
+
width: '10px',
|
|
60
|
+
height: '10px',
|
|
61
|
+
borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-full)',
|
|
62
|
+
backgroundColor: 'transparent',
|
|
63
|
+
transition: 'all 0.2s ease-in-out',
|
|
64
|
+
},
|
|
65
|
+
} })) : null, _jsx(Typography, { text: label, size: TypographySize.TextS, weight: TypographyWeight.Medium })] }));
|
|
66
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Checkbox } from './Checkbox';
|
|
3
|
+
declare const meta: Meta<typeof Checkbox>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Checked: Story;
|
|
8
|
+
export declare const DisabledUnchecked: Story;
|
|
9
|
+
export declare const DisabledChecked: Story;
|
|
10
|
+
export declare const Radio: Story;
|
|
11
|
+
export declare const RadioChecked: Story;
|
|
12
|
+
export declare const RadioDisabledUnchecked: Story;
|
|
13
|
+
export declare const RadioDisabledChecked: Story;
|