@beydesign/storybook 0.6.0 → 0.6.1
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/Navigation/Drawer/DrawerCreditsCard.js +25 -6
- package/dist/stories/Navigation/Drawer/DrawerCreditsCard.stories.d.ts +2 -0
- package/dist/stories/Navigation/Drawer/DrawerCreditsCard.stories.js +10 -0
- package/dist/stories/Navigation/Drawer/types.d.ts +5 -0
- package/package.json +1 -1
|
@@ -57,10 +57,15 @@ const UpgradeLink = styled.button `
|
|
|
57
57
|
color: var(--color-text-text-title);
|
|
58
58
|
transition: color 0.2s ease-in-out;
|
|
59
59
|
|
|
60
|
-
&:hover {
|
|
60
|
+
&:hover:not(:disabled) {
|
|
61
61
|
color: var(--color-text-text-clicable);
|
|
62
62
|
text-decoration: underline;
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
&:disabled {
|
|
66
|
+
color: var(--color-text-text-inactive);
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
}
|
|
64
69
|
`;
|
|
65
70
|
const InfoButton = styled.button `
|
|
66
71
|
appearance: none;
|
|
@@ -97,10 +102,12 @@ const CollapsedBox = styled.span `
|
|
|
97
102
|
justify-content: center;
|
|
98
103
|
width: 36px;
|
|
99
104
|
height: 36px;
|
|
100
|
-
color:
|
|
105
|
+
color: ${({ $disabled }) => $disabled
|
|
106
|
+
? 'var(--color-foreground-fg-disabled)'
|
|
107
|
+
: 'var(--color-foreground-fg-brand-primary)'};
|
|
101
108
|
background-color: var(--color-background-bg-brand-transparent);
|
|
102
109
|
border-radius: var(--spacing-tokens-size-in-px-spacing-spacing-md, 8px);
|
|
103
|
-
cursor: pointer;
|
|
110
|
+
cursor: ${({ $disabled }) => ($disabled ? 'not-allowed' : 'pointer')};
|
|
104
111
|
`;
|
|
105
112
|
/** Dark popover body shown when hovering the collapsed credits box. */
|
|
106
113
|
const PopoverBody = styled.div `
|
|
@@ -120,6 +127,14 @@ const PopoverButton = styled.button `
|
|
|
120
127
|
background-color: var(--color-background-bg-brand-primary);
|
|
121
128
|
color: var(--color-text-text-on-accent-color);
|
|
122
129
|
box-shadow: ${SHADOW_XS};
|
|
130
|
+
|
|
131
|
+
&:disabled {
|
|
132
|
+
border-color: var(--color-background-bg-button-disabled);
|
|
133
|
+
background-color: var(--color-background-bg-button-disabled);
|
|
134
|
+
color: var(--color-text-text-inactive);
|
|
135
|
+
box-shadow: none;
|
|
136
|
+
cursor: not-allowed;
|
|
137
|
+
}
|
|
123
138
|
`;
|
|
124
139
|
const PopoverGroup = styled.div `
|
|
125
140
|
display: flex;
|
|
@@ -133,11 +148,15 @@ const InfoLines = ({ lines }) => (_jsx("div", { style: { display: 'flex', flexDi
|
|
|
133
148
|
* conversion rates. When collapsed it shrinks to the gem glyph and reveals the
|
|
134
149
|
* full details (and an upgrade action) in a hover popover. Fully theme-aware.
|
|
135
150
|
*/
|
|
136
|
-
export const DrawerCreditsCard = ({ size = DrawerSize.Expanded, usedCredits = 0, maxCredits = 0, upgradeLabel = 'Upgrade Plan', creditsCaption, icon, infoLines = DEFAULT_INFO_LINES, onUpgradeClick, className, style, testId, }) => {
|
|
151
|
+
export const DrawerCreditsCard = ({ size = DrawerSize.Expanded, usedCredits = 0, maxCredits = 0, upgradeLabel = 'Upgrade Plan', creditsCaption, icon, infoLines = DEFAULT_INFO_LINES, onUpgradeClick, disabled = false, className, style, testId, }) => {
|
|
152
|
+
const handleUpgradeClick = () => {
|
|
153
|
+
if (!disabled)
|
|
154
|
+
onUpgradeClick?.();
|
|
155
|
+
};
|
|
137
156
|
const caption = creditsCaption ?? `${usedCredits} credits used of ${maxCredits}`;
|
|
138
157
|
const glyph = icon ? (getIconComponent(icon, { size: 20 })) : (_jsx(GemIcon, { size: 20 }));
|
|
139
158
|
if (size === DrawerSize.Collapsed) {
|
|
140
|
-
return (_jsx(Popover, { placement: "right", content: _jsxs(PopoverBody, { children: [_jsx(PopoverButton, { type: "button", onClick:
|
|
159
|
+
return (_jsx(Popover, { placement: "right", content: _jsxs(PopoverBody, { children: [_jsx(PopoverButton, { type: "button", onClick: handleUpgradeClick, disabled: disabled, children: _jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: "inherit", children: upgradeLabel }) }), _jsxs(PopoverGroup, { children: [_jsx(CreditsBar, { used: usedCredits, max: maxCredits }), _jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: "var(--color-text-text-white)", children: caption })] }), _jsx(InfoLines, { lines: infoLines })] }), children: _jsx(CollapsedBox, { "$disabled": disabled, className: className, style: style, "data-testid": testId, onClick: handleUpgradeClick, children: glyph }) }));
|
|
141
160
|
}
|
|
142
|
-
return (_jsxs(Card, { className: className, style: style, "data-testid": testId, children: [_jsxs(HeaderRow, { children: [_jsxs(HeaderLeft, { children: [_jsx(GemBox, { children: glyph }), _jsx(UpgradeLink, { type: "button", onClick:
|
|
161
|
+
return (_jsxs(Card, { className: className, style: style, "data-testid": testId, children: [_jsxs(HeaderRow, { children: [_jsxs(HeaderLeft, { children: [_jsx(GemBox, { children: glyph }), _jsx(UpgradeLink, { type: "button", onClick: handleUpgradeClick, disabled: disabled, children: _jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: "inherit", children: upgradeLabel }) })] }), _jsx(Popover, { placement: "top", content: _jsx(InfoLines, { lines: infoLines }), children: _jsx(InfoButton, { type: "button", "aria-label": "Credit rate information", children: getIconComponent('WarningCircle', { size: 20 }) }) })] }), _jsx(CreditsBar, { used: usedCredits, max: maxCredits }), _jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: "var(--color-text-text-label)", children: caption })] }));
|
|
143
162
|
};
|
|
@@ -21,6 +21,10 @@ const meta = {
|
|
|
21
21
|
usedCredits: { control: 'number' },
|
|
22
22
|
maxCredits: { control: 'number' },
|
|
23
23
|
upgradeLabel: { control: 'text' },
|
|
24
|
+
disabled: {
|
|
25
|
+
control: 'boolean',
|
|
26
|
+
table: { defaultValue: { summary: 'false' } },
|
|
27
|
+
},
|
|
24
28
|
},
|
|
25
29
|
args: {
|
|
26
30
|
size: DrawerSize.Expanded,
|
|
@@ -43,3 +47,9 @@ export const NearLimit = {
|
|
|
43
47
|
export const Collapsed = {
|
|
44
48
|
args: { size: DrawerSize.Collapsed },
|
|
45
49
|
};
|
|
50
|
+
export const Disabled = {
|
|
51
|
+
args: { disabled: true },
|
|
52
|
+
};
|
|
53
|
+
export const CollapsedDisabled = {
|
|
54
|
+
args: { size: DrawerSize.Collapsed, disabled: true },
|
|
55
|
+
};
|
|
@@ -60,6 +60,11 @@ export interface DrawerCreditsCardProps {
|
|
|
60
60
|
infoLines?: string[];
|
|
61
61
|
/** Fired when the title or upgrade button is clicked. */
|
|
62
62
|
onUpgradeClick?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Disables the upgrade action — the title link, and when collapsed both the
|
|
65
|
+
* gem box and the popover button. The info tooltip stays available.
|
|
66
|
+
*/
|
|
67
|
+
disabled?: boolean;
|
|
63
68
|
className?: string;
|
|
64
69
|
style?: CSSProperties;
|
|
65
70
|
testId?: string;
|