@beydesign/storybook 0.0.9 → 0.0.11

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/index.d.ts CHANGED
@@ -3,8 +3,12 @@ export { Avatar } from './stories/Avatar';
3
3
  export { Typography } from './stories/Typography';
4
4
  export { Badge } from './stories/Bagde';
5
5
  export { Checkbox } from './stories/Checkbox';
6
+ export { ToggleButtonGroup } from './stories/ToggleButtonGroup';
7
+ export { ProgressIndicator } from './stories/ProgressIndicator';
6
8
  export { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, type MainButtonProps, } from './stories/types/button';
7
9
  export { BadgeColor, BadgeSize, type BadgeProps } from './stories/types/badge';
8
10
  export { AvatarStyle, AvatarSize, type AvatarProps, } from './stories/types/avatar';
9
11
  export { TypographySize, TypographyWeight, type TypographyProps, } from './stories/types/typography';
10
12
  export { CheckboxType, type CheckboxProps } from './stories/types/checkbox';
13
+ export { ToggleButtonGroupSize, type ToggleButtonGroupProps, } from './stories/types/toggle-button-group';
14
+ export { ProgressIndicatorMode, type ProgressIndicatorProps, } from './stories/types/progress-indicator';
package/dist/index.js CHANGED
@@ -4,9 +4,13 @@ export { Avatar } from './stories/Avatar';
4
4
  export { Typography } from './stories/Typography';
5
5
  export { Badge } from './stories/Bagde';
6
6
  export { Checkbox } from './stories/Checkbox';
7
+ export { ToggleButtonGroup } from './stories/ToggleButtonGroup';
8
+ export { ProgressIndicator } from './stories/ProgressIndicator';
7
9
  // Types
8
10
  export { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, } from './stories/types/button';
9
11
  export { BadgeColor, BadgeSize } from './stories/types/badge';
10
12
  export { AvatarStyle, AvatarSize, } from './stories/types/avatar';
11
13
  export { TypographySize, TypographyWeight, } from './stories/types/typography';
12
14
  export { CheckboxType } from './stories/types/checkbox';
