@beydesign/storybook 0.0.28 → 0.0.29
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/AgentCard.d.ts +4 -0
- package/dist/stories/AgentCard.js +37 -0
- package/dist/stories/AgentCard.stories.d.ts +6 -0
- package/dist/stories/AgentCard.stories.js +144 -0
- package/dist/stories/Badge.stories.js +9 -0
- package/dist/stories/Bagde.js +3 -7
- package/dist/stories/Button.js +2 -6
- package/dist/stories/Menu.d.ts +4 -0
- package/dist/stories/Menu.js +57 -0
- package/dist/stories/Menu.stories.d.ts +43 -0
- package/dist/stories/Menu.stories.js +48 -0
- package/dist/stories/NavItem.js +1 -5
- package/dist/stories/Typography.js +2 -1
- package/dist/stories/types/agent-card.d.ts +53 -0
- package/dist/stories/types/agent-card.js +7 -0
- package/dist/stories/types/badge.d.ts +4 -2
- package/dist/stories/types/button.d.ts +6 -6
- package/dist/stories/types/menu.d.ts +30 -0
- package/dist/stories/types/menu.js +1 -0
- package/dist/stories/types/nav-item.d.ts +2 -1
- package/dist/stories/types/sidebar.d.ts +2 -1
- package/dist/stories/types/typography.d.ts +2 -0
- package/dist/utils/icon.d.ts +4 -0
- package/dist/utils/icon.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { AgentState, } from './types/agent-card';
|
|
4
|
+
import { Box } from '@mui/material';
|
|
5
|
+
import { Typography } from './Typography';
|
|
6
|
+
import { TypographySize, TypographyWeight } from './types/typography';
|
|
7
|
+
import { Toggle } from './Toggle';
|
|
8
|
+
import { TogglePosition } from './types/toggle';
|
|
9
|
+
import { Badge } from './Bagde';
|
|
10
|
+
import { BadgeColor, BadgeSize } from './types/badge';
|
|
11
|
+
import { MainButton } from './Button';
|
|
12
|
+
import { ButtonHierarchy, ButtonSize } from './types/button';
|
|
13
|
+
import { Menu } from './Menu';
|
|
14
|
+
import { ArrowsCounterClockwise } from '@phosphor-icons/react';
|
|
15
|
+
import { ProgressIndicator } from './ProgressIndicator';
|
|
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, }) => {
|
|
18
|
+
const [hovered, setHovered] = useState(false);
|
|
19
|
+
// const isError = agentState === AgentState.error;
|
|
20
|
+
// const isDraft = agentState === AgentState.pending;
|
|
21
|
+
const isProcessing = agentState === AgentState.processing;
|
|
22
|
+
const isReady = agentState === AgentState.ready;
|
|
23
|
+
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: 'var(--colors-light-background-bg-component)', boxShadow: '0px 2px 8px 0px #2207380A', 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: [agentImage && (_jsx("img", { src: agentImage, alt: "Agent", width: '100%', height: '100%', style: { objectFit: 'cover' } })), showTimeBadge && time && (_jsx(Badge, { text: time, size: BadgeSize.md, fill: true, style: {
|
|
24
|
+
position: 'absolute',
|
|
25
|
+
right: '8px',
|
|
26
|
+
bottom: '8px',
|
|
27
|
+
zIndex: 2,
|
|
28
|
+
}, color: BadgeColor.Violet })), showMenu && menuItems.length > 0 && (_jsx(Menu, { items: menuItems, style: {
|
|
29
|
+
zIndex: 2,
|
|
30
|
+
position: 'absolute',
|
|
31
|
+
right: '8px',
|
|
32
|
+
top: '8px',
|
|
33
|
+
} })), 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: "Preview", 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)' }))] }));
|
|
34
|
+
};
|
|
35
|
+
export const Components = () => {
|
|
36
|
+
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" }) }) })] }));
|
|
37
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { AgentCard } from './AgentCard';
|
|
2
|
+
import { AgentState } from './types/agent-card';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Design System/Components/AgentCard',
|
|
5
|
+
component: AgentCard,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
design: {
|
|
9
|
+
type: 'figspec',
|
|
10
|
+
url: 'https://www.figma.com/design/mIhjz2yJjcpLlIqw6oUivt/Beyond-Presence?node-id=5155-1047&t=qmLHvTvP8XX3NuUh-1',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: {
|
|
15
|
+
agentImage: {
|
|
16
|
+
control: 'text',
|
|
17
|
+
description: 'Image of the agent',
|
|
18
|
+
table: {
|
|
19
|
+
type: { summary: 'string' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
showDate: {
|
|
23
|
+
control: 'boolean',
|
|
24
|
+
description: 'Whether to show the date',
|
|
25
|
+
table: {
|
|
26
|
+
type: { summary: 'boolean' },
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
badges: {
|
|
30
|
+
description: 'Badges of the agent',
|
|
31
|
+
table: {
|
|
32
|
+
type: { summary: 'array' },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
showBadges: {
|
|
36
|
+
control: 'boolean',
|
|
37
|
+
description: 'Whether to show the badges',
|
|
38
|
+
table: {
|
|
39
|
+
type: { summary: 'boolean' },
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
showTimeBadge: {
|
|
43
|
+
control: 'boolean',
|
|
44
|
+
description: 'Whether to show the time badge',
|
|
45
|
+
table: {
|
|
46
|
+
type: { summary: 'boolean' },
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
showDescription: {
|
|
50
|
+
control: 'boolean',
|
|
51
|
+
description: 'Whether to show the description',
|
|
52
|
+
table: {
|
|
53
|
+
type: { summary: 'boolean' },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
showMenu: {
|
|
57
|
+
control: 'boolean',
|
|
58
|
+
description: 'Whether to show the menu',
|
|
59
|
+
table: {
|
|
60
|
+
type: { summary: 'boolean' },
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
active: {
|
|
64
|
+
control: 'boolean',
|
|
65
|
+
description: 'Whether the agent is active',
|
|
66
|
+
table: {
|
|
67
|
+
type: { summary: 'boolean' },
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
activeToggleDisabled: {
|
|
71
|
+
control: 'boolean',
|
|
72
|
+
description: 'Whether the active toggle is disabled',
|
|
73
|
+
table: {
|
|
74
|
+
type: { summary: 'boolean' },
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
showActiveToggle: {
|
|
78
|
+
control: 'boolean',
|
|
79
|
+
description: 'Whether to show the active toggle',
|
|
80
|
+
table: {
|
|
81
|
+
type: { summary: 'boolean' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
onActiveToggleChange: {
|
|
85
|
+
description: 'Callback function for active toggle change',
|
|
86
|
+
table: {
|
|
87
|
+
type: { summary: 'function' },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
date: {
|
|
91
|
+
control: 'text',
|
|
92
|
+
description: 'Date of the agent',
|
|
93
|
+
table: {
|
|
94
|
+
type: { summary: 'string' },
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
description: {
|
|
98
|
+
control: 'text',
|
|
99
|
+
description: 'Description of the agent',
|
|
100
|
+
table: {
|
|
101
|
+
type: { summary: 'string' },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
title: {
|
|
105
|
+
control: 'text',
|
|
106
|
+
description: 'Title of the agent',
|
|
107
|
+
table: {
|
|
108
|
+
type: { summary: 'string' },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
agentState: {
|
|
112
|
+
control: 'select',
|
|
113
|
+
description: 'State of the agent',
|
|
114
|
+
options: Object.values(AgentState),
|
|
115
|
+
table: {
|
|
116
|
+
type: { summary: 'string' },
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
export default meta;
|
|
122
|
+
export const Placeholder = {
|
|
123
|
+
args: {
|
|
124
|
+
title: 'Agent Card',
|
|
125
|
+
active: true,
|
|
126
|
+
showActiveToggle: true,
|
|
127
|
+
showDate: true,
|
|
128
|
+
date: '2024-01-01',
|
|
129
|
+
badges: ['HR', 'Sales', 'Marketing'],
|
|
130
|
+
showBadges: true,
|
|
131
|
+
showDescription: true,
|
|
132
|
+
description: 'This is a very long description that will wrap to the next line',
|
|
133
|
+
agentImage: 'https://images.unsplash.com/photo-1575936123452-b67c3203c357?fm=jpg&q=60&w=3000&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxzZWFyY2h8Mnx8aW1hZ2V8ZW58MHx8MHx8fDA%3D',
|
|
134
|
+
showTimeBadge: true,
|
|
135
|
+
time: '10:00',
|
|
136
|
+
onPreview: () => { },
|
|
137
|
+
menuItems: [
|
|
138
|
+
{ label: 'Edit', icon: 'Pencil', onClick: () => { } },
|
|
139
|
+
{ label: 'Delete', icon: 'Trash', onClick: () => { }, destructive: true },
|
|
140
|
+
],
|
|
141
|
+
showMenu: true,
|
|
142
|
+
agentState: AgentState.processing,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
@@ -35,6 +35,13 @@ const meta = {
|
|
|
35
35
|
type: { summary: 'string' },
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
|
+
showIcon: {
|
|
39
|
+
control: 'boolean',
|
|
40
|
+
description: 'Whether to show the Icon',
|
|
41
|
+
table: {
|
|
42
|
+
type: { summary: 'boolean' },
|
|
43
|
+
},
|
|
44
|
+
},
|
|
38
45
|
icon: {
|
|
39
46
|
control: 'text',
|
|
40
47
|
description: 'Name of the display Phosphor icon (e.g., "Circle")',
|
|
@@ -82,6 +89,8 @@ export const Green = {
|
|
|
82
89
|
args: {
|
|
83
90
|
text: 'Badge',
|
|
84
91
|
color: BadgeColor.Green,
|
|
92
|
+
showIcon: true,
|
|
93
|
+
icon: 'Cactus',
|
|
85
94
|
},
|
|
86
95
|
};
|
|
87
96
|
export const Red = {
|
package/dist/stories/Bagde.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { BadgeColor, BadgeSize } from './types/badge';
|
|
3
|
-
import * as PhosphorIcons from '@phosphor-icons/react';
|
|
4
3
|
import { Box } from '@mui/material';
|
|
5
4
|
import { Typography } from './Typography';
|
|
6
5
|
import { TypographySize, TypographyWeight } from './types/typography';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return Icon ? _jsx(Icon, { ...props }) : null;
|
|
10
|
-
};
|
|
11
|
-
export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, style: customStyle, icon = 'Cactus', fill = true, }) => {
|
|
6
|
+
import { getIconComponent } from '../utils/icon';
|
|
7
|
+
export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, style: customStyle, icon = 'Cactus', showIcon = false, fill = true, }) => {
|
|
12
8
|
const getBackgroundColor = (color) => {
|
|
13
9
|
switch (color) {
|
|
14
10
|
case BadgeColor.Default:
|
|
@@ -109,5 +105,5 @@ export const Badge = ({ color = BadgeColor.Default, size = BadgeSize.md, text, s
|
|
|
109
105
|
color: getTextColor(),
|
|
110
106
|
weight: 'regular',
|
|
111
107
|
};
|
|
112
|
-
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: [icon && getIconComponent(icon, iconProps), text && (_jsx(Typography, { text: text, size: TypographySize.TextS, weight: TypographyWeight.Medium, color: getTextColor() }))] }));
|
|
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: TypographySize.TextS, weight: TypographyWeight.Medium, color: getTextColor() }))] }));
|
|
113
109
|
};
|
package/dist/stories/Button.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CircularProgress } from '@mui/material';
|
|
3
|
-
import * as PhosphorIcons from '@phosphor-icons/react';
|
|
4
3
|
import styled from '@emotion/styled';
|
|
5
4
|
import { ButtonSize, ButtonHierarchy, ButtonState, ButtonShape, ButtonDisplayMode, ButtonType, } from './types/button';
|
|
6
5
|
import { Typography } from './Typography';
|
|
7
6
|
import { TypographySize, TypographyWeight } from './types/typography';
|
|
8
|
-
|
|
9
|
-
const Icon = PhosphorIcons[iconName];
|
|
10
|
-
return Icon ? _jsx(Icon, { ...props }) : null;
|
|
11
|
-
};
|
|
7
|
+
import { getIconComponent } from '../utils/icon';
|
|
12
8
|
const StyledButton = styled.button `
|
|
13
9
|
text-transform: none;
|
|
14
10
|
padding: ${(props) => props.$displayIconMode === ButtonDisplayMode.Only
|
|
@@ -283,7 +279,7 @@ export const MainButton = ({ onClick, text, disabled = false, loading = false, t
|
|
|
283
279
|
gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
284
280
|
}, children: [showLeadingIcon &&
|
|
285
281
|
leadingIcon &&
|
|
286
|
-
getIconComponent(leadingIcon, iconProps), _jsx(Typography, { text: text, size: getTextSize(), weight: TypographyWeight.SemiBold }), showTrailingIcon &&
|
|
282
|
+
getIconComponent(leadingIcon, iconProps), text && (_jsx(Typography, { text: text, size: getTextSize(), weight: TypographyWeight.SemiBold })), showTrailingIcon &&
|
|
287
283
|
trailingIcon &&
|
|
288
284
|
getIconComponent(trailingIcon, iconProps)] }));
|
|
289
285
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MenuItem as MuiMenuItem, Menu as MuiMenu, } from '@mui/material';
|
|
3
|
+
import { Fragment, useState } from 'react';
|
|
4
|
+
import { MainButton } from './Button';
|
|
5
|
+
import { ButtonDisplayMode, ButtonHierarchy, ButtonType } from './types/button';
|
|
6
|
+
import { Typography } from './Typography';
|
|
7
|
+
import { TypographySize, TypographyWeight } from './types/typography';
|
|
8
|
+
import { getIconComponent } from '../utils/icon';
|
|
9
|
+
export const Menu = ({ icon = 'DotsThree', items, style, }) => {
|
|
10
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
|
+
const open = Boolean(anchorEl);
|
|
12
|
+
const handleClick = (event) => {
|
|
13
|
+
setAnchorEl(event.currentTarget);
|
|
14
|
+
};
|
|
15
|
+
const handleClose = () => {
|
|
16
|
+
setAnchorEl(null);
|
|
17
|
+
};
|
|
18
|
+
const handleMenuItemClick = (item, event) => {
|
|
19
|
+
handleClose();
|
|
20
|
+
if (item.onClick) {
|
|
21
|
+
item?.onClick(event);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const getColor = (action) => {
|
|
25
|
+
if (action?.destructive)
|
|
26
|
+
return 'var(--colors-light-text-text-error)';
|
|
27
|
+
return 'var(--colors-light-text-text-title)';
|
|
28
|
+
};
|
|
29
|
+
return (_jsxs(Fragment, { children: [_jsx(MainButton, { displayIcon: icon, onClick: handleClick, type: ButtonType.Button, displayIconMode: ButtonDisplayMode.Only, hierarchy: ButtonHierarchy.Secondary, style: style }), _jsx(MuiMenu, { id: "basic-menu", anchorEl: anchorEl, open: open, onClose: handleClose, MenuListProps: {
|
|
30
|
+
'aria-labelledby': 'basic-button',
|
|
31
|
+
style: {
|
|
32
|
+
padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)',
|
|
33
|
+
},
|
|
34
|
+
}, slotProps: {
|
|
35
|
+
paper: {
|
|
36
|
+
style: {
|
|
37
|
+
borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-sm)',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
root: { style: { gap: '4px' } },
|
|
41
|
+
}, children: items?.map((action, index) => {
|
|
42
|
+
if (action) {
|
|
43
|
+
return (_jsxs(MuiMenuItem, { onClick: (e) => handleMenuItemClick(action, e), sx: { gap: '8px' }, disableRipple: true, children: [action?.icon &&
|
|
44
|
+
getIconComponent(action.icon, {
|
|
45
|
+
width: '20px',
|
|
46
|
+
height: '20px',
|
|
47
|
+
color: getColor(action),
|
|
48
|
+
}), action?.label && (_jsx(Typography, { text: action.label, size: TypographySize.TextS, weight: TypographyWeight.Regular, color: getColor(action) }))] }, index));
|
|
49
|
+
}
|
|
50
|
+
}) })] }));
|
|
51
|
+
};
|
|
52
|
+
export const Components = () => {
|
|
53
|
+
return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "Menu" }), _jsx("div", { style: { display: 'flex', gap: '1rem', flexDirection: 'column' }, children: _jsx(Menu, { icon: "DotsThree", items: [
|
|
54
|
+
{ label: 'Edit', onClick: () => { }, icon: 'Pencil' },
|
|
55
|
+
{ label: 'Delete', onClick: () => { }, icon: 'Trash' },
|
|
56
|
+
] }) })] }));
|
|
57
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").FC<import("./types/menu").MenuProps>;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
tags: string[];
|
|
9
|
+
argTypes: {
|
|
10
|
+
icon: {
|
|
11
|
+
control: "select";
|
|
12
|
+
options: string[];
|
|
13
|
+
defaultValue: string;
|
|
14
|
+
description: string;
|
|
15
|
+
table: {
|
|
16
|
+
type: {
|
|
17
|
+
summary: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
items: {
|
|
22
|
+
control: "object";
|
|
23
|
+
description: string;
|
|
24
|
+
table: {
|
|
25
|
+
type: {
|
|
26
|
+
summary: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
style: {
|
|
31
|
+
control: "object";
|
|
32
|
+
description: string;
|
|
33
|
+
table: {
|
|
34
|
+
type: {
|
|
35
|
+
summary: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export default meta;
|
|
42
|
+
type Story = StoryObj<typeof meta>;
|
|
43
|
+
export declare const Default: Story;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Menu } from './Menu';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Design System/Components/Menu',
|
|
4
|
+
component: Menu,
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'centered',
|
|
7
|
+
},
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: {
|
|
10
|
+
icon: {
|
|
11
|
+
control: 'select',
|
|
12
|
+
options: ['DotsThree', 'Pencil', 'Trash'],
|
|
13
|
+
defaultValue: 'DotsThree',
|
|
14
|
+
description: 'The icon to display in the menu',
|
|
15
|
+
table: {
|
|
16
|
+
type: {
|
|
17
|
+
summary: 'string',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
items: {
|
|
22
|
+
control: 'object',
|
|
23
|
+
description: 'The items to display in the menu',
|
|
24
|
+
table: {
|
|
25
|
+
type: {
|
|
26
|
+
summary: 'MenuItemProps[]',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
style: {
|
|
31
|
+
control: 'object',
|
|
32
|
+
description: 'The style to display in the menu',
|
|
33
|
+
table: {
|
|
34
|
+
type: { summary: 'CSSProperties' },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export default meta;
|
|
40
|
+
export const Default = {
|
|
41
|
+
args: {
|
|
42
|
+
icon: 'DotsThree',
|
|
43
|
+
items: [
|
|
44
|
+
{ label: 'Edit', onClick: () => { }, destructive: false, icon: 'Pencil' },
|
|
45
|
+
{ label: 'Delete', onClick: () => { }, destructive: true, icon: 'Trash' },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
};
|
package/dist/stories/NavItem.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
|
-
import * as PhosphorIcons from '@phosphor-icons/react';
|
|
4
3
|
import { NavItemState, NavItemSize } from './types/nav-item';
|
|
5
4
|
import { Typography } from './Typography';
|
|
6
5
|
import { TypographySize, TypographyWeight } from './types/typography';
|
|
7
6
|
import { Badge } from './Bagde';
|
|
8
7
|
import { BadgeColor, BadgeSize } from './types/badge';
|
|
9
8
|
import { Box } from '@mui/material';
|
|
10
|
-
|
|
11
|
-
const Icon = PhosphorIcons[iconName];
|
|
12
|
-
return Icon ? _jsx(Icon, { ...props }) : null;
|
|
13
|
-
};
|
|
9
|
+
import { getIconComponent } from '../utils/icon';
|
|
14
10
|
const StyledNavItem = styled.div `
|
|
15
11
|
display: flex;
|
|
16
12
|
flex-direction: row;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { TypographySize, TypographyWeight, } from './types/typography';
|
|
3
|
-
export const Typography = ({ text, color, size = TypographySize.HeadingL, weight = TypographyWeight.Bold, className, }) => {
|
|
3
|
+
export const Typography = ({ text, color, size = TypographySize.HeadingL, weight = TypographyWeight.Bold, className, style, }) => {
|
|
4
4
|
const getTypographySizeToken = () => {
|
|
5
5
|
let sizeLc = size?.toLowerCase() || '';
|
|
6
6
|
if (sizeLc.includes('heading')) {
|
|
@@ -47,6 +47,7 @@ export const Typography = ({ text, color, size = TypographySize.HeadingL, weight
|
|
|
47
47
|
textTransform: getTextTransform(),
|
|
48
48
|
textDecoration: textDecoration,
|
|
49
49
|
color: color || 'var(--global-text-text-title)',
|
|
50
|
+
...style,
|
|
50
51
|
}, children: text }));
|
|
51
52
|
};
|
|
52
53
|
export const Components = () => {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { MenuItemProps } from './menu';
|
|
2
|
+
export declare enum AgentState {
|
|
3
|
+
pending = "pending",
|
|
4
|
+
processing = "processing",
|
|
5
|
+
error = "error",
|
|
6
|
+
ready = "ready"
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Agent card component props
|
|
10
|
+
*/
|
|
11
|
+
export type AgentCardProps = {
|
|
12
|
+
/** Agent image */
|
|
13
|
+
agentImage?: string;
|
|
14
|
+
/** Show date */
|
|
15
|
+
showDate?: boolean;
|
|
16
|
+
/** Badges */
|
|
17
|
+
badges?: string[];
|
|
18
|
+
/** Show badges */
|
|
19
|
+
showBadges?: boolean;
|
|
20
|
+
/** Time */
|
|
21
|
+
time?: string;
|
|
22
|
+
/** Show time badge */
|
|
23
|
+
showTimeBadge?: boolean;
|
|
24
|
+
/** Show description */
|
|
25
|
+
showDescription?: boolean;
|
|
26
|
+
/** Menu items */
|
|
27
|
+
menuItems?: MenuItemProps[];
|
|
28
|
+
/** Show menu */
|
|
29
|
+
showMenu?: boolean;
|
|
30
|
+
/** Description */
|
|
31
|
+
description?: string;
|
|
32
|
+
/** Title */
|
|
33
|
+
title: string;
|
|
34
|
+
/** Date */
|
|
35
|
+
date?: string;
|
|
36
|
+
/** Active */
|
|
37
|
+
active?: boolean;
|
|
38
|
+
/** Show active toggle */
|
|
39
|
+
showActiveToggle?: boolean;
|
|
40
|
+
/** On active toggle change */
|
|
41
|
+
onActiveToggleChange?: (active: boolean) => void;
|
|
42
|
+
/** Active toggle disabled */
|
|
43
|
+
activeToggleDisabled?: boolean;
|
|
44
|
+
/** On preview */
|
|
45
|
+
onPreview?: () => void;
|
|
46
|
+
/** Agent state */
|
|
47
|
+
agentState?: AgentState;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Props for the Components wrapper
|
|
51
|
+
*/
|
|
52
|
+
export interface ComponentsProps {
|
|
53
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { IconName } from '../../utils/icon';
|
|
1
2
|
import type { SxProps, Theme } from '@mui/material';
|
|
2
|
-
import * as PhosphorIcons from '@phosphor-icons/react';
|
|
3
3
|
/**
|
|
4
4
|
* Badge size variants
|
|
5
5
|
*/
|
|
@@ -35,8 +35,10 @@ export type BadgeProps = {
|
|
|
35
35
|
text: string;
|
|
36
36
|
/** Custom style of the badge */
|
|
37
37
|
style?: SxProps<Theme>;
|
|
38
|
+
/** Whether to show the Icon */
|
|
39
|
+
showIcon?: boolean;
|
|
38
40
|
/** Icon to display in the badge */
|
|
39
|
-
icon?:
|
|
41
|
+
icon?: IconName;
|
|
40
42
|
/** Whether to fill the icon */
|
|
41
43
|
fill?: boolean;
|
|
42
44
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { IconName } from '../../utils/icon';
|
|
3
3
|
/**
|
|
4
4
|
* Button size variants
|
|
5
5
|
*/
|
|
@@ -65,9 +65,9 @@ export interface ButtonSizeConfig {
|
|
|
65
65
|
*/
|
|
66
66
|
export interface MainButtonProps {
|
|
67
67
|
/** Click handler for the button */
|
|
68
|
-
onClick?:
|
|
68
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
69
69
|
/** Text content of the button */
|
|
70
|
-
text
|
|
70
|
+
text?: string;
|
|
71
71
|
/** Whether the button is disabled */
|
|
72
72
|
disabled?: boolean;
|
|
73
73
|
/** Whether the button is in loading state */
|
|
@@ -81,7 +81,7 @@ export interface MainButtonProps {
|
|
|
81
81
|
/** Visual hierarchy of the button */
|
|
82
82
|
hierarchy?: ButtonHierarchy;
|
|
83
83
|
/** Icon to display when in icon mode */
|
|
84
|
-
displayIcon?:
|
|
84
|
+
displayIcon?: IconName;
|
|
85
85
|
/** How to display the icon */
|
|
86
86
|
displayIconMode?: ButtonDisplayMode;
|
|
87
87
|
/** Current state of the button */
|
|
@@ -95,9 +95,9 @@ export interface MainButtonProps {
|
|
|
95
95
|
/** Whether to show the trailing icon */
|
|
96
96
|
showTrailingIcon?: boolean;
|
|
97
97
|
/** Icon to show at the start of the button */
|
|
98
|
-
leadingIcon?:
|
|
98
|
+
leadingIcon?: IconName;
|
|
99
99
|
/** Icon to show at the end of the button */
|
|
100
|
-
trailingIcon?:
|
|
100
|
+
trailingIcon?: IconName;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Props for the Components wrapper
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IconName } from '../../utils/icon';
|
|
2
|
+
/**
|
|
3
|
+
* Menu item
|
|
4
|
+
*/
|
|
5
|
+
export interface MenuItemProps {
|
|
6
|
+
/** Label */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Icon */
|
|
9
|
+
icon: IconName;
|
|
10
|
+
/** On click */
|
|
11
|
+
onClick: () => void;
|
|
12
|
+
/** Destructive */
|
|
13
|
+
destructive?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Menu component props
|
|
17
|
+
*/
|
|
18
|
+
export type MenuProps = {
|
|
19
|
+
/** Icon */
|
|
20
|
+
icon?: IconName;
|
|
21
|
+
/** Items */
|
|
22
|
+
items?: MenuItemProps[];
|
|
23
|
+
/** Style */
|
|
24
|
+
style?: React.CSSProperties;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Props for the Components wrapper
|
|
28
|
+
*/
|
|
29
|
+
export interface ComponentsProps {
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconName } from '../../utils/icon';
|
|
1
2
|
export declare enum NavItemState {
|
|
2
3
|
Default = "default",
|
|
3
4
|
Active = "active",
|
|
@@ -16,7 +17,7 @@ export interface NavItemProps {
|
|
|
16
17
|
* The icon to display before the text
|
|
17
18
|
* Uses Phosphor Icons
|
|
18
19
|
*/
|
|
19
|
-
icon:
|
|
20
|
+
icon: IconName;
|
|
20
21
|
/**
|
|
21
22
|
* The current state of the navigation item
|
|
22
23
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IconName } from '../../utils/icon';
|
|
1
2
|
export declare enum SidebarSize {
|
|
2
3
|
Expanded = "expanded",
|
|
3
4
|
Collapsed = "collapsed"
|
|
@@ -10,7 +11,7 @@ export interface NavItemConfig {
|
|
|
10
11
|
/**
|
|
11
12
|
* The icon to display before the text (Phosphor icon name)
|
|
12
13
|
*/
|
|
13
|
-
icon:
|
|
14
|
+
icon: IconName;
|
|
14
15
|
/**
|
|
15
16
|
* The current state of the navigation item
|
|
16
17
|
*/
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import * as PhosphorIcons from '@phosphor-icons/react';
|
|
2
|
+
import type { IconProps } from '@phosphor-icons/react';
|
|
3
|
+
export type IconName = keyof typeof PhosphorIcons;
|
|
4
|
+
export declare const getIconComponent: (iconName: IconName, props: IconProps) => import("react/jsx-runtime").JSX.Element | null;
|