@beydesign/storybook 0.1.2 → 0.1.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/dist/stories/StripeProduct/StripeProduct.js +2 -2
- package/dist/stories/StripeProduct/StripeProductCardSkeleton.d.ts +3 -0
- package/dist/stories/StripeProduct/StripeProductCardSkeleton.js +6 -0
- package/dist/stories/StripeProduct/StripeProductCardSkeleton.stories.d.ts +16 -0
- package/dist/stories/StripeProduct/StripeProductCardSkeleton.stories.js +137 -0
- package/dist/stories/StripeProduct/index.d.ts +1 -0
- package/dist/stories/StripeProduct/index.js +1 -0
- package/dist/stories/StripeProduct/types.d.ts +23 -0
- package/dist/stories/UI/Badge.js +2 -2
- package/dist/stories/UI/ProgressIndicator.js +2 -2
- package/dist/stories/UI/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -5,12 +5,12 @@ import { ButtonHierarchy, ButtonSize, MainButton } from '../Buttons';
|
|
|
5
5
|
import { getIconComponent } from '../../utils';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { Badge, BadgeColor, BadgeSize } from '../UI';
|
|
8
|
-
export const StripeProduct = ({ className, description, features, isMostPopular, isEnterprisePlan, style, title, duration, price, buttonProps, bubbleText, bubbleTooltip, bubbleTopOffset, }) => {
|
|
8
|
+
export const StripeProduct = ({ className, description, features, isMostPopular, isEnterprisePlan, style, title, duration, price, buttonProps, bubbleText, bubbleTooltip, bubbleTopOffset, testId, }) => {
|
|
9
9
|
return (_jsxs(Box, { display: 'flex', flexDirection: 'column', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', paddingY: 'var(--spacing-tokens-size-in-px-spacing-spacing-2xl)', paddingX: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', bgcolor: isMostPopular
|
|
10
10
|
? 'var(--primitives-desktop-primary-brand-violet-50)'
|
|
11
11
|
: 'var(--colors-light-background-bg-white)', border: isMostPopular
|
|
12
12
|
? '1.5px solid var(--colors-light-border-border-brand)'
|
|
13
|
-
: 'none', position: 'relative', boxShadow: '0px 0px 10px 0px rgba(0, 0, 0, 0.1)', style: style, className: className, children: [bubbleText && (_jsx(Box, { position: 'absolute', top: bubbleTopOffset || '-4%', right: 0, left: 0, children: _jsx(Badge, { text: bubbleText, color: BadgeColor.Yellow, children: bubbleTooltip, size: BadgeSize.xs, fill: true }) })), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', children: [_jsx(Typography, { size: TypographySize.HeadingM, weight: TypographyWeight.Bold, color: 'var(--colors-light-text-text-title)', children: title }), isMostPopular && (_jsx(Box, { display: 'flex', justifyContent: 'center', alignItems: 'center', paddingX: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', paddingY: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', bgcolor: 'var(--primitives-desktop-primary-brand-violet-200)', borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-sm)', children: _jsx(Typography, { size: TypographySize.HeadingXS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-accent)', children: "Most popular" }) }))] }), _jsx(Typography, { size: TypographySize.HeadingM, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-paragraph)', textStyle: { textAlign: 'left', minHeight: '100px' }, children: description }), _jsx(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'end', children: isEnterprisePlan ? (_jsx(Typography, { size: TypographySize.HeadingL, weight: TypographyWeight.Bold, color: 'var(--colors-light-text-text-title)', children: "Custom" })) : (_jsxs(React.Fragment, { children: [_jsx(Typography, { size: TypographySize.HeadingL, weight: TypographyWeight.Bold, color: 'var(--colors-light-text-text-title)', children: price }), _jsxs(Typography, { size: TypographySize.HeadingXS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-paragraph)', children: ["/", duration] })] })) }), buttonProps && (_jsx(MainButton, { disabled: buttonProps?.disabled, loading: buttonProps?.loading, onClick: buttonProps?.onClick, text: buttonProps?.text, size: buttonProps?.size || ButtonSize.lg, hierarchy: buttonProps?.hierarchy || ButtonHierarchy.Primary, style: {
|
|
13
|
+
: 'none', position: 'relative', boxShadow: '0px 0px 10px 0px rgba(0, 0, 0, 0.1)', style: style, className: className, "data-testid": testId, children: [bubbleText && (_jsx(Box, { position: 'absolute', top: bubbleTopOffset || '-4%', right: 0, left: 0, children: _jsx(Badge, { text: bubbleText, color: BadgeColor.Yellow, children: bubbleTooltip, size: BadgeSize.xs, fill: true }) })), _jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', children: [_jsx(Typography, { size: TypographySize.HeadingM, weight: TypographyWeight.Bold, color: 'var(--colors-light-text-text-title)', children: title }), isMostPopular && (_jsx(Box, { display: 'flex', justifyContent: 'center', alignItems: 'center', paddingX: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', paddingY: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', bgcolor: 'var(--primitives-desktop-primary-brand-violet-200)', borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-sm)', children: _jsx(Typography, { size: TypographySize.HeadingXS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-accent)', children: "Most popular" }) }))] }), _jsx(Typography, { size: TypographySize.HeadingM, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-paragraph)', textStyle: { textAlign: 'left', minHeight: '100px' }, children: description }), _jsx(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'end', children: isEnterprisePlan ? (_jsx(Typography, { size: TypographySize.HeadingL, weight: TypographyWeight.Bold, color: 'var(--colors-light-text-text-title)', children: "Custom" })) : (_jsxs(React.Fragment, { children: [_jsx(Typography, { size: TypographySize.HeadingL, weight: TypographyWeight.Bold, color: 'var(--colors-light-text-text-title)', children: price }), _jsxs(Typography, { size: TypographySize.HeadingXS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-paragraph)', children: ["/", duration] })] })) }), buttonProps && (_jsx(MainButton, { disabled: buttonProps?.disabled, loading: buttonProps?.loading, onClick: buttonProps?.onClick, text: buttonProps?.text, size: buttonProps?.size || ButtonSize.lg, hierarchy: buttonProps?.hierarchy || ButtonHierarchy.Primary, style: {
|
|
14
14
|
margin: 'var(--spacing-tokens-size-in-px-spacing-spacing-3xl) 0',
|
|
15
15
|
} })), features && features?.length > 0 && (_jsxs(Box, { display: 'flex', flexDirection: 'column', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', alignItems: 'flex-start', children: [_jsx(Typography, { size: TypographySize.TextM, weight: TypographyWeight.Medium, color: 'var(--colors-light-text-text-title)', children: "This includes:" }), features.map((feature, index) => {
|
|
16
16
|
const isHeading = feature?.startsWith('-');
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { SkeletonLoader } from '../UI';
|
|
4
|
+
export const StripeProductCardSkeleton = ({ width = 'auto', showMostPopular = false, showBubble = false, showButton = true, showFeatures = true, featuresCount = 5, style, testId, }) => {
|
|
5
|
+
return (_jsxs(Box, { width: width, display: "flex", flexDirection: "column", borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', paddingY: 'var(--spacing-tokens-size-in-px-spacing-spacing-2xl)', paddingX: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', bgcolor: "var(--colors-light-background-bg-white)", position: "relative", boxShadow: '0px 0px 10px 0px rgba(0, 0, 0, 0.1)', style: style, "data-testid": testId, children: [showBubble && (_jsx(Box, { position: "absolute", top: "-4%", left: "50%", sx: { transform: 'translateX(-50%)' }, width: "50%", children: _jsx(SkeletonLoader, { height: "24px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }) })), _jsxs(Box, { display: "flex", flexDirection: "row", justifyContent: "space-between", alignItems: "center", children: [_jsx(SkeletonLoader, { width: "40%", height: "28px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), showMostPopular && (_jsx(SkeletonLoader, { width: "100px", height: "28px", borderRadius: "var(--spacing-tokens-size-in-px-radius-radius-sm)" }))] }), _jsxs(Box, { display: "flex", flexDirection: "column", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-sm)", minHeight: "100px", children: [_jsx(SkeletonLoader, { width: "100%", height: "20px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), _jsx(SkeletonLoader, { width: "95%", height: "20px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), _jsx(SkeletonLoader, { width: "80%", height: "20px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" })] }), _jsxs(Box, { display: "flex", flexDirection: "row", alignItems: "end", gap: "4px", children: [_jsx(SkeletonLoader, { width: "80px", height: "36px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), _jsx(SkeletonLoader, { width: "60px", height: "20px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" })] }), showButton && (_jsx(Box, { margin: 'var(--spacing-tokens-size-in-px-spacing-spacing-3xl) 0', children: _jsx(SkeletonLoader, { width: "100%", height: "44px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-md)" }) })), showFeatures && (_jsxs(Box, { display: "flex", flexDirection: "column", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-xl)", alignItems: "flex-start", children: [_jsx(SkeletonLoader, { width: "120px", height: "20px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), Array.from({ length: featuresCount }).map((_, index) => (_jsxs(Box, { display: "flex", flexDirection: "row", alignItems: "flex-start", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-md)", width: "100%", children: [_jsx(SkeletonLoader, { width: "18px", height: "18px", borderRadius: "var(--spacing-tokens-size-in-px-radius-radius-full)" }), _jsx(SkeletonLoader, { width: index % 3 === 0 ? '85%' : index % 3 === 1 ? '75%' : '90%', height: "18px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" })] }, index)))] }))] }));
|
|
6
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { StripeProductCardSkeleton } from './StripeProductCardSkeleton';
|
|
3
|
+
declare const meta: Meta<typeof StripeProductCardSkeleton>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof StripeProductCardSkeleton>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithMostPopular: Story;
|
|
8
|
+
export declare const WithBubble: Story;
|
|
9
|
+
export declare const WithoutButton: Story;
|
|
10
|
+
export declare const WithoutFeatures: Story;
|
|
11
|
+
export declare const CustomFeaturesCount: Story;
|
|
12
|
+
export declare const Complete: Story;
|
|
13
|
+
export declare const CustomWidth: Story;
|
|
14
|
+
export declare const PricingGrid: Story;
|
|
15
|
+
export declare const LoadingState: Story;
|
|
16
|
+
export declare const MinimalVariant: Story;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { StripeProductCardSkeleton } from './StripeProductCardSkeleton';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Components/StripeProduct/StripeProductCardSkeleton',
|
|
6
|
+
component: StripeProductCardSkeleton,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
width: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Width of the skeleton card',
|
|
15
|
+
table: {
|
|
16
|
+
type: { summary: 'string | number' },
|
|
17
|
+
defaultValue: { summary: 'auto' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
showMostPopular: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Show the most popular badge placeholder',
|
|
23
|
+
table: {
|
|
24
|
+
type: { summary: 'boolean' },
|
|
25
|
+
defaultValue: { summary: 'false' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
showBubble: {
|
|
29
|
+
control: 'boolean',
|
|
30
|
+
description: 'Show the bubble placeholder',
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: 'boolean' },
|
|
33
|
+
defaultValue: { summary: 'false' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
showButton: {
|
|
37
|
+
control: 'boolean',
|
|
38
|
+
description: 'Show the button placeholder',
|
|
39
|
+
table: {
|
|
40
|
+
type: { summary: 'boolean' },
|
|
41
|
+
defaultValue: { summary: 'true' },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
showFeatures: {
|
|
45
|
+
control: 'boolean',
|
|
46
|
+
description: 'Show the features section placeholder',
|
|
47
|
+
table: {
|
|
48
|
+
type: { summary: 'boolean' },
|
|
49
|
+
defaultValue: { summary: 'true' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
featuresCount: {
|
|
53
|
+
control: 'number',
|
|
54
|
+
description: 'Number of feature items to show',
|
|
55
|
+
table: {
|
|
56
|
+
type: { summary: 'number' },
|
|
57
|
+
defaultValue: { summary: '5' },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
style: {
|
|
61
|
+
control: 'object',
|
|
62
|
+
description: 'Custom style for the skeleton',
|
|
63
|
+
table: {
|
|
64
|
+
type: { summary: 'React.CSSProperties' },
|
|
65
|
+
defaultValue: { summary: 'undefined' },
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export default meta;
|
|
71
|
+
export const Default = {
|
|
72
|
+
args: {
|
|
73
|
+
width: '360px',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
export const WithMostPopular = {
|
|
77
|
+
args: {
|
|
78
|
+
width: '360px',
|
|
79
|
+
showMostPopular: true,
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
export const WithBubble = {
|
|
83
|
+
args: {
|
|
84
|
+
width: '360px',
|
|
85
|
+
showBubble: true,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
export const WithoutButton = {
|
|
89
|
+
args: {
|
|
90
|
+
width: '360px',
|
|
91
|
+
showButton: false,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
export const WithoutFeatures = {
|
|
95
|
+
args: {
|
|
96
|
+
width: '360px',
|
|
97
|
+
showFeatures: false,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
export const CustomFeaturesCount = {
|
|
101
|
+
args: {
|
|
102
|
+
width: '360px',
|
|
103
|
+
featuresCount: 8,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
export const Complete = {
|
|
107
|
+
args: {
|
|
108
|
+
width: '360px',
|
|
109
|
+
showMostPopular: true,
|
|
110
|
+
showBubble: true,
|
|
111
|
+
showButton: true,
|
|
112
|
+
showFeatures: true,
|
|
113
|
+
featuresCount: 6,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
export const CustomWidth = {
|
|
117
|
+
args: {
|
|
118
|
+
width: '500px',
|
|
119
|
+
showMostPopular: true,
|
|
120
|
+
showBubble: true,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
export const PricingGrid = {
|
|
124
|
+
render: () => (_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 3, children: [_jsx(StripeProductCardSkeleton, { width: "360px", showFeatures: true }), _jsx(StripeProductCardSkeleton, { width: "360px", showMostPopular: true, showBubble: true, featuresCount: 7 }), _jsx(StripeProductCardSkeleton, { width: "360px", showFeatures: true })] })),
|
|
125
|
+
};
|
|
126
|
+
export const LoadingState = {
|
|
127
|
+
render: () => (_jsxs(Box, { display: "flex", flexDirection: "column", gap: 4, children: [_jsxs(Box, { children: [_jsx("h3", { children: "Loading state example" }), _jsx("p", { children: "This demonstrates how the skeleton appears while loading pricing plans" })] }), _jsx(Box, { display: "flex", flexWrap: "wrap", gap: 3, justifyContent: "center", children: Array(3)
|
|
128
|
+
.fill(0)
|
|
129
|
+
.map((_, index) => (_jsx(StripeProductCardSkeleton, { width: "360px", showMostPopular: index === 1, showBubble: index === 1, featuresCount: index === 1 ? 7 : 5 }, index))) })] })),
|
|
130
|
+
};
|
|
131
|
+
export const MinimalVariant = {
|
|
132
|
+
args: {
|
|
133
|
+
width: '360px',
|
|
134
|
+
showButton: false,
|
|
135
|
+
showFeatures: false,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
@@ -30,4 +30,27 @@ export interface StripeProductProps {
|
|
|
30
30
|
style?: React.CSSProperties;
|
|
31
31
|
/** Class name of the product */
|
|
32
32
|
className?: string;
|
|
33
|
+
/** Test ID of the product */
|
|
34
|
+
testId?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Stripe product card skeleton component props
|
|
38
|
+
*/
|
|
39
|
+
export interface StripeProductCardSkeletonProps {
|
|
40
|
+
/** Width of the skeleton card */
|
|
41
|
+
width?: string | number;
|
|
42
|
+
/** Show the most popular badge placeholder */
|
|
43
|
+
showMostPopular?: boolean;
|
|
44
|
+
/** Show the bubble placeholder */
|
|
45
|
+
showBubble?: boolean;
|
|
46
|
+
/** Show the button placeholder */
|
|
47
|
+
showButton?: boolean;
|
|
48
|
+
/** Show the features section placeholder */
|
|
49
|
+
showFeatures?: boolean;
|
|
50
|
+
/** Number of feature items to show */
|
|
51
|
+
featuresCount?: number;
|
|
52
|
+
/** Custom style for the skeleton */
|
|
53
|
+
style?: React.CSSProperties;
|
|
54
|
+
/** Test ID of the skeleton card */
|
|
55
|
+
testId?: string;
|
|
33
56
|
}
|
package/dist/stories/UI/Badge.js
CHANGED
|
@@ -3,7 +3,7 @@ import { BadgeColor, BadgeSize } from './types';
|
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
5
5
|
import { getIconComponent } from '../../utils';
|
|
6
|
-
export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, children, style: customStyle, icon = 'Cactus', showIcon = false, fill = true, iconWeight = 'regular', iconSize, iconColor, }) => {
|
|
6
|
+
export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, children, style: customStyle, icon = 'Cactus', showIcon = false, fill = true, iconWeight = 'regular', iconSize, iconColor, testId, }) => {
|
|
7
7
|
const getBackgroundColor = (color) => {
|
|
8
8
|
switch (color) {
|
|
9
9
|
case BadgeColor.Default:
|
|
@@ -114,5 +114,5 @@ export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, c
|
|
|
114
114
|
color: iconColor || getTextColor(),
|
|
115
115
|
weight: iconWeight,
|
|
116
116
|
};
|
|
117
|
-
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "center", bgcolor: fill ? backgroundColor : 'transparent', border: fill ? border : 'none', borderRadius: fill ? 'var(--spacing-tokens-size-in-px-radius-radius-full)' : 'none', padding: padding, margin: 0, gap: "4px", sx: customStyle, children: [showIcon && icon && getIconComponent(icon, iconProps), text && (_jsx(Typography, { size: getTypographySize(size), weight: TypographyWeight.Medium, color: getTextColor(), children: text })), children] }));
|
|
117
|
+
return (_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "center", bgcolor: fill ? backgroundColor : 'transparent', border: fill ? border : 'none', borderRadius: fill ? 'var(--spacing-tokens-size-in-px-radius-radius-full)' : 'none', padding: padding, margin: 0, gap: "4px", sx: customStyle, "data-testid": testId, children: [showIcon && icon && getIconComponent(icon, iconProps), text && (_jsx(Typography, { size: getTypographySize(size), weight: TypographyWeight.Medium, color: getTextColor(), children: text })), children] }));
|
|
118
118
|
};
|
|
@@ -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, }) => {
|
|
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, }) => {
|
|
6
6
|
let errorText = '';
|
|
7
7
|
const calculateFill = () => {
|
|
8
8
|
if (currentValue > maxValue)
|
|
@@ -29,5 +29,5 @@ 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, 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: `${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 })}%` }))] }));
|
|
33
33
|
};
|
|
@@ -47,6 +47,8 @@ export type BadgeProps = {
|
|
|
47
47
|
iconSize?: string | number;
|
|
48
48
|
/** Custom icon color (overrides the default color based on badge color) */
|
|
49
49
|
iconColor?: string;
|
|
50
|
+
/** Test ID of the badge */
|
|
51
|
+
testId?: string;
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
52
54
|
* Avatar size variants
|
|
@@ -189,6 +191,8 @@ export type ProgressIndicatorProps = {
|
|
|
189
191
|
textColor?: string;
|
|
190
192
|
/** Style of the progress indicator */
|
|
191
193
|
style?: SxProps<Theme>;
|
|
194
|
+
/** Test ID of the progress indicator */
|
|
195
|
+
testId?: string;
|
|
192
196
|
};
|
|
193
197
|
export interface SkeletonLoaderProps {
|
|
194
198
|
/**
|