15
+ export { ToggleButtonGroupSize, } from './stories/types/toggle-button-group';
16
+ export { ProgressIndicatorMode, } from './stories/types/progress-indicator';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentsProps, ProgressIndicatorProps } from './types/progress-indicator';
3
+ export declare const ProgressIndicator: React.FC<ProgressIndicatorProps>;
4
+ export declare const Components: React.FC<ComponentsProps>;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ProgressIndicatorMode, } from './types/progress-indicator';
3
+ import { Box } from '@mui/material';
4
+ import { Typography } from './Typography';
5
+ import { TypographySize, TypographyWeight } from './types/typography';
6
+ 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, }) => {
7
+ let errorText = '';
8
+ const calculateFill = () => {
9
+ if (mode === ProgressIndicatorMode.Value) {
10
+ return (currentValue / maxValue) * 100;
11
+ }
12
+ else {
13
+ return currentValue;
14
+ }
15
+ };
16
+ if (!Number.isInteger(currentValue)) {
17
+ errorText = 'Current value must be an integer';
18
+ }
19
+ else if (!Number.isInteger(maxValue)) {
20
+ errorText = 'Max value must be an integer';
21
+ }
22
+ else if (currentValue < 0) {
23
+ errorText = 'Invalid current value';
24
+ }
25
+ else if (currentValue > maxValue) {
26
+ errorText = 'Current value is greater than max value';
27
+ }
28
+ else if (mode === ProgressIndicatorMode.Percentage) {
29
+ if (maxValue > 100 || maxValue < 0) {
30
+ errorText = 'Invalid max value for percentage mode';
31
+ }
32
+ }
33
+ if (errorText) {
34
+ return (_jsx(Typography, { text: errorText, size: TypographySize.TextXS, weight: TypographyWeight.Regular }));
35
+ }
36
+ 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, children: [mode === ProgressIndicatorMode.Value && (_jsx(Typography, { text: `${currentValue} / ${maxValue} ${text}`, size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor })), _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, { text: `${currentValue}%`, size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor }))] }));
37
+ };
38
+ export const Components = () => {
39
+ return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "Progress Indicator" }), _jsx("div", { style: { display: 'flex', gap: '1rem', flexDirection: 'column' } })] }));
40
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ProgressIndicator } from './ProgressIndicator';
3
+ declare const meta: Meta<typeof ProgressIndicator>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ProgressIndicator>;
6
+ export declare const Default: Story;
7
+ export declare const Percentage: Story;
8
+ export declare const Custom: Story;
@@ -0,0 +1,80 @@
1
+ import { ProgressIndicator } from './ProgressIndicator';
2
+ import { ProgressIndicatorMode } from './types/progress-indicator';
3
+ const meta = {
4
+ title: 'Design System/Components/ProgressIndicator',
5
+ component: ProgressIndicator,
6
+ parameters: {
7
+ layout: 'centered',
8
+ design: {
9
+ type: 'figspec',
10
+ url: 'https://www.figma.com/design/mIhjz2yJjcpLlIqw6oUivt/Beyond-Presence?node-id=4793-22258&t=3PJghL9RdZ71sldb-1',
11
+ },
12
+ },
13
+ tags: ['autodocs'],
14
+ argTypes: {
15
+ currentValue: {
16
+ control: 'number',
17
+ description: 'Current value of the progress indicator',
18
+ table: {
19
+ type: { summary: 'number' },
20
+ },
21
+ },
22
+ maxValue: {
23
+ control: 'number',
24
+ description: 'Maximum value of the progress indicator',
25
+ table: {
26
+ type: { summary: 'number' },
27
+ },
28
+ },
29
+ mode: {
30
+ control: 'select',
31
+ description: 'Mode of the progress indicator',
32
+ options: Object.values(ProgressIndicatorMode),
33
+ table: {
34
+ type: { summary: 'string' },
35
+ },
36
+ },
37
+ text: {
38
+ control: 'text',
39
+ description: 'Text of the progress indicator',
40
+ },
41
+ textColor: {
42
+ control: 'color',
43
+ description: 'Text color of the progress indicator',
44
+ },
45
+ fillColor: {
46
+ control: 'color',
47
+ description: 'Fill color of the progress indicator',
48
+ },
49
+ backgroundColor: {
50
+ control: 'color',
51
+ description: 'Background color of the progress indicator',
52
+ },
53
+ },
54
+ };
55
+ export default meta;
56
+ export const Default = {
57
+ args: {
58
+ mode: ProgressIndicatorMode.Value,
59
+ currentValue: 10,
60
+ maxValue: 100,
61
+ },
62
+ };
63
+ export const Percentage = {
64
+ args: {
65
+ mode: ProgressIndicatorMode.Percentage,
66
+ currentValue: 30,
67
+ maxValue: 100,
68
+ },
69
+ };
70
+ export const Custom = {
71
+ args: {
72
+ mode: ProgressIndicatorMode.Value,
73
+ currentValue: 10,
74
+ maxValue: 100,
75
+ backgroundColor: 'red',
76
+ fillColor: 'blue',
77
+ text: 'consumed',
78
+ textColor: 'purple',
79
+ },
80
+ };
@@ -0,0 +1,35 @@
1
+ import { Theme } from '@mui/material';
2
+ import { SxProps } from '@mui/material';
3
+ /**
4
+ * Progress indicator mode variants
5
+ */
6
+ export declare enum ProgressIndicatorMode {
7
+ Value = "Value",
8
+ Percentage = "Percentage"
9
+ }
10
+ /**
11
+ * Progress indicator component props
12
+ */
13
+ export type ProgressIndicatorProps = {
14
+ /** Mode variant of the progress indicator */
15
+ mode?: ProgressIndicatorMode;
16
+ /** Value of the progress indicator */
17
+ currentValue: number;
18
+ /** Maximum value of the progress indicator */
19
+ maxValue: number;
20
+ /** Fill color of the progress indicator */
21
+ fillColor?: string;
22
+ /** Background color of the progress indicator */
23
+ backgroundColor?: string;
24
+ /** Text of the progress indicator */
25
+ text?: string;
26
+ /** Text color of the progress indicator */
27
+ textColor?: string;
28
+ /** Style of the progress indicator */
29
+ style?: SxProps<Theme>;
30
+ };
31
+ /**
32
+ * Props for the Components wrapper
33
+ */
34
+ export interface ComponentsProps {
35
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Progress indicator mode variants
3
+ */
4
+ export var ProgressIndicatorMode;
5
+ (function (ProgressIndicatorMode) {
6
+ ProgressIndicatorMode["Value"] = "Value";
7
+ ProgressIndicatorMode["Percentage"] = "Percentage";
8
+ })(ProgressIndicatorMode || (ProgressIndicatorMode = {}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.0.9",
4
+ "version": "0.0.11",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",