@beydesign/storybook 0.2.3 → 0.2.5
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 +1 -0
- package/dist/index.js +1 -0
- package/dist/stories/Drawer/Drawer.d.ts +10 -0
- package/dist/stories/Drawer/Drawer.js +161 -0
- package/dist/stories/Drawer/Drawer.stories.d.ts +9 -0
- package/dist/stories/Drawer/Drawer.stories.js +107 -0
- package/dist/stories/Drawer/DrawerCreditsCard.d.ts +9 -0
- package/dist/stories/Drawer/DrawerCreditsCard.js +143 -0
- package/dist/stories/Drawer/DrawerCreditsCard.stories.d.ts +8 -0
- package/dist/stories/Drawer/DrawerCreditsCard.stories.js +45 -0
- package/dist/stories/Drawer/DrawerIcons.d.ts +14 -0
- package/dist/stories/Drawer/DrawerIcons.js +7 -0
- package/dist/stories/Drawer/DrawerNavItem.d.ts +8 -0
- package/dist/stories/Drawer/DrawerNavItem.js +87 -0
- package/dist/stories/Drawer/DrawerNavItem.stories.d.ts +11 -0
- package/dist/stories/Drawer/DrawerNavItem.stories.js +82 -0
- package/dist/stories/Drawer/DrawerProfile.d.ts +10 -0
- package/dist/stories/Drawer/DrawerProfile.js +170 -0
- package/dist/stories/Drawer/DrawerProfile.stories.d.ts +9 -0
- package/dist/stories/Drawer/DrawerProfile.stories.js +60 -0
- package/dist/stories/Drawer/index.d.ts +6 -0
- package/dist/stories/Drawer/index.js +6 -0
- package/dist/stories/Drawer/types.d.ts +164 -0
- package/dist/stories/Drawer/types.js +29 -0
- package/dist/stories/Form/TextInput.js +2 -2
- package/dist/stories/Form/TextInput.stories.d.ts +13 -0
- package/dist/stories/Form/TextInput.stories.js +18 -0
- package/dist/stories/Form/types.d.ts +5 -0
- package/dist/stories/UI/Menu.js +1 -1
- package/dist/stories/UI/Popover.d.ts +10 -0
- package/dist/stories/UI/Popover.js +66 -0
- package/dist/stories/UI/Popover.stories.d.ts +7 -0
- package/dist/stories/UI/Popover.stories.js +62 -0
- package/dist/stories/UI/ProgressIndicator.js +7 -3
- package/dist/stories/UI/ProgressIndicator.stories.d.ts +1 -0
- package/dist/stories/UI/ProgressIndicator.stories.js +9 -0
- package/dist/stories/UI/index.d.ts +1 -0
- package/dist/stories/UI/index.js +1 -0
- package/dist/stories/UI/types.d.ts +49 -2
- package/dist/stories/UI/types.js +10 -0
- package/package.json +1 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { Tooltip, ClickAwayListener } from '@mui/material';
|
|
4
|
+
import { PopoverVariant } from './types';
|
|
5
|
+
/** Composed from the semantic `shadow-sm` design token. */
|
|
6
|
+
const SHADOW_SM = 'var(--global-shadows-shadow-sm-offset-x) var(--global-shadows-shadow-sm-offset-y) var(--global-shadows-shadow-sm-blur) var(--global-shadows-shadow-sm-spread) var(--global-shadows-shadow-sm-color)';
|
|
7
|
+
const VARIANT_BG = {
|
|
8
|
+
[PopoverVariant.Dark]: 'var(--color-background-bg-black)',
|
|
9
|
+
[PopoverVariant.Light]: 'var(--color-background-bg-page-contrast)',
|
|
10
|
+
};
|
|
11
|
+
const VARIANT_COLOR = {
|
|
12
|
+
[PopoverVariant.Dark]: 'var(--color-text-text-white)',
|
|
13
|
+
[PopoverVariant.Light]: 'var(--color-text-text-title)',
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Design-system popover: a floating panel anchored to a trigger element that
|
|
17
|
+
* renders arbitrary content. Wraps MUI `Tooltip` for positioning and the arrow,
|
|
18
|
+
* then applies theme-aware token styling. Opens on hover/focus (default) or on
|
|
19
|
+
* click (menu-style, dismissed by an outside click). Supports a dark or light
|
|
20
|
+
* surface and an optional controlled open state.
|
|
21
|
+
*/
|
|
22
|
+
export const Popover = ({ content, children, variant = PopoverVariant.Dark, placement = 'top', trigger = 'hover', arrow = true, maxWidth = 280, padding = 'var(--spacing-tokens-size-in-px-spacing-spacing-lg)', open, onOpenChange, disableInteractive = false, className, }) => {
|
|
23
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
24
|
+
const isControlled = open !== undefined;
|
|
25
|
+
const isOpen = isControlled ? open : internalOpen;
|
|
26
|
+
const setOpen = (next) => {
|
|
27
|
+
if (!isControlled)
|
|
28
|
+
setInternalOpen(next);
|
|
29
|
+
onOpenChange?.(next);
|
|
30
|
+
};
|
|
31
|
+
const background = VARIANT_BG[variant];
|
|
32
|
+
const slotProps = {
|
|
33
|
+
tooltip: {
|
|
34
|
+
className,
|
|
35
|
+
sx: {
|
|
36
|
+
backgroundColor: background,
|
|
37
|
+
color: VARIANT_COLOR[variant],
|
|
38
|
+
padding,
|
|
39
|
+
borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-xs)',
|
|
40
|
+
boxShadow: SHADOW_SM,
|
|
41
|
+
maxWidth,
|
|
42
|
+
border: variant === PopoverVariant.Light
|
|
43
|
+
? '1px solid var(--color-border-border-subtle)'
|
|
44
|
+
: 'none',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
arrow: { sx: { color: background } },
|
|
48
|
+
};
|
|
49
|
+
if (trigger === 'click') {
|
|
50
|
+
const triggerEl = React.cloneElement(children, {
|
|
51
|
+
onClick: (event) => {
|
|
52
|
+
children.props.onClick?.(event);
|
|
53
|
+
setOpen(!isOpen);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
return (_jsx(ClickAwayListener, { onClickAway: () => setOpen(false), children: _jsx(Tooltip, { open: isOpen, placement: placement, arrow: arrow, title: content, disableHoverListener: true, disableFocusListener: true, disableTouchListener: true, slotProps: slotProps, children: triggerEl }) }));
|
|
57
|
+
}
|
|
58
|
+
const controlledProps = isControlled
|
|
59
|
+
? {
|
|
60
|
+
open,
|
|
61
|
+
onOpen: () => onOpenChange?.(true),
|
|
62
|
+
onClose: () => onOpenChange?.(false),
|
|
63
|
+
}
|
|
64
|
+
: {};
|
|
65
|
+
return (_jsx(Tooltip, { arrow: arrow, placement: placement, disableInteractive: disableInteractive, title: content, ...controlledProps, slotProps: slotProps, children: children }));
|
|
66
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Popover } from './Popover';
|
|
3
|
+
declare const meta: Meta<typeof Popover>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Popover>;
|
|
6
|
+
export declare const Dark: Story;
|
|
7
|
+
export declare const Light: Story;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Popover } from './Popover';
|
|
4
|
+
import { PopoverVariant } from './types';
|
|
5
|
+
import { Typography, TypographySize, TypographyWeight } from '../Typography';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Design System/Components/UI/Popover',
|
|
8
|
+
component: Popover,
|
|
9
|
+
parameters: { layout: 'centered' },
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
argTypes: {
|
|
12
|
+
variant: {
|
|
13
|
+
control: 'inline-radio',
|
|
14
|
+
options: Object.values(PopoverVariant),
|
|
15
|
+
table: { defaultValue: { summary: 'Dark' } },
|
|
16
|
+
},
|
|
17
|
+
placement: {
|
|
18
|
+
control: 'select',
|
|
19
|
+
options: ['top', 'right', 'bottom', 'left'],
|
|
20
|
+
table: { defaultValue: { summary: 'top' } },
|
|
21
|
+
},
|
|
22
|
+
arrow: { control: 'boolean', table: { defaultValue: { summary: 'true' } } },
|
|
23
|
+
maxWidth: {
|
|
24
|
+
control: 'number',
|
|
25
|
+
table: { defaultValue: { summary: '280' } },
|
|
26
|
+
},
|
|
27
|
+
content: { control: false },
|
|
28
|
+
children: { control: false },
|
|
29
|
+
},
|
|
30
|
+
decorators: [
|
|
31
|
+
(Story) => (_jsx("div", { style: { padding: 80 }, children: _jsx(Story, {}) })),
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
export default meta;
|
|
35
|
+
// MUI Tooltip injects a ref + hover handlers into its child, so the trigger
|
|
36
|
+
// must forward the ref and spread the received props onto a DOM node.
|
|
37
|
+
const Trigger = React.forwardRef((props, ref) => (_jsx("button", { ...props, ref: ref, type: "button", style: {
|
|
38
|
+
padding: '8px 16px',
|
|
39
|
+
borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-sm)',
|
|
40
|
+
border: '1px solid var(--color-border-border-component)',
|
|
41
|
+
background: 'var(--color-background-bg-page-contrast)',
|
|
42
|
+
color: 'var(--color-text-text-title)',
|
|
43
|
+
cursor: 'pointer',
|
|
44
|
+
}, children: "Hover me" })));
|
|
45
|
+
Trigger.displayName = 'Trigger';
|
|
46
|
+
const RichContent = () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [_jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: "var(--color-text-text-white)", children: "Credit rates" }), _jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: "var(--color-text-text-white)", children: "Managed Agents 1 Min = 100 Credits" })] }));
|
|
47
|
+
export const Dark = {
|
|
48
|
+
args: {
|
|
49
|
+
variant: PopoverVariant.Dark,
|
|
50
|
+
placement: 'top',
|
|
51
|
+
content: _jsx(RichContent, {}),
|
|
52
|
+
children: _jsx(Trigger, {}),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
export const Light = {
|
|
56
|
+
args: {
|
|
57
|
+
variant: PopoverVariant.Light,
|
|
58
|
+
placement: 'right',
|
|
59
|
+
content: (_jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.Regular, color: "var(--color-text-text-title)", children: "A light popover surface." })),
|
|
60
|
+
children: _jsx(Trigger, {}),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -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, overriddenText = null, currentValue = 40, maxValue = 100, fillColor = 'var(--color-background-bg-brand-primary)', backgroundColor = 'var(--color-background-bg-component)', text = 'used', textColor = 'var(--color-text-text-title)', style, textStyle, testId, }) => {
|
|
5
|
+
export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, overriddenText = null, currentValue = 40, maxValue = 100, fillColor = 'var(--color-background-bg-brand-primary)', backgroundColor = 'var(--color-background-bg-component)', minWidth = 200, animated = false, text = 'used', textColor = 'var(--color-text-text-title)', style, textStyle, testId, }) => {
|
|
6
6
|
let errorText = '';
|
|
7
7
|
const calculateFill = () => {
|
|
8
8
|
if (currentValue > maxValue)
|
|
@@ -29,7 +29,11 @@ export const ProgressIndicator = ({ mode = ProgressIndicatorMode.Value, overridd
|
|
|
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:
|
|
33
|
-
`${currentValue.toLocaleString(undefined, { maximumFractionDigits: 2 })} / ${maxValue.toLocaleString(undefined, { maximumFractionDigits: 2 })} ${text}` })), _jsx(Box, { display: "flex", flexGrow: 1, flexDirection: "row", alignItems: "center", borderRadius: '
|
|
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: minWidth, "data-testid": testId, children: [mode === ProgressIndicatorMode.Value && (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor, textStyle: textStyle, children: overriddenText ||
|
|
33
|
+
`${currentValue.toLocaleString(undefined, { maximumFractionDigits: 2 })} / ${maxValue.toLocaleString(undefined, { maximumFractionDigits: 2 })} ${text}` })), _jsx(Box, { display: "flex", flexGrow: 1, flexDirection: "row", alignItems: "center", borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-xs)', sx: { backgroundColor, overflow: 'hidden' }, height: '4px', width: '100%', children: _jsx(Box, { height: '100%', borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-xs)', sx: {
|
|
34
|
+
backgroundColor: fillColor,
|
|
35
|
+
width: `${calculateFill()}%`,
|
|
36
|
+
transition: animated ? 'width 0.3s ease-in-out' : undefined,
|
|
37
|
+
} }) }), mode === ProgressIndicatorMode.Percentage && (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: textColor, textStyle: textStyle, children: overriddenText ||
|
|
34
38
|
`${currentValue.toLocaleString(undefined, { maximumFractionDigits: 2 })}%` }))] }));
|
|
35
39
|
};
|
|
@@ -6,5 +6,6 @@ type Story = StoryObj<typeof ProgressIndicator>;
|
|
|
6
6
|
export declare const Default: Story;
|
|
7
7
|
export declare const ValueWithOverriddenText: Story;
|
|
8
8
|
export declare const Percentage: Story;
|
|
9
|
+
export declare const BarOnly: Story;
|
|
9
10
|
export declare const PercentageWithOverriddenText: Story;
|
|
10
11
|
export declare const Custom: Story;
|
|
@@ -75,6 +75,15 @@ export const Percentage = {
|
|
|
75
75
|
maxValue: 100,
|
|
76
76
|
},
|
|
77
77
|
};
|
|
78
|
+
export const BarOnly = {
|
|
79
|
+
args: {
|
|
80
|
+
mode: ProgressIndicatorMode.Bar,
|
|
81
|
+
currentValue: 500,
|
|
82
|
+
maxValue: 2000,
|
|
83
|
+
minWidth: 0,
|
|
84
|
+
style: { width: '206px' },
|
|
85
|
+
},
|
|
86
|
+
};
|
|
78
87
|
export const PercentageWithOverriddenText = {
|
|
79
88
|
args: {
|
|
80
89
|
mode: ProgressIndicatorMode.Percentage,
|
package/dist/stories/UI/index.js
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
|
-
import { Theme, SxProps } from '@mui/material';
|
|
1
|
+
import { Theme, SxProps, TooltipProps } from '@mui/material';
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
3
|
import { IconName } from '../../utils';
|
|
3
4
|
import { ButtonSize, ButtonHierarchy } from '../Buttons';
|
|
5
|
+
/**
|
|
6
|
+
* Colour scheme for the {@link Popover}.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum PopoverVariant {
|
|
9
|
+
Dark = "Dark",
|
|
10
|
+
Light = "Light"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Props for the {@link Popover} component — a hover/focus-triggered floating
|
|
14
|
+
* panel that anchors to a trigger element and renders arbitrary content.
|
|
15
|
+
*/
|
|
16
|
+
export interface PopoverProps {
|
|
17
|
+
/** Floating content shown inside the popover. */
|
|
18
|
+
content: ReactNode;
|
|
19
|
+
/** The trigger element the popover anchors to (must forward a ref). */
|
|
20
|
+
children: ReactElement;
|
|
21
|
+
/** Colour scheme. Defaults to `Dark`. */
|
|
22
|
+
variant?: PopoverVariant;
|
|
23
|
+
/** Placement relative to the trigger. Defaults to `top`. */
|
|
24
|
+
placement?: TooltipProps['placement'];
|
|
25
|
+
/** How the popover opens. `hover` (default) or `click` (menu-style). */
|
|
26
|
+
trigger?: 'hover' | 'click';
|
|
27
|
+
/** Show the arrow pointer. Defaults to `true`. */
|
|
28
|
+
arrow?: boolean;
|
|
29
|
+
/** Max width of the popover in pixels. Defaults to `280`. */
|
|
30
|
+
maxWidth?: number;
|
|
31
|
+
/** Padding of the popover surface. Defaults to the `spacing-lg` token. */
|
|
32
|
+
padding?: string;
|
|
33
|
+
/** Controlled open state. Omit for uncontrolled hover/focus behaviour. */
|
|
34
|
+
open?: boolean;
|
|
35
|
+
/** Called with the next open state (controlled usage). */
|
|
36
|
+
onOpenChange?: (open: boolean) => void;
|
|
37
|
+
/**
|
|
38
|
+
* When true the popover closes as soon as the pointer leaves the trigger.
|
|
39
|
+
* Leave false (default) so users can move into interactive content.
|
|
40
|
+
*/
|
|
41
|
+
disableInteractive?: boolean;
|
|
42
|
+
/** Applied to the popover surface. */
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
4
45
|
/**
|
|
5
46
|
* Badge size variants
|
|
6
47
|
*/
|
|
@@ -216,7 +257,9 @@ export interface CheckIconProps {
|
|
|
216
257
|
*/
|
|
217
258
|
export declare enum ProgressIndicatorMode {
|
|
218
259
|
Value = "Value",
|
|
219
|
-
Percentage = "Percentage"
|
|
260
|
+
Percentage = "Percentage",
|
|
261
|
+
/** Renders only the bar, with no accompanying value text. */
|
|
262
|
+
Bar = "Bar"
|
|
220
263
|
}
|
|
221
264
|
/**
|
|
222
265
|
* Progress indicator component props
|
|
@@ -232,6 +275,10 @@ export type ProgressIndicatorProps = {
|
|
|
232
275
|
fillColor?: string;
|
|
233
276
|
/** Background color of the progress indicator */
|
|
234
277
|
backgroundColor?: string;
|
|
278
|
+
/** Minimum width of the indicator in px. Defaults to `200`. */
|
|
279
|
+
minWidth?: number;
|
|
280
|
+
/** Animate the fill width when the value changes. Defaults to `false`. */
|
|
281
|
+
animated?: boolean;
|
|
235
282
|
/** Text of the progress indicator */
|
|
236
283
|
text?: string;
|
|
237
284
|
/** Overridden text of the progress indicator */
|
package/dist/stories/UI/types.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Colour scheme for the {@link Popover}.
|
|
3
|
+
*/
|
|
4
|
+
export var PopoverVariant;
|
|
5
|
+
(function (PopoverVariant) {
|
|
6
|
+
PopoverVariant["Dark"] = "Dark";
|
|
7
|
+
PopoverVariant["Light"] = "Light";
|
|
8
|
+
})(PopoverVariant || (PopoverVariant = {}));
|
|
1
9
|
/**
|
|
2
10
|
* Badge size variants
|
|
3
11
|
*/
|
|
@@ -98,6 +106,8 @@ export var ProgressIndicatorMode;
|
|
|
98
106
|
(function (ProgressIndicatorMode) {
|
|
99
107
|
ProgressIndicatorMode["Value"] = "Value";
|
|
100
108
|
ProgressIndicatorMode["Percentage"] = "Percentage";
|
|
109
|
+
/** Renders only the bar, with no accompanying value text. */
|
|
110
|
+
ProgressIndicatorMode["Bar"] = "Bar";
|
|
101
111
|
})(ProgressIndicatorMode || (ProgressIndicatorMode = {}));
|
|
102
112
|
/**
|
|
103
113
|
* FeatureBanner media variants
|