@beydesign/storybook 0.4.12 → 0.5.0
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/App.js
CHANGED
|
@@ -148,7 +148,7 @@ function App() {
|
|
|
148
148
|
gap: '16px',
|
|
149
149
|
}, children: avatars
|
|
150
150
|
.slice(0, 4)
|
|
151
|
-
.map((avatar) => loading ? (_jsx(EntityCardSkeleton, { view: "agent" }, `agent-${avatar.id}`)) : (_jsx(EntityCard, { view: "agent", name: `${avatar.name} Customer Support`, image: avatar.image,
|
|
151
|
+
.map((avatar) => loading ? (_jsx(EntityCardSkeleton, { view: "agent" }, `agent-${avatar.id}`)) : (_jsx(EntityCard, { view: "agent", name: `${avatar.name} Customer Support`, image: avatar.image, stockAgent: true, onPreview: () => console.log('Join', avatar.name), previewButtonText: "Join", previewIcon: "VideoCamera", showMenu: true, menuItems: agentMenuItems }, `agent-${avatar.id}`))) }), _jsx("h2", { style: {
|
|
152
152
|
fontFamily: 'Figtree, sans-serif',
|
|
153
153
|
color: 'var(--color-text-text-title)',
|
|
154
154
|
margin: '40px 0 4px',
|
|
@@ -19,6 +19,24 @@ const ASPECT_RATIO_BY_VIEW = {
|
|
|
19
19
|
agent: '264 / 268',
|
|
20
20
|
video: '16 / 9',
|
|
21
21
|
};
|
|
22
|
+
/** Empty-state label per view variant, shown over the silhouette when there is no image. */
|
|
23
|
+
const EMPTY_TEXT_BY_VIEW = {
|
|
24
|
+
avatar: 'Avatar is not available',
|
|
25
|
+
agent: 'Agent is not available',
|
|
26
|
+
video: 'Video is not available',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Height of the empty-state silhouette (avatar/agent views). The empty-state
|
|
30
|
+
* label sits on the silhouette's vertical midpoint, i.e. half of this up from
|
|
31
|
+
* the bottom of the media area.
|
|
32
|
+
*/
|
|
33
|
+
const SILHOUETTE_HEIGHT = 224;
|
|
34
|
+
/** Copy for the stock-agent badge — the card's only badge. */
|
|
35
|
+
const STOCK_AGENT_BADGE_TEXT = 'Stock Agent';
|
|
36
|
+
/** Label shown beneath the spinner while the entity is processing. */
|
|
37
|
+
const PROCESSING_TEXT = 'Processing...';
|
|
38
|
+
/** Accessible label for the error state, on the warning icon. */
|
|
39
|
+
const ERROR_TEXT = 'Something went wrong';
|
|
22
40
|
/** Hook the root's hover/focus rules use to reveal the action buttons. */
|
|
23
41
|
const ACTIONS_CLASS = 'EntityCard-actions';
|
|
24
42
|
const spin = keyframes `
|
|
@@ -27,11 +45,12 @@ const spin = keyframes `
|
|
|
27
45
|
`;
|
|
28
46
|
/** A continuously rotating refresh icon, matching the AgentCard processing spinner. */
|
|
29
47
|
const Spinner = () => (_jsx(Box, { display: 'flex', sx: { animation: `${spin} 1.5s linear infinite` }, children: _jsx(ArrowsClockwise, { size: 24, color: 'var(--color-text-text-white)' }) }));
|
|
30
|
-
export const EntityCard = ({ view = 'avatar', name, image, description = '', showDescription = false, date, aspectRatio, processing = false,
|
|
48
|
+
export const EntityCard = ({ view = 'avatar', name, image, description = '', showDescription = false, date, aspectRatio, processing = false, error = false, onPreview, previewButtonText, previewIcon = 'Play', previewButtonClassName, stockAgent = false, menuItems = [], showMenu = false, width, testId, }) => {
|
|
31
49
|
const [hovered, setHovered] = useState(false);
|
|
32
50
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
33
51
|
const [imageError, setImageError] = useState(false);
|
|
34
52
|
const isVideo = view === 'video';
|
|
53
|
+
const isAgent = view === 'agent';
|
|
35
54
|
const cardWidth = width ?? WIDTH_BY_VIEW[view];
|
|
36
55
|
const imageAspectRatio = aspectRatio ?? ASPECT_RATIO_BY_VIEW[view];
|
|
37
56
|
const entityKey = name?.toLowerCase()?.replace(/\s+/g, '-');
|
|
@@ -40,8 +59,9 @@ export const EntityCard = ({ view = 'avatar', name, image, description = '', sho
|
|
|
40
59
|
const canPreview = !!onPreview && !isProcessing && !error;
|
|
41
60
|
const showActions = canPreview || hasMenu;
|
|
42
61
|
const active = hovered || menuOpen;
|
|
43
|
-
const showBadge =
|
|
62
|
+
const showBadge = isAgent && stockAgent && !error;
|
|
44
63
|
const showImage = !!image && !imageError && !error;
|
|
64
|
+
const emptyText = EMPTY_TEXT_BY_VIEW[view];
|
|
45
65
|
const resolvedTestId = testId ?? `${entityKey}-${isVideo ? 'video' : 'entity'}-card`;
|
|
46
66
|
const handlePreviewButtonClick = (event) => {
|
|
47
67
|
event.stopPropagation();
|
|
@@ -63,21 +83,24 @@ export const EntityCard = ({ view = 'avatar', name, image, description = '', sho
|
|
|
63
83
|
opacity: 1,
|
|
64
84
|
pointerEvents: 'auto',
|
|
65
85
|
},
|
|
66
|
-
}, "data-testid": resolvedTestId, children: [_jsxs(Box, { position: 'relative', width: '100%', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', overflow: 'hidden', sx: { aspectRatio: imageAspectRatio }, children: [error ? (_jsx(Box, { width: '100%', height: '100%', bgcolor: 'var(--color-background-bg-badge-accent-red)', display: 'flex', justifyContent: 'center', alignItems: 'center', role: 'img', "aria-label":
|
|
86
|
+
}, "data-testid": resolvedTestId, children: [_jsxs(Box, { position: 'relative', width: '100%', borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', overflow: 'hidden', sx: { aspectRatio: imageAspectRatio }, children: [error ? (_jsx(Box, { width: '100%', height: '100%', bgcolor: 'var(--color-background-bg-badge-accent-red)', display: 'flex', justifyContent: 'center', alignItems: 'center', role: 'img', "aria-label": ERROR_TEXT, title: ERROR_TEXT, children: _jsx(Warning, { size: 50, color: 'var(--color-foreground-fg-error)' }) })) : showImage ? (_jsx("img", { src: image, alt: name, width: '100%', height: '100%', style: { objectFit: 'cover', height: '100%', width: '100%' }, onError: () => setImageError(true) })) : (_jsxs(Box, { position: 'relative', width: '100%', height: '100%', overflow: 'hidden', bgcolor: view === 'agent'
|
|
67
87
|
? 'var(--color-background-bg-component-disabled)'
|
|
68
|
-
: 'var(--color-background-bg-button-disabled)', children: _jsx(Box, { position: 'absolute', bottom: 0, left: '50%', sx: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
88
|
+
: 'var(--color-background-bg-button-disabled)', children: [_jsx(Box, { position: 'absolute', bottom: 0, left: '50%', sx: {
|
|
89
|
+
transform: 'translateX(-50%)',
|
|
90
|
+
color: 'var(--color-border-border-subtle)',
|
|
91
|
+
aspectRatio: '206 / 224',
|
|
92
|
+
...(isVideo
|
|
93
|
+
? { height: '100%', maxWidth: '100%' }
|
|
94
|
+
: { width: '206px', height: `${SILHOUETTE_HEIGHT}px` }),
|
|
95
|
+
}, children: _jsx(AvatarSilhouette, {}) }), !!emptyText && (_jsx(Box, { position: 'absolute', left: 0, right: 0, bottom: isVideo ? '50%' : `${SILHOUETTE_HEIGHT / 2}px`, display: 'flex', justifyContent: 'center', padding: '0 var(--spacing-tokens-size-in-px-spacing-spacing-lg)', boxSizing: 'border-box', children: _jsx(Typography, { text: emptyText, size: TypographySize.HeadingXS, weight: TypographyWeight.SemiBold, color: 'var(--color-text-text-subtle)', textStyle: {
|
|
96
|
+
textAlign: 'center',
|
|
97
|
+
wordBreak: 'break-word',
|
|
98
|
+
} }) }))] })), _jsx(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)', sx: {
|
|
76
99
|
backgroundImage: 'linear-gradient(180deg, rgba(21, 0, 73, 0) 0%, rgba(72, 29, 180, 0.152) 16.76%, rgba(32, 13, 82, 0.36) 100%)',
|
|
77
100
|
opacity: active && !isProcessing && !error ? 1 : 0,
|
|
78
101
|
transition: 'opacity 0.15s ease-in-out',
|
|
79
102
|
pointerEvents: 'none',
|
|
80
|
-
} }), isProcessing && (_jsxs(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', bgcolor: 'var(--color-background-bg-overlay-2)', sx: { zIndex: 1 }, children: [_jsx(Spinner, {}), _jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: 'var(--color-text-text-white)', children:
|
|
103
|
+
} }), isProcessing && (_jsxs(Box, { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', bgcolor: 'var(--color-background-bg-overlay-2)', sx: { zIndex: 1 }, children: [_jsx(Spinner, {}), _jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: 'var(--color-text-text-white)', children: PROCESSING_TEXT })] })), showBadge && (_jsx(Box, { position: 'absolute', top: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', left: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', sx: { zIndex: 2 }, children: _jsx(Badge, { text: STOCK_AGENT_BADGE_TEXT, color: BadgeColor.Violet, size: BadgeSize.md, testId: `${entityKey}-stock-agent-badge` }) })), showActions && (_jsxs(Box, { className: ACTIONS_CLASS, position: 'absolute', top: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', right: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', sx: {
|
|
81
104
|
zIndex: 4,
|
|
82
105
|
transition: 'opacity 0.15s ease-in-out',
|
|
83
106
|
...(menuOpen
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EntityCard } from './EntityCard';
|
|
2
|
-
import { BadgeColor } from '../UI';
|
|
3
2
|
const meta = {
|
|
4
3
|
title: 'Design System/Components/EntityCard/EntityCard',
|
|
5
4
|
component: EntityCard,
|
|
@@ -59,27 +58,11 @@ const meta = {
|
|
|
59
58
|
description: 'Show the processing overlay (spinner + label)',
|
|
60
59
|
table: { type: { summary: 'boolean' } },
|
|
61
60
|
},
|
|
62
|
-
processingText: {
|
|
63
|
-
control: 'text',
|
|
64
|
-
description: 'Processing overlay label',
|
|
65
|
-
table: {
|
|
66
|
-
type: { summary: 'string' },
|
|
67
|
-
defaultValue: { summary: 'Please wait' },
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
61
|
error: {
|
|
71
62
|
control: 'boolean',
|
|
72
63
|
description: 'Show the error state (tinted media area + warning icon)',
|
|
73
64
|
table: { type: { summary: 'boolean' } },
|
|
74
65
|
},
|
|
75
|
-
errorText: {
|
|
76
|
-
control: 'text',
|
|
77
|
-
description: "Accessible label for the error state (the warning icon's aria-label/title)",
|
|
78
|
-
table: {
|
|
79
|
-
type: { summary: 'string' },
|
|
80
|
-
defaultValue: { summary: 'Something went wrong' },
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
66
|
showMenu: {
|
|
84
67
|
control: 'boolean',
|
|
85
68
|
description: 'Whether to show the menu on hover',
|
|
@@ -102,23 +85,12 @@ const meta = {
|
|
|
102
85
|
defaultValue: { summary: 'Play' },
|
|
103
86
|
},
|
|
104
87
|
},
|
|
105
|
-
|
|
88
|
+
stockAgent: {
|
|
106
89
|
control: 'boolean',
|
|
107
|
-
description: '
|
|
108
|
-
table: { type: { summary: 'boolean' } },
|
|
109
|
-
},
|
|
110
|
-
statusBadgeText: {
|
|
111
|
-
control: 'text',
|
|
112
|
-
description: 'Status badge text (e.g. "Active")',
|
|
113
|
-
table: { type: { summary: 'string' } },
|
|
114
|
-
},
|
|
115
|
-
statusBadgeColor: {
|
|
116
|
-
control: 'select',
|
|
117
|
-
options: Object.values(BadgeColor),
|
|
118
|
-
description: 'Status badge color',
|
|
90
|
+
description: 'Marks the entity as a stock agent — renders the "Stock Agent" badge (top-left). `agent` view only',
|
|
119
91
|
table: {
|
|
120
|
-
type: { summary: '
|
|
121
|
-
defaultValue: { summary:
|
|
92
|
+
type: { summary: 'boolean' },
|
|
93
|
+
defaultValue: { summary: 'false' },
|
|
122
94
|
},
|
|
123
95
|
},
|
|
124
96
|
menuItems: {
|
|
@@ -158,8 +130,7 @@ export const AgentView = {
|
|
|
158
130
|
onPreview: () => { },
|
|
159
131
|
previewButtonText: 'Join',
|
|
160
132
|
previewIcon: 'VideoCamera',
|
|
161
|
-
|
|
162
|
-
statusBadgeText: 'Active',
|
|
133
|
+
stockAgent: true,
|
|
163
134
|
showMenu: true,
|
|
164
135
|
menuItems: [
|
|
165
136
|
{ label: 'Conversation Link', icon: 'ShareNetwork', onClick: () => { } },
|
|
@@ -177,7 +148,7 @@ export const AgentView = {
|
|
|
177
148
|
},
|
|
178
149
|
docs: {
|
|
179
150
|
description: {
|
|
180
|
-
story: 'The agent view — wider, square image,
|
|
151
|
+
story: 'The agent view — wider, square image, the "Stock Agent" badge, and a labelled "Join" action. Hover to reveal the action row.',
|
|
181
152
|
},
|
|
182
153
|
},
|
|
183
154
|
},
|
|
@@ -213,13 +184,13 @@ export const NoActions = {
|
|
|
213
184
|
export const NoImage = {
|
|
214
185
|
args: {
|
|
215
186
|
...Default.args,
|
|
216
|
-
name: '
|
|
187
|
+
name: 'Nelly Customer Support',
|
|
217
188
|
image: undefined,
|
|
218
189
|
},
|
|
219
190
|
parameters: {
|
|
220
191
|
docs: {
|
|
221
192
|
description: {
|
|
222
|
-
story: 'Fallback placeholder shown when no image is provided or it fails to load.',
|
|
193
|
+
story: 'Fallback placeholder shown when no image is provided or it fails to load — the avatar silhouette plus an "Avatar is not available" label sitting on the silhouette\'s midpoint. The `video` view reads "Video is not available".',
|
|
223
194
|
},
|
|
224
195
|
},
|
|
225
196
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { MenuItemProps
|
|
1
|
+
import { MenuItemProps } from '../UI';
|
|
2
2
|
import { IconName } from '../../utils';
|
|
3
3
|
/**
|
|
4
4
|
* Entity card view variants.
|
|
5
5
|
* - `avatar`: portrait avatar tile (icon-only preview action)
|
|
6
|
-
* - `agent`: wider, square agent tile (labelled action +
|
|
6
|
+
* - `agent`: wider, square agent tile (labelled action + stock-agent badge)
|
|
7
7
|
* - `video`: landscape media tile (name + date footer, optional processing overlay)
|
|
8
8
|
*/
|
|
9
9
|
export type EntityCardView = 'avatar' | 'agent' | 'video';
|
|
@@ -27,12 +27,8 @@ export interface EntityCardProps {
|
|
|
27
27
|
aspectRatio?: string;
|
|
28
28
|
/** Show the processing overlay (spinner + label) over the image */
|
|
29
29
|
processing?: boolean;
|
|
30
|
-
/** Processing overlay label. Defaults to "Please wait" */
|
|
31
|
-
processingText?: string;
|
|
32
30
|
/** Show the error state (tinted media area + warning icon) in place of the image */
|
|
33
31
|
error?: boolean;
|
|
34
|
-
/** Accessible label for the error state — exposed as the warning icon's aria-label/title. Defaults to "Something went wrong" */
|
|
35
|
-
errorText?: string;
|
|
36
32
|
/** Preview handler — renders the action button on hover */
|
|
37
33
|
onPreview?: () => void;
|
|
38
34
|
/** Label for the action button; when set it renders text + icon, otherwise icon-only */
|
|
@@ -41,12 +37,8 @@ export interface EntityCardProps {
|
|
|
41
37
|
previewIcon?: IconName;
|
|
42
38
|
/** Extra class names merged onto the action button — used by analytics click triggers */
|
|
43
39
|
previewButtonClassName?: string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
/** Status badge text (e.g. "Active") */
|
|
47
|
-
statusBadgeText?: string;
|
|
48
|
-
/** Status badge color (defaults to Green) */
|
|
49
|
-
statusBadgeColor?: BadgeColor;
|
|
40
|
+
/** Marks the entity as a stock agent — renders the "Stock Agent" badge (top-left). `agent` view only */
|
|
41
|
+
stockAgent?: boolean;
|
|
50
42
|
/** Menu items for the dropdown — renders the menu button on hover */
|
|
51
43
|
menuItems?: MenuItemProps[];
|
|
52
44
|
/** Whether to show the menu */
|