@beydesign/storybook 0.1.8 → 0.1.9
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/dist/stories/UI/Stepper.d.ts +3 -0
- package/dist/stories/UI/Stepper.js +58 -0
- package/dist/stories/UI/Stepper.stories.d.ts +6 -0
- package/dist/stories/UI/Stepper.stories.js +65 -0
- package/dist/stories/UI/index.d.ts +1 -0
- package/dist/stories/UI/index.js +1 -0
- package/dist/stories/UI/types.d.ts +32 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
4
|
+
import { getIconComponent } from '../../utils';
|
|
5
|
+
export const Stepper = ({ steps, currentStep, onStepClick, style, testId, connectorWidth, stepStyle, }) => {
|
|
6
|
+
return (_jsx(Box, { borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', sx: style, "data-testId": testId, display: 'flex', flexDirection: 'row', alignItems: 'center', children: steps.map((step, index) => (_jsx(Step, { currentStep: currentStep, index: index, title: step, onClick: () => onStepClick(index), totalSteps: steps.length, connectorWidth: connectorWidth, stepStyle: stepStyle }, index))) }));
|
|
7
|
+
};
|
|
8
|
+
const Step = ({ currentStep, totalSteps, index, title, onClick, connectorWidth = '70px', stepStyle, }) => {
|
|
9
|
+
const thisStep = index + 1;
|
|
10
|
+
const isDisabled = currentStep < thisStep;
|
|
11
|
+
const isCurrent = currentStep === thisStep;
|
|
12
|
+
const isCompleted = currentStep > thisStep;
|
|
13
|
+
const getTextColor = () => {
|
|
14
|
+
if (isDisabled)
|
|
15
|
+
return 'var(--colors-light-text-text-paragraph)';
|
|
16
|
+
else if (isCurrent)
|
|
17
|
+
return 'var(--colors-light-text-text-clicable)';
|
|
18
|
+
else if (isCompleted)
|
|
19
|
+
return 'var(--colors-light-text-text-title)';
|
|
20
|
+
else
|
|
21
|
+
return 'var(--colors-light-text-text-paragraph)';
|
|
22
|
+
};
|
|
23
|
+
const getIconColor = () => {
|
|
24
|
+
if (isDisabled)
|
|
25
|
+
return 'var(--colors-light-foreground-fg-disabled)';
|
|
26
|
+
else if (isCurrent)
|
|
27
|
+
return 'var(--colors-light-background-bg-brand)';
|
|
28
|
+
else if (isCompleted)
|
|
29
|
+
return 'var(--colors-light-background-bg-brand)';
|
|
30
|
+
else
|
|
31
|
+
return 'var(--colors-light-foreground-fg-secondary)';
|
|
32
|
+
};
|
|
33
|
+
const IconComponent = getIconComponent('CheckCircle', {
|
|
34
|
+
size: '24px',
|
|
35
|
+
color: getIconColor(),
|
|
36
|
+
weight: isCompleted ? 'fill' : 'regular',
|
|
37
|
+
onClick: onClick,
|
|
38
|
+
});
|
|
39
|
+
const getConnectorColor = (position) => {
|
|
40
|
+
if (position === 'left') {
|
|
41
|
+
if (thisStep === 1)
|
|
42
|
+
return 'transparent';
|
|
43
|
+
else if (thisStep <= currentStep)
|
|
44
|
+
return 'var(--colors-light-background-bg-brand)';
|
|
45
|
+
else
|
|
46
|
+
return 'var(--colors-light-foreground-fg-disabled)';
|
|
47
|
+
}
|
|
48
|
+
else if (position === 'right') {
|
|
49
|
+
if (thisStep === totalSteps)
|
|
50
|
+
return 'transparent';
|
|
51
|
+
else if (thisStep < currentStep)
|
|
52
|
+
return 'var(--colors-light-background-bg-brand)';
|
|
53
|
+
else
|
|
54
|
+
return 'var(--colors-light-foreground-fg-disabled)';
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return (_jsxs(Box, { display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', sx: stepStyle, children: [_jsxs(Box, { display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', children: [_jsx(Box, { height: '1px', bgcolor: getConnectorColor('left'), width: connectorWidth, borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)' }), IconComponent, _jsx(Box, { height: '1px', bgcolor: getConnectorColor('right'), width: connectorWidth, borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)' })] }), _jsx(Box, { onClick: onClick, children: _jsx(Typography, { size: TypographySize.TextM, weight: TypographyWeight.SemiBold, color: getTextColor(), children: title }) })] }));
|
|
58
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Stepper } from './Stepper';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Design System/Components/UI/Stepper',
|
|
4
|
+
component: Stepper,
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'centered',
|
|
7
|
+
design: {
|
|
8
|
+
type: 'figspec',
|
|
9
|
+
url: '',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
tags: ['autodocs'],
|
|
13
|
+
argTypes: {
|
|
14
|
+
currentStep: {
|
|
15
|
+
control: 'number',
|
|
16
|
+
description: 'Current step of the stepper',
|
|
17
|
+
table: {
|
|
18
|
+
type: { summary: 'number' },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
steps: {
|
|
22
|
+
control: 'object',
|
|
23
|
+
description: 'Steps of the stepper',
|
|
24
|
+
table: {
|
|
25
|
+
type: { summary: 'object' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
onStepClick: {
|
|
29
|
+
description: 'Function to call when a step is clicked',
|
|
30
|
+
table: {
|
|
31
|
+
type: { summary: 'function' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
style: {
|
|
35
|
+
control: 'object',
|
|
36
|
+
description: 'Style of the stepper',
|
|
37
|
+
table: {
|
|
38
|
+
type: { summary: 'object' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
testId: {
|
|
42
|
+
control: 'text',
|
|
43
|
+
description: 'Test ID of the stepper',
|
|
44
|
+
table: {
|
|
45
|
+
type: { summary: 'string' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
export default meta;
|
|
51
|
+
export const Default = {
|
|
52
|
+
args: {
|
|
53
|
+
currentStep: 1,
|
|
54
|
+
steps: [
|
|
55
|
+
'Lighting, Audio & Setup',
|
|
56
|
+
'Beginning',
|
|
57
|
+
'Speaking Phase',
|
|
58
|
+
'Ending',
|
|
59
|
+
'Final Checklist',
|
|
60
|
+
],
|
|
61
|
+
onStepClick: () => { },
|
|
62
|
+
style: {},
|
|
63
|
+
testId: 'stepper',
|
|
64
|
+
},
|
|
65
|
+
};
|
package/dist/stories/UI/index.js
CHANGED
|
@@ -232,3 +232,35 @@ export interface TopbarProps {
|
|
|
232
232
|
/** Class name */
|
|
233
233
|
className?: string;
|
|
234
234
|
}
|
|
235
|
+
export interface StepProps {
|
|
236
|
+
/** Current step of the stepper */
|
|
237
|
+
currentStep: number;
|
|
238
|
+
/** Total steps of the stepper */
|
|
239
|
+
totalSteps: number;
|
|
240
|
+
/** Index of the step */
|
|
241
|
+
index: number;
|
|
242
|
+
/** Title of the step */
|
|
243
|
+
title: string;
|
|
244
|
+
/** On click of the step */
|
|
245
|
+
onClick?: () => void;
|
|
246
|
+
/** Connector width of the step */
|
|
247
|
+
connectorWidth?: string | number;
|
|
248
|
+
/** Style of the step */
|
|
249
|
+
stepStyle?: SxProps<Theme>;
|
|
250
|
+
}
|
|
251
|
+
export interface StepperProps {
|
|
252
|
+
/** Steps of the stepper */
|
|
253
|
+
steps: string[];
|
|
254
|
+
/** Current step of the stepper */
|
|
255
|
+
currentStep: number;
|
|
256
|
+
/** On click of the step */
|
|
257
|
+
onStepClick: (step: number) => void;
|
|
258
|
+
/** Style of the stepper */
|
|
259
|
+
style?: SxProps<Theme>;
|
|
260
|
+
/** Style of the step */
|
|
261
|
+
stepStyle?: SxProps<Theme>;
|
|
262
|
+
/** Test ID of the stepper */
|
|
263
|
+
testId?: string;
|
|
264
|
+
/** Connector width of the stepper */
|
|
265
|
+
connectorWidth?: string | number;
|
|
266
|
+
}
|