@beydesign/storybook 0.1.8 → 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: `${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, children: `${currentValue.toLocaleString(undefined, { maximumFractionDigits: 2 })}%` }))] }));
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,
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { StepperProps } from './types';
3
+ export declare const Stepper: React.FC<StepperProps>;
@@ -0,0 +1,59 @@
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 ? () => onStepClick(index) : undefined, 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
+ style: { cursor: onClick ? 'pointer' : 'default' },
39
+ });
40
+ const getConnectorColor = (position) => {
41
+ if (position === 'left') {
42
+ if (thisStep === 1)
43
+ return 'transparent';
44
+ else if (thisStep <= currentStep)
45
+ return 'var(--colors-light-background-bg-brand)';
46
+ else
47
+ return 'var(--colors-light-foreground-fg-disabled)';
48
+ }
49
+ else if (position === 'right') {
50
+ if (thisStep === totalSteps)
51
+ return 'transparent';
52
+ else if (thisStep < currentStep)
53
+ return 'var(--colors-light-background-bg-brand)';
54
+ else
55
+ return 'var(--colors-light-foreground-fg-disabled)';
56
+ }
57
+ };
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 }) })] }));
59
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Stepper } from './Stepper';
3
+ declare const meta: Meta<typeof Stepper>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Stepper>;
6
+ export declare const Default: Story;
@@ -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
+ };
@@ -7,3 +7,4 @@ export * from './ProgressIndicator';
7
7
  export * from './SkeletonLoader';
8
8
  export * from './Topbar';
9
9
  export * from './types';
10
+ export * from './Stepper';
@@ -7,3 +7,4 @@ export * from './ProgressIndicator';
7
7
  export * from './SkeletonLoader';
8
8
  export * from './Topbar';
9
9
  export * from './types';
10
+ export * from './Stepper';
@@ -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 */
@@ -232,3 +234,35 @@ export interface TopbarProps {
232
234
  /** Class name */
233
235
  className?: string;
234
236
  }
237
+ export interface StepProps {
238
+ /** Current step of the stepper */
239
+ currentStep: number;
240
+ /** Total steps of the stepper */
241
+ totalSteps: number;
242
+ /** Index of the step */
243
+ index: number;
244
+ /** Title of the step */
245
+ title: string;
246
+ /** On click of the step */
247
+ onClick?: () => void;
248
+ /** Connector width of the step */
249
+ connectorWidth?: string | number;
250
+ /** Style of the step */
251
+ stepStyle?: SxProps<Theme>;
252
+ }
253
+ export interface StepperProps {
254
+ /** Steps of the stepper */
255
+ steps: string[];
256
+ /** Current step of the stepper */
257
+ currentStep: number;
258
+ /** On click of the step */
259
+ onStepClick?: (step: number) => void;
260
+ /** Style of the stepper */
261
+ style?: SxProps<Theme>;
262
+ /** Style of the step */
263
+ stepStyle?: SxProps<Theme>;
264
+ /** Test ID of the stepper */
265
+ testId?: string;
266
+ /** Connector width of the stepper */
267
+ connectorWidth?: string | number;
268
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.1.8",
4
+ "version": "0.1.10",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",