@beydesign/storybook 0.0.33 → 0.0.35
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 +2 -0
- package/dist/index.js +1 -0
- package/dist/stories/AgentCard.js +49 -4
- package/dist/stories/AgentCard.stories.d.ts +3 -0
- package/dist/stories/AgentCard.stories.js +46 -1
- package/dist/stories/AgentCardSkeleton.stories.d.ts +13 -0
- package/dist/stories/AgentCardSkeleton.stories.js +101 -0
- package/dist/stories/Bagde.js +13 -3
- package/dist/stories/Sidebar.js +5 -7
- package/dist/stories/SkeletonLoader.d.ts +47 -0
- package/dist/stories/SkeletonLoader.js +22 -0
- package/dist/stories/SkeletonLoader.stories.d.ts +11 -0
- package/dist/stories/SkeletonLoader.stories.js +141 -0
- package/dist/stories/types/agent-card.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { CreditsCard } from './stories/CreditsCard';
|
|
|
13
13
|
export { Sidebar } from './stories/Sidebar';
|
|
14
14
|
export { Menu } from './stories/Menu';
|
|
15
15
|
export { AgentCard } from './stories/AgentCard';
|
|
16
|
+
export { SkeletonLoader, AgentCardSkeleton } from './stories/SkeletonLoader';
|
|
16
17
|
export { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, type MainButtonProps, } from './stories/types/button';
|
|
17
18
|
export { BadgeColor, BadgeSize, type BadgeProps } from './stories/types/badge';
|
|
18
19
|
export { AvatarStyle, AvatarSize, type AvatarProps, } from './stories/types/avatar';
|
|
@@ -28,3 +29,4 @@ export { CreditsCardSize, type CreditsCardProps, } from './stories/types/credits
|
|
|
28
29
|
export { SidebarSize, type SidebarProps, type NavItemConfig, type NavSection, } from './stories/types/sidebar';
|
|
29
30
|
export { type MenuProps, type MenuItemProps } from './stories/types/menu';
|
|
30
31
|
export { type AgentCardProps, AgentState } from './stories/types/agent-card';
|
|
32
|
+
export { type SkeletonLoaderProps, type AgentCardSkeletonProps, } from './stories/SkeletonLoader';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { CreditsCard } from './stories/CreditsCard';
|
|
|
14
14
|
export { Sidebar } from './stories/Sidebar';
|
|
15
15
|
export { Menu } from './stories/Menu';
|
|
16
16
|
export { AgentCard } from './stories/AgentCard';
|
|
17
|
+
export { SkeletonLoader, AgentCardSkeleton } from './stories/SkeletonLoader';
|
|
17
18
|
// Button Types
|
|
18
19
|
export { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, } from './stories/types/button';
|
|
19
20
|
// Badge Types
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from 'react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
3
|
import { AgentState, } from './types/agent-card';
|
|
4
4
|
import { Box } from '@mui/material';
|
|
5
5
|
import { Typography } from './Typography';
|
|
@@ -14,16 +14,61 @@ import { Menu } from './Menu';
|
|
|
14
14
|
import { ArrowsCounterClockwise } from '@phosphor-icons/react';
|
|
15
15
|
import { ProgressIndicator } from './ProgressIndicator';
|
|
16
16
|
import { ProgressIndicatorMode } from './types/progress-indicator';
|
|
17
|
-
export const AgentCard = ({ title, description = '', date = '', showDate = false, badges = [], showBadges = false, showTimeBadge = false, showDescription = false, showMenu = false, menuItems = [], active = false, showActiveToggle = false, onActiveToggleChange, activeToggleDisabled = false, agentImage, time, onPreview, agentState, }) => {
|
|
17
|
+
export const AgentCard = ({ title, description = '', date = '', showDate = false, badges = [], showBadges = false, showTimeBadge = false, showDescription = false, showMenu = false, menuItems = [], active = false, showActiveToggle = false, onActiveToggleChange, activeToggleDisabled = false, agentImage, time, onPreview, agentState, previewButtonText = 'Preview', }) => {
|
|
18
18
|
const [hovered, setHovered] = useState(false);
|
|
19
19
|
const [imageError, setImageError] = useState(false);
|
|
20
|
+
const [isLoading, setIsLoading] = useState(!!agentImage);
|
|
20
21
|
// const isError = agentState === AgentState.error;
|
|
21
22
|
const isDraft = agentState === AgentState.pending;
|
|
22
23
|
const isProcessing = agentState === AgentState.processing;
|
|
23
24
|
const isReady = agentState === AgentState.ready;
|
|
25
|
+
// Handle image loading and errors
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
if (!agentImage) {
|
|
28
|
+
setIsLoading(false);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setIsLoading(true);
|
|
32
|
+
setImageError(false);
|
|
33
|
+
// Preload the image to check if it exists
|
|
34
|
+
const img = new Image();
|
|
35
|
+
img.onload = () => {
|
|
36
|
+
setImageError(false);
|
|
37
|
+
setIsLoading(false);
|
|
38
|
+
};
|
|
39
|
+
img.onerror = () => {
|
|
40
|
+
setImageError(true);
|
|
41
|
+
setIsLoading(false);
|
|
42
|
+
};
|
|
43
|
+
img.src = agentImage;
|
|
44
|
+
// Cleanup
|
|
45
|
+
return () => {
|
|
46
|
+
img.onload = null;
|
|
47
|
+
img.onerror = null;
|
|
48
|
+
};
|
|
49
|
+
}, [agentImage]);
|
|
50
|
+
// Render loading state or placeholder
|
|
51
|
+
const renderImageContent = () => {
|
|
52
|
+
if (isLoading) {
|
|
53
|
+
return (_jsxs(Box, { width: '100%', height: '100%', bgcolor: 'var(--colors-light-background-bg-element)', display: 'flex', justifyContent: 'center', alignItems: 'center', children: [_jsxs(Box, { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', children: [_jsx(ArrowsCounterClockwise, { size: 24, weight: "bold", color: 'var(--colors-light-text-text-subtle)', style: { animation: 'spin 1.5s linear infinite' } }), _jsx(Typography, { text: "Loading preview...", size: TypographySize.TextS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-subtle)' })] }), _jsx("style", { children: `
|
|
54
|
+
@keyframes spin {
|
|
55
|
+
0% {
|
|
56
|
+
transform: rotate(0deg);
|
|
57
|
+
}
|
|
58
|
+
100% {
|
|
59
|
+
transform: rotate(360deg);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
` })] }));
|
|
63
|
+
}
|
|
64
|
+
if (imageError || !agentImage) {
|
|
65
|
+
return (_jsx(Box, { width: '100%', height: '100%', bgcolor: 'var(--colors-light-background-bg-element)', display: 'flex', justifyContent: 'center', alignItems: 'center', children: _jsx(Typography, { text: "No Preview Available", size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold }) }));
|
|
66
|
+
}
|
|
67
|
+
return (_jsx("img", { src: agentImage, alt: "Agent", width: '100%', height: '100%', style: { objectFit: 'cover' } }));
|
|
68
|
+
};
|
|
24
69
|
return (_jsxs(Box, { width: '300px', display: 'flex', flexDirection: 'column', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', bgcolor: isDraft
|
|
25
70
|
? 'var(--colors-light-background-bg-element)'
|
|
26
|
-
: 'var(--colors-light-background-bg-component)', boxShadow:
|
|
71
|
+
: 'var(--colors-light-background-bg-component)', boxShadow: `var(--global-shadows-shadow-xs-offset-x) var(--global-shadows-shadow-xs-offset-y) var(--global-shadows-shadow-xs-blur) var(--global-shadows-shadow-xs-spread) var(--global-shadows-shadow-xs-color)`, children: [_jsxs(Box, { display: 'flex', justifyContent: 'center', alignItems: 'center', position: 'relative', width: '100%', sx: { aspectRatio: 1 }, borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', overflow: 'hidden', onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), children: [renderImageContent(), showTimeBadge && time && (_jsx(Badge, { text: time, size: BadgeSize.md, fill: true, style: {
|
|
27
72
|
position: 'absolute',
|
|
28
73
|
right: '8px',
|
|
29
74
|
bottom: '8px',
|
|
@@ -33,7 +78,7 @@ export const AgentCard = ({ title, description = '', date = '', showDate = false
|
|
|
33
78
|
position: 'absolute',
|
|
34
79
|
right: '8px',
|
|
35
80
|
top: '8px',
|
|
36
|
-
} })), isReady && hovered && (_jsx(Box, { position: 'absolute', top: '0', left: '0', width: '100%', height: '100%', bgcolor: 'var(--colors-light-background-bg-component-hover)', sx: { opacity: 0.5, zIndex: 1 } })), isProcessing && (_jsxs(Box, { position: 'absolute', top: '0', left: '0', width: '100%', height: '100%', bgcolor: 'var(--colors-light-background-bg-component-hover)', style: { zIndex: 1 }, display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', children: [_jsx(ArrowsCounterClockwise, { size: 24, weight: "bold", color: 'var(--primitives-desktop-primary-white-100)' }), _jsx(Typography, { text: "Agent creation in progress", size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: 'var(--primitives-desktop-primary-white-100)' }), _jsx(ProgressIndicator, { mode: ProgressIndicatorMode.Percentage, currentValue: 50, maxValue: 100, textColor: 'var(--primitives-desktop-primary-white-100)' })] })), isReady && onPreview && (_jsx(Box, { position: 'absolute', sx: { zIndex: 2 }, children: _jsx(MainButton, { text:
|
|
81
|
+
} })), isReady && hovered && (_jsx(Box, { position: 'absolute', top: '0', left: '0', width: '100%', height: '100%', bgcolor: 'var(--colors-light-background-bg-component-hover)', sx: { opacity: 0.5, zIndex: 1 } })), isProcessing && (_jsxs(Box, { position: 'absolute', top: '0', left: '0', width: '100%', height: '100%', bgcolor: 'var(--colors-light-background-bg-component-hover)', style: { zIndex: 1 }, display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', children: [_jsx(ArrowsCounterClockwise, { size: 24, weight: "bold", color: 'var(--primitives-desktop-primary-white-100)' }), _jsx(Typography, { text: "Agent creation in progress", size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: 'var(--primitives-desktop-primary-white-100)' }), _jsx(ProgressIndicator, { mode: ProgressIndicatorMode.Percentage, currentValue: 50, maxValue: 100, textColor: 'var(--primitives-desktop-primary-white-100)' })] })), isReady && onPreview && (_jsx(Box, { position: 'absolute', sx: { zIndex: 2 }, children: _jsx(MainButton, { text: previewButtonText, onClick: onPreview, showTrailingIcon: true, trailingIcon: "Play", hierarchy: ButtonHierarchy.SecondaryTransparent, size: ButtonSize.sm, style: { border: 'none' } }) }))] }), _jsx(Typography, { text: title, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold }), (showDate || showActiveToggle) && (_jsxs(Box, { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', children: [showDate && (_jsx(Typography, { text: date, size: TypographySize.TextS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-subtle)', style: { flex: 1 } })), showActiveToggle && (_jsx(Toggle, { checked: active, onChange: (checked) => onActiveToggleChange?.(checked), disabled: activeToggleDisabled, text: "Active", togglePosition: TogglePosition.Right, style: { flex: 1 } }))] })), showBadges && (_jsx(Box, { display: 'flex', flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', children: badges.map((badge) => (_jsx(Badge, { text: badge, size: BadgeSize.lg, fill: true }))) })), showDescription && (_jsx(Typography, { text: description, size: TypographySize.TextS, weight: TypographyWeight.Regular, color: 'var(--colors-light-text-text-paragraph)' }))] }));
|
|
37
82
|
};
|
|
38
83
|
export const Components = () => {
|
|
39
84
|
return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "Avatars" }), _jsx("div", { style: { display: 'flex', gap: '1rem', flexDirection: 'column' }, children: _jsx("div", { children: _jsx("h2", { children: "Size: sm, Avatar Style: Letters" }) }) })] }));
|
|
@@ -4,3 +4,6 @@ declare const meta: Meta<typeof AgentCard>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof AgentCard>;
|
|
6
6
|
export declare const Placeholder: Story;
|
|
7
|
+
export declare const CustomPreviewText: Story;
|
|
8
|
+
export declare const LoadingPreview: Story;
|
|
9
|
+
export declare const NoImage: Story;
|
|
@@ -116,6 +116,14 @@ const meta = {
|
|
|
116
116
|
type: { summary: 'string' },
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
|
+
previewButtonText: {
|
|
120
|
+
control: 'text',
|
|
121
|
+
description: 'Text for the preview button',
|
|
122
|
+
table: {
|
|
123
|
+
type: { summary: 'string' },
|
|
124
|
+
defaultValue: { summary: 'Preview' },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
119
127
|
},
|
|
120
128
|
};
|
|
121
129
|
export default meta;
|
|
@@ -134,11 +142,48 @@ export const Placeholder = {
|
|
|
134
142
|
showTimeBadge: true,
|
|
135
143
|
time: '10:00',
|
|
136
144
|
onPreview: () => { },
|
|
145
|
+
previewButtonText: 'Preview',
|
|
137
146
|
menuItems: [
|
|
138
147
|
{ label: 'Edit', icon: 'Pencil', onClick: () => { } },
|
|
139
148
|
{ label: 'Delete', icon: 'Trash', onClick: () => { }, destructive: true },
|
|
140
149
|
],
|
|
141
150
|
showMenu: true,
|
|
142
|
-
agentState: AgentState.
|
|
151
|
+
agentState: AgentState.ready,
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
export const CustomPreviewText = {
|
|
155
|
+
args: {
|
|
156
|
+
...Placeholder.args,
|
|
157
|
+
previewButtonText: 'View Agent',
|
|
158
|
+
agentState: AgentState.ready,
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
export const LoadingPreview = {
|
|
162
|
+
args: {
|
|
163
|
+
...Placeholder.args,
|
|
164
|
+
title: 'Loading Preview Example',
|
|
165
|
+
// Using a non-existent image to force loading state
|
|
166
|
+
agentImage: 'https://example.com/non-existent-image.jpg',
|
|
167
|
+
},
|
|
168
|
+
parameters: {
|
|
169
|
+
docs: {
|
|
170
|
+
description: {
|
|
171
|
+
story: 'This example demonstrates the loading state of the agent card image.',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
export const NoImage = {
|
|
177
|
+
args: {
|
|
178
|
+
...Placeholder.args,
|
|
179
|
+
title: 'No Image Example',
|
|
180
|
+
agentImage: undefined,
|
|
181
|
+
},
|
|
182
|
+
parameters: {
|
|
183
|
+
docs: {
|
|
184
|
+
description: {
|
|
185
|
+
story: 'This example demonstrates the agent card when no image is provided.',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
143
188
|
},
|
|
144
189
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { AgentCardSkeleton } from './SkeletonLoader';
|
|
3
|
+
declare const meta: Meta<typeof AgentCardSkeleton>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof AgentCardSkeleton>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithDate: Story;
|
|
8
|
+
export declare const WithBadges: Story;
|
|
9
|
+
export declare const WithDescription: Story;
|
|
10
|
+
export declare const Complete: Story;
|
|
11
|
+
export declare const CustomWidth: Story;
|
|
12
|
+
export declare const Grid: Story;
|
|
13
|
+
export declare const LoadingState: Story;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AgentCardSkeleton } from './SkeletonLoader';
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Components/AgentCardSkeleton',
|
|
6
|
+
component: AgentCardSkeleton,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
width: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Width of the card',
|
|
15
|
+
table: {
|
|
16
|
+
type: { summary: 'string | number' },
|
|
17
|
+
defaultValue: { summary: '300px' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
showDate: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Show date placeholder',
|
|
23
|
+
table: {
|
|
24
|
+
type: { summary: 'boolean' },
|
|
25
|
+
defaultValue: { summary: 'false' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
showBadges: {
|
|
29
|
+
control: 'boolean',
|
|
30
|
+
description: 'Show badges placeholder',
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: 'boolean' },
|
|
33
|
+
defaultValue: { summary: 'false' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
showDescription: {
|
|
37
|
+
control: 'boolean',
|
|
38
|
+
description: 'Show description placeholder',
|
|
39
|
+
table: {
|
|
40
|
+
type: { summary: 'boolean' },
|
|
41
|
+
defaultValue: { summary: 'false' },
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
style: {
|
|
45
|
+
control: 'object',
|
|
46
|
+
description: 'Custom style for the skeleton',
|
|
47
|
+
table: {
|
|
48
|
+
type: { summary: 'React.CSSProperties' },
|
|
49
|
+
defaultValue: { summary: 'undefined' },
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export default meta;
|
|
55
|
+
export const Default = {
|
|
56
|
+
args: {
|
|
57
|
+
width: '300px',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export const WithDate = {
|
|
61
|
+
args: {
|
|
62
|
+
width: '300px',
|
|
63
|
+
showDate: true,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const WithBadges = {
|
|
67
|
+
args: {
|
|
68
|
+
width: '300px',
|
|
69
|
+
showBadges: true,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
export const WithDescription = {
|
|
73
|
+
args: {
|
|
74
|
+
width: '300px',
|
|
75
|
+
showDescription: true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
export const Complete = {
|
|
79
|
+
args: {
|
|
80
|
+
width: '300px',
|
|
81
|
+
showDate: true,
|
|
82
|
+
showBadges: true,
|
|
83
|
+
showDescription: true,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
export const CustomWidth = {
|
|
87
|
+
args: {
|
|
88
|
+
width: '400px',
|
|
89
|
+
showDate: true,
|
|
90
|
+
showBadges: true,
|
|
91
|
+
showDescription: true,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
export const Grid = {
|
|
95
|
+
render: () => (_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 2, children: [_jsx(AgentCardSkeleton, { showDate: true }), _jsx(AgentCardSkeleton, { showBadges: true }), _jsx(AgentCardSkeleton, { showDescription: true }), _jsx(AgentCardSkeleton, { showDate: true, showBadges: true, showDescription: true })] })),
|
|
96
|
+
};
|
|
97
|
+
export const LoadingState = {
|
|
98
|
+
render: () => (_jsxs(Box, { display: "flex", flexDirection: "column", gap: 3, children: [_jsxs(Box, { children: [_jsx("h3", { children: "Loading state example" }), _jsx("p", { children: "This demonstrates how multiple skeletons might appear during a loading state" })] }), _jsx(Box, { display: "flex", flexWrap: "wrap", gap: 2, children: Array(6)
|
|
99
|
+
.fill(0)
|
|
100
|
+
.map((_, index) => (_jsx(AgentCardSkeleton, { showDate: index % 2 === 0, showBadges: index % 3 === 0, showDescription: index % 2 !== 0 }, index))) })] })),
|
|
101
|
+
};
|
package/dist/stories/Bagde.js
CHANGED
|
@@ -82,7 +82,7 @@ export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, s
|
|
|
82
82
|
case BadgeSize.lg:
|
|
83
83
|
return 'var(--spacing-tokens-size-in-px-spacing-spacing-sm) var(--spacing-tokens-size-in-px-spacing-spacing-lg)';
|
|
84
84
|
case BadgeSize.md:
|
|
85
|
-
return 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)
|
|
85
|
+
return 'var(--spacing-tokens-size-in-px-spacing-spacing-xs) 10px';
|
|
86
86
|
case BadgeSize.xs:
|
|
87
87
|
return 'var(--spacing-tokens-size-in-px-spacing-spacing-xs) var(--spacing-tokens-size-in-px-spacing-spacing-md)';
|
|
88
88
|
}
|
|
@@ -90,13 +90,23 @@ export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, s
|
|
|
90
90
|
const getIconSize = (size) => {
|
|
91
91
|
switch (size) {
|
|
92
92
|
case BadgeSize.lg:
|
|
93
|
-
return '
|
|
93
|
+
return '16px';
|
|
94
94
|
case BadgeSize.md:
|
|
95
95
|
return '16px';
|
|
96
96
|
case BadgeSize.xs:
|
|
97
97
|
return '12px';
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
|
+
const getTypographySize = (size) => {
|
|
101
|
+
switch (size) {
|
|
102
|
+
case BadgeSize.lg:
|
|
103
|
+
return TypographySize.TextS;
|
|
104
|
+
case BadgeSize.md:
|
|
105
|
+
return TypographySize.TextS;
|
|
106
|
+
case BadgeSize.xs:
|
|
107
|
+
return TypographySize.TextXS;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
100
110
|
const backgroundColor = getBackgroundColor(color);
|
|
101
111
|
const border = getBorder(color);
|
|
102
112
|
const padding = getPadding(size);
|
|
@@ -105,5 +115,5 @@ export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, s
|
|
|
105
115
|
color: getTextColor(),
|
|
106
116
|
weight: 'regular',
|
|
107
117
|
};
|
|
108
|
-
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, gap: "4px", sx: customStyle, children: [showIcon && icon && getIconComponent(icon, iconProps), text && (_jsx(Typography, { text: text, size:
|
|
118
|
+
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, { text: text, size: getTypographySize(size), weight: TypographyWeight.Medium, color: getTextColor() }))] }));
|
|
109
119
|
};
|
package/dist/stories/Sidebar.js
CHANGED
|
@@ -35,8 +35,7 @@ const SidebarContainer = styled.div `
|
|
|
35
35
|
const LogoContainer = styled.div `
|
|
36
36
|
display: flex;
|
|
37
37
|
align-items: center;
|
|
38
|
-
justify-content:
|
|
39
|
-
padding: ${({ $size }) => ($size === SidebarSize.Expanded ? '0 24px' : '0')};
|
|
38
|
+
justify-content: center;
|
|
40
39
|
margin-bottom: 32px;
|
|
41
40
|
min-height: 38px;
|
|
42
41
|
height: 38px;
|
|
@@ -56,7 +55,6 @@ const ToggleButtonWrapper = styled.div `
|
|
|
56
55
|
const NavItemsContainer = styled.div `
|
|
57
56
|
display: flex;
|
|
58
57
|
flex-direction: column;
|
|
59
|
-
gap: 8px;
|
|
60
58
|
flex: 1;
|
|
61
59
|
`;
|
|
62
60
|
const NavSection = styled.div `
|
|
@@ -74,10 +72,10 @@ const SectionTitle = styled.div `
|
|
|
74
72
|
transition: all 0.3s ease-in-out;
|
|
75
73
|
`;
|
|
76
74
|
const Separator = styled.div `
|
|
77
|
-
height: 0.
|
|
75
|
+
height: 0.1px;
|
|
78
76
|
background-color: var(--primitives-desktop-primary-brand-violet-950);
|
|
79
|
-
padding:
|
|
80
|
-
margin:
|
|
77
|
+
padding: ${({ $size }) => $size === SidebarSize.Collapsed ? '0px 8px' : '0px 28px'};
|
|
78
|
+
margin: ${({ $size }) => $size === SidebarSize.Collapsed ? '16px 12px' : '16px 18px'};
|
|
81
79
|
opacity: 0.05;
|
|
82
80
|
transition: all 0.3s ease-in-out;
|
|
83
81
|
`;
|
|
@@ -112,7 +110,7 @@ export const Sidebar = ({ size = SidebarSize.Expanded, className = '', navSectio
|
|
|
112
110
|
};
|
|
113
111
|
const isCollapsed = sidebarSize === SidebarSize.Collapsed;
|
|
114
112
|
return (_jsxs(SidebarContainer, { className: className, children: [_jsxs(StyledSidebar, { "$size": sidebarSize, children: [_jsx(LogoContainer, { "$size": sidebarSize, children: _jsx(Logo, { variant: isCollapsed ? LogoVariant.Icon : LogoVariant.Horizontal, color: logoProps.color, gradient: logoProps.gradient }) }), _jsx(NavItemsContainer, { children: navSections.map((section, sectionIndex) => (_jsxs(React.Fragment, { children: [_jsxs(NavSection, { children: [section.title && (_jsx(SectionTitle, { "$size": sidebarSize, children: _jsx(Typography, { text: section.title, size: TypographySize.TextS, weight: TypographyWeight.Regular, color: "var(--primitives-desktop-primary-gray-700)", className: isCollapsed ? 'hidden' : '' }) })), section.items.map((item, itemIndex) => (_jsx(NavItemWrapper, { item: item, isCollapsed: isCollapsed }, `${item.text}-${itemIndex}`)))] }), sectionIndex < navSections.length - 1 &&
|
|
115
|
-
section.showSeparator && _jsx(Separator, {})] }, `section-${sectionIndex}`))) }), _jsx(BottomContainer, { children: _jsxs(Box, { display: "flex", flexDirection: "column", gap: "16px", children: [credits && (_jsx(Box, { sx: {
|
|
113
|
+
section.showSeparator && _jsx(Separator, { "$size": sidebarSize })] }, `section-${sectionIndex}`))) }), _jsx(BottomContainer, { children: _jsxs(Box, { display: "flex", flexDirection: "column", gap: "16px", children: [credits && (_jsx(Box, { sx: {
|
|
116
114
|
display: 'flex',
|
|
117
115
|
justifyContent: 'center',
|
|
118
116
|
padding: isCollapsed ? '8px' : '0px 12px',
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SkeletonLoaderProps {
|
|
3
|
+
/**
|
|
4
|
+
* Width of the skeleton
|
|
5
|
+
*/
|
|
6
|
+
width?: string | number;
|
|
7
|
+
/**
|
|
8
|
+
* Height of the skeleton
|
|
9
|
+
*/
|
|
10
|
+
height?: string | number;
|
|
11
|
+
/**
|
|
12
|
+
* Border radius of the skeleton
|
|
13
|
+
*/
|
|
14
|
+
borderRadius?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Animation duration in seconds
|
|
17
|
+
*/
|
|
18
|
+
animationDuration?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Custom style for the skeleton
|
|
21
|
+
*/
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
export declare const SkeletonLoader: React.FC<SkeletonLoaderProps>;
|
|
25
|
+
export interface AgentCardSkeletonProps {
|
|
26
|
+
/**
|
|
27
|
+
* Width of the card
|
|
28
|
+
*/
|
|
29
|
+
width?: string | number;
|
|
30
|
+
/**
|
|
31
|
+
* Show date placeholder
|
|
32
|
+
*/
|
|
33
|
+
showDate?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Show badges placeholder
|
|
36
|
+
*/
|
|
37
|
+
showBadges?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Show description placeholder
|
|
40
|
+
*/
|
|
41
|
+
showDescription?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Custom style for the skeleton
|
|
44
|
+
*/
|
|
45
|
+
style?: React.CSSProperties;
|
|
46
|
+
}
|
|
47
|
+
export declare const AgentCardSkeleton: React.FC<AgentCardSkeletonProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
export const SkeletonLoader = ({ width = '100%', height = '100%', borderRadius = 'var(--spacing-tokens-size-in-px-spacing-sm)', animationDuration = 1.5, style, }) => {
|
|
4
|
+
return (_jsx(Box, { width: width, height: height, borderRadius: borderRadius, sx: {
|
|
5
|
+
background: 'linear-gradient(90deg, var(--colors-light-background-bg-element) 25%, var(--colors-light-background-bg-component) 50%, var(--colors-light-background-bg-element) 75%)',
|
|
6
|
+
backgroundSize: '200% 100%',
|
|
7
|
+
animation: `shimmer ${animationDuration}s infinite linear`,
|
|
8
|
+
...style,
|
|
9
|
+
}, children: _jsx("style", { children: `
|
|
10
|
+
@keyframes shimmer {
|
|
11
|
+
0% {
|
|
12
|
+
background-position: 200% 0;
|
|
13
|
+
}
|
|
14
|
+
100% {
|
|
15
|
+
background-position: -200% 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
` }) }));
|
|
19
|
+
};
|
|
20
|
+
export const AgentCardSkeleton = ({ width = '300px', showDate = false, showBadges = false, showDescription = false, style, }) => {
|
|
21
|
+
return (_jsxs(Box, { width: width, display: "flex", flexDirection: "column", borderRadius: "var(--spacing-tokens-size-in-px-spacing-md)", padding: "var(--spacing-tokens-size-in-px-spacing-spacing-xl)", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-lg)", bgcolor: "var(--colors-light-background-bg-component)", boxShadow: `var(--global-shadows-shadow-xs-offset-x) var(--global-shadows-shadow-xs-offset-y) var(--global-shadows-shadow-xs-blur) var(--global-shadows-shadow-xs-spread) var(--global-shadows-shadow-xs-color)`, style: style, children: [_jsx(Box, { width: "100%", sx: { aspectRatio: 1 }, borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-sm)", overflow: "hidden", children: _jsx(SkeletonLoader, {}) }), _jsx(SkeletonLoader, { width: "70%", height: "24px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), showDate && (_jsx(SkeletonLoader, { width: "100%", height: "20px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" })), showBadges && (_jsxs(Box, { display: "flex", flexDirection: "row", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-md)", children: [_jsx(SkeletonLoader, { width: "60px", height: "24px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), _jsx(SkeletonLoader, { width: "80px", height: "24px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" })] })), showDescription && (_jsxs(Box, { display: "flex", flexDirection: "column", gap: "var(--spacing-tokens-size-in-px-spacing-spacing-sm)", children: [_jsx(SkeletonLoader, { width: "100%", height: "16px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" }), _jsx(SkeletonLoader, { width: "80%", height: "16px", borderRadius: "var(--spacing-tokens-size-in-px-spacing-spacing-xs)" })] }))] }));
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SkeletonLoader, AgentCardSkeleton } from './SkeletonLoader';
|
|
3
|
+
declare const meta: Meta<typeof SkeletonLoader>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SkeletonLoader>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const CustomAnimation: Story;
|
|
8
|
+
export declare const RoundedSkeleton: Story;
|
|
9
|
+
export declare const agentCardSkeletonMeta: Meta<typeof AgentCardSkeleton>;
|
|
10
|
+
export declare const AgentCardSkeletonStory: StoryObj<typeof AgentCardSkeleton>;
|
|
11
|
+
export declare const AgentCardSkeletonGrid: StoryObj<typeof AgentCardSkeleton>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SkeletonLoader, AgentCardSkeleton } from './SkeletonLoader';
|
|
3
|
+
import { Box } from '@mui/material';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Design System/Components/SkeletonLoader',
|
|
6
|
+
component: SkeletonLoader,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
width: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Width of the skeleton',
|
|
15
|
+
table: {
|
|
16
|
+
type: { summary: 'string | number' },
|
|
17
|
+
defaultValue: { summary: '100%' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
height: {
|
|
21
|
+
control: 'text',
|
|
22
|
+
description: 'Height of the skeleton',
|
|
23
|
+
table: {
|
|
24
|
+
type: { summary: 'string | number' },
|
|
25
|
+
defaultValue: { summary: '100%' },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
borderRadius: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description: 'Border radius of the skeleton',
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: 'string' },
|
|
33
|
+
defaultValue: {
|
|
34
|
+
summary: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
animationDuration: {
|
|
39
|
+
control: 'number',
|
|
40
|
+
description: 'Animation duration in seconds',
|
|
41
|
+
table: {
|
|
42
|
+
type: { summary: 'number' },
|
|
43
|
+
defaultValue: { summary: '1.5' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
style: {
|
|
47
|
+
control: 'object',
|
|
48
|
+
description: 'Custom style for the skeleton',
|
|
49
|
+
table: {
|
|
50
|
+
type: { summary: 'React.CSSProperties' },
|
|
51
|
+
defaultValue: { summary: 'undefined' },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
export default meta;
|
|
57
|
+
export const Default = {
|
|
58
|
+
args: {
|
|
59
|
+
width: 200,
|
|
60
|
+
height: 100,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
export const CustomAnimation = {
|
|
64
|
+
args: {
|
|
65
|
+
width: 200,
|
|
66
|
+
height: 100,
|
|
67
|
+
animationDuration: 3,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export const RoundedSkeleton = {
|
|
71
|
+
args: {
|
|
72
|
+
width: 100,
|
|
73
|
+
height: 100,
|
|
74
|
+
borderRadius: '50%',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
// AgentCardSkeleton meta and stories
|
|
78
|
+
export const agentCardSkeletonMeta = {
|
|
79
|
+
title: 'Design System/Components/AgentCardSkeleton',
|
|
80
|
+
component: AgentCardSkeleton,
|
|
81
|
+
parameters: {
|
|
82
|
+
layout: 'centered',
|
|
83
|
+
},
|
|
84
|
+
tags: ['autodocs'],
|
|
85
|
+
argTypes: {
|
|
86
|
+
width: {
|
|
87
|
+
control: 'text',
|
|
88
|
+
description: 'Width of the card',
|
|
89
|
+
table: {
|
|
90
|
+
type: { summary: 'string | number' },
|
|
91
|
+
defaultValue: { summary: '300px' },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
showDate: {
|
|
95
|
+
control: 'boolean',
|
|
96
|
+
description: 'Show date placeholder',
|
|
97
|
+
table: {
|
|
98
|
+
type: { summary: 'boolean' },
|
|
99
|
+
defaultValue: { summary: 'false' },
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
showBadges: {
|
|
103
|
+
control: 'boolean',
|
|
104
|
+
description: 'Show badges placeholder',
|
|
105
|
+
table: {
|
|
106
|
+
type: { summary: 'boolean' },
|
|
107
|
+
defaultValue: { summary: 'false' },
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
showDescription: {
|
|
111
|
+
control: 'boolean',
|
|
112
|
+
description: 'Show description placeholder',
|
|
113
|
+
table: {
|
|
114
|
+
type: { summary: 'boolean' },
|
|
115
|
+
defaultValue: { summary: 'false' },
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
style: {
|
|
119
|
+
control: 'object',
|
|
120
|
+
description: 'Custom style for the skeleton',
|
|
121
|
+
table: {
|
|
122
|
+
type: { summary: 'React.CSSProperties' },
|
|
123
|
+
defaultValue: { summary: 'undefined' },
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
// AgentCardSkeleton stories
|
|
129
|
+
export const AgentCardSkeletonStory = {
|
|
130
|
+
name: 'Agent Card Skeleton',
|
|
131
|
+
render: (args) => _jsx(AgentCardSkeleton, { ...args }),
|
|
132
|
+
args: {
|
|
133
|
+
showDate: true,
|
|
134
|
+
showBadges: true,
|
|
135
|
+
showDescription: true,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
export const AgentCardSkeletonGrid = {
|
|
139
|
+
name: 'Agent Card Skeleton Grid',
|
|
140
|
+
render: () => (_jsxs(Box, { display: "flex", flexWrap: "wrap", gap: 2, children: [_jsx(AgentCardSkeleton, { showDate: true }), _jsx(AgentCardSkeleton, { showBadges: true }), _jsx(AgentCardSkeleton, { showDescription: true }), _jsx(AgentCardSkeleton, { showDate: true, showBadges: true, showDescription: true })] })),
|
|
141
|
+
};
|