@beydesign/storybook 0.1.9 → 0.1.10
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.
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { ProgressIndicatorMode } from './types';
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
5
|
-
export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, currentValue = 40, maxValue = 100, fillColor = 'var(--colors-light-background-bg-brand)', backgroundColor = 'var(--colors-light-background-bg-white)', text = 'used', textColor = 'var(--colors-light-text-text-primary)', style, testId, }) => {
|
|
5
|
+
export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, overriddenText = null, currentValue = 40, maxValue = 100, fillColor = 'var(--colors-light-background-bg-brand)', backgroundColor = 'var(--colors-light-background-bg-white)', text = 'used', textColor = 'var(--colors-light-text-text-primary)', style, testId, }) => {
|
|
6
6
|
let errorText = '';
|
|
7
7
|
const calculateFill = () => {
|
|
8
8
|
if (currentValue > maxValue)
|
|
@@ -29,5 +29,7 @@ export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, currentV
|
|
|
29
29
|
if (errorText) {
|
|
30
30
|
return (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, children: errorText }));
|
|
31
31
|
}
|
|
32
|
-
return (_jsxs(Box, { display: "flex", flexDirection: mode === ProgressIndicatorMode.Value ? 'column' : 'row', justifyContent: 'space-between', alignItems: mode === ProgressIndicatorMode.Value ? 'flex-end' : 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', sx: style, minWidth: 200, "data-testid": testId, children: [mode === ProgressIndicatorMode.Value && (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor, children:
|
|
32
|
+
return (_jsxs(Box, { display: "flex", flexDirection: mode === ProgressIndicatorMode.Value ? 'column' : 'row', justifyContent: 'space-between', alignItems: mode === ProgressIndicatorMode.Value ? 'flex-end' : 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', sx: style, minWidth: 200, "data-testid": testId, children: [mode === ProgressIndicatorMode.Value && (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor, children: overriddenText ||
|
|
33
|
+
`${currentValue.toLocaleString(undefined, { maximumFractionDigits: 2 })} / ${maxValue.toLocaleString(undefined, { maximumFractionDigits: 2 })} ${text}` })), _jsx(Box, { display: "flex", flexGrow: 1, flexDirection: "row", alignItems: "center", borderRadius: '4px', sx: { backgroundColor, overflow: 'hidden' }, height: '4px', width: '100%', children: _jsx(Box, { height: '100%', borderRadius: '4px', sx: { backgroundColor: fillColor, width: `${calculateFill()}%` } }) }), mode === ProgressIndicatorMode.Percentage && (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor, textStyle: { width: '100%' }, children: overriddenText ||
|
|
34
|
+
`${currentValue.toLocaleString(undefined, { maximumFractionDigits: 2 })}%` }))] }));
|
|
33
35
|
};
|
|
@@ -4,5 +4,7 @@ declare const meta: Meta<typeof ProgressIndicator>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof ProgressIndicator>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
+
export declare const ValueWithOverriddenText: Story;
|
|
7
8
|
export declare const Percentage: Story;
|
|
9
|
+
export declare const PercentageWithOverriddenText: Story;
|
|
8
10
|
export declare const Custom: Story;
|
|
@@ -60,6 +60,14 @@ export const Default = {
|
|
|
60
60
|
maxValue: 100,
|
|
61
61
|
},
|
|
62
62
|
};
|
|
63
|
+
export const ValueWithOverriddenText = {
|
|
64
|
+
args: {
|
|
65
|
+
mode: ProgressIndicatorMode.Value,
|
|
66
|
+
currentValue: 10,
|
|
67
|
+
maxValue: 100,
|
|
68
|
+
overriddenText: 'Step 10 of 100',
|
|
69
|
+
},
|
|
70
|
+
};
|
|
63
71
|
export const Percentage = {
|
|
64
72
|
args: {
|
|
65
73
|
mode: ProgressIndicatorMode.Percentage,
|
|
@@ -67,6 +75,14 @@ export const Percentage = {
|
|
|
67
75
|
maxValue: 100,
|
|
68
76
|
},
|
|
69
77
|
};
|
|
78
|
+
export const PercentageWithOverriddenText = {
|
|
79
|
+
args: {
|
|
80
|
+
mode: ProgressIndicatorMode.Percentage,
|
|
81
|
+
currentValue: 30,
|
|
82
|
+
maxValue: 100,
|
|
83
|
+
overriddenText: 'Step 30 of 100',
|
|
84
|
+
},
|
|
85
|
+
};
|
|
70
86
|
export const Custom = {
|
|
71
87
|
args: {
|
|
72
88
|
mode: ProgressIndicatorMode.Value,
|
|
@@ -3,7 +3,7 @@ import { Box } from '@mui/material';
|
|
|
3
3
|
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
4
4
|
import { getIconComponent } from '../../utils';
|
|
5
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))) }));
|
|
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 ? () => onStepClick(index) : undefined, totalSteps: steps.length, connectorWidth: connectorWidth, stepStyle: stepStyle }, index))) }));
|
|
7
7
|
};
|
|
8
8
|
const Step = ({ currentStep, totalSteps, index, title, onClick, connectorWidth = '70px', stepStyle, }) => {
|
|
9
9
|
const thisStep = index + 1;
|
|
@@ -34,7 +34,8 @@ const Step = ({ currentStep, totalSteps, index, title, onClick, connectorWidth =
|
|
|
34
34
|
size: '24px',
|
|
35
35
|
color: getIconColor(),
|
|
36
36
|
weight: isCompleted ? 'fill' : 'regular',
|
|
37
|
-
onClick: onClick,
|
|
37
|
+
onClick: () => onClick?.(),
|
|
38
|
+
style: { cursor: onClick ? 'pointer' : 'default' },
|
|
38
39
|
});
|
|
39
40
|
const getConnectorColor = (position) => {
|
|
40
41
|
if (position === 'left') {
|
|
@@ -54,5 +55,5 @@ const Step = ({ currentStep, totalSteps, index, title, onClick, connectorWidth =
|
|
|
54
55
|
return 'var(--colors-light-foreground-fg-disabled)';
|
|
55
56
|
}
|
|
56
57
|
};
|
|
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
|
+
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?.(), sx: { cursor: onClick ? 'pointer' : 'default' }, children: _jsx(Typography, { size: TypographySize.TextM, weight: TypographyWeight.SemiBold, color: getTextColor(), children: title }) })] }));
|
|
58
59
|
};
|
|
@@ -187,6 +187,8 @@ export type ProgressIndicatorProps = {
|
|
|
187
187
|
backgroundColor?: string;
|
|
188
188
|
/** Text of the progress indicator */
|
|
189
189
|
text?: string;
|
|
190
|
+
/** Overridden text of the progress indicator */
|
|
191
|
+
overriddenText?: string;
|
|
190
192
|
/** Text color of the progress indicator */
|
|
191
193
|
textColor?: string;
|
|
192
194
|
/** Style of the progress indicator */
|
|
@@ -254,7 +256,7 @@ export interface StepperProps {
|
|
|
254
256
|
/** Current step of the stepper */
|
|
255
257
|
currentStep: number;
|
|
256
258
|
/** On click of the step */
|
|
257
|
-
onStepClick
|
|
259
|
+
onStepClick?: (step: number) => void;
|
|
258
260
|
/** Style of the stepper */
|
|
259
261
|
style?: SxProps<Theme>;
|
|
260
262
|
/** Style of the step */
|