@beydesign/storybook 0.6.0 → 0.6.2

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.
@@ -44,7 +44,7 @@ const fileIconMap = {
44
44
  };
45
45
  // Default icon for unknown file types
46
46
  const defaultIcon = FileCode;
47
- export const FileUpload = ({ disabled, sx, acceptedFileTypes = '.pdf,.doc,.docx,.txt', maxFileSizeMB = 10, onFileSelect, }) => {
47
+ export const FileUpload = ({ disabled, sx, acceptedFileTypes = '.pdf,.doc,.docx,.txt', maxFileSizeMB = 10, onFileSelect, hintText, showFileTypeIcons = true, }) => {
48
48
  const [isDragging, setIsDragging] = useState(false);
49
49
  const fileInputRef = useRef(null);
50
50
  // Function to get the icons to display based on acceptedFileTypes
@@ -134,5 +134,7 @@ export const FileUpload = ({ disabled, sx, acceptedFileTypes = '.pdf,.doc,.docx,
134
134
  ? 'var(--color-text-text-inactive)'
135
135
  : 'var(--color-text-text-clicable)', textStyle: { cursor: disabled ? 'not-allowed' : 'pointer' }, children: "Click to upload" }), _jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.Regular, color: disabled
136
136
  ? 'var(--color-text-text-disabled)'
137
- : 'var(--color-text-text-paragraph)', children: "or drag and drop" }), _jsxs(Box, { display: 'flex', flexDirection: 'row', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [fileIcons.map((Icon, index) => (_jsx(Icon, { ...iconProps }, index))), fileIcons.length === 0 && _jsx(FileCode, { ...iconProps })] })] })] }));
137
+ : 'var(--color-text-text-paragraph)', children: "or drag and drop" }), showFileTypeIcons && (_jsxs(Box, { display: 'flex', flexDirection: 'row', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', children: [fileIcons.map((Icon, index) => (_jsx(Icon, { ...iconProps }, index))), fileIcons.length === 0 && _jsx(FileCode, { ...iconProps })] }))] }), hintText && (_jsx(Typography, { size: TypographySize.TextXS, weight: TypographyWeight.Regular, color: disabled
138
+ ? 'var(--color-text-text-disabled)'
139
+ : 'var(--color-text-text-paragraph)', children: hintText }))] }));
138
140
  };
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof FileUpload>;
6
6
  export declare const Default: Story;
7
7
  export declare const Disabled: Story;
8
+ export declare const WithHintText: Story;
@@ -31,6 +31,19 @@ const meta = {
31
31
  description: 'Callback function when a file is selected',
32
32
  table: { type: { summary: 'function' } },
33
33
  },
34
+ hintText: {
35
+ control: 'text',
36
+ description: 'Supporting line rendered under the label',
37
+ table: { type: { summary: 'string' } },
38
+ },
39
+ showFileTypeIcons: {
40
+ control: 'boolean',
41
+ description: 'Whether to render the per-extension file icons',
42
+ table: {
43
+ type: { summary: 'boolean' },
44
+ defaultValue: { summary: 'true' },
45
+ },
46
+ },
34
47
  sx: {
35
48
  control: 'object',
36
49
  description: 'Style of the file upload',
@@ -49,3 +62,12 @@ export const Disabled = {
49
62
  disabled: true,
50
63
  },
51
64
  };
65
+ export const WithHintText = {
66
+ args: {
67
+ acceptedFileTypes: '.mp4,.mov',
68
+ maxFileSizeMB: 500,
69
+ hintText: 'MP4 or MOV, up to 500MB',
70
+ showFileTypeIcons: false,
71
+ sx: { width: '537px', aspectRatio: '537 / 293' },
72
+ },
73
+ };
@@ -150,6 +150,16 @@ export interface FileUploadProps {
150
150
  maxFileSizeMB?: number;
151
151
  /** Callback function when a file is selected */
152
152
  onFileSelect?: (file: File) => void;
153
+ /**
154
+ * Supporting line rendered under the label, e.g. "MP4 or MOV, up to 500MB".
155
+ * Figma centres it inside the drop area as part of the label cluster.
156
+ */
157
+ hintText?: string;
158
+ /**
159
+ * Whether to render the per-extension file icons beside the label.
160
+ * Defaults to true; turn it off when `hintText` states the formats instead.
161
+ */
162
+ showFileTypeIcons?: boolean;
153
163
  /** Style of the file upload */
154
164
  sx?: SxProps<Theme>;
155
165
  }
@@ -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: var(--color-foreground-fg-brand-primary);
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: () => onUpgradeClick?.(), children: _jsx(Typography, { size: TypographySize.TextS, weight: TypographyWeight.SemiBold, color: "var(--color-text-text-on-accent-color)", 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, { className: className, style: style, "data-testid": testId, onClick: () => onUpgradeClick?.(), children: glyph }) }));
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: () => onUpgradeClick?.(), 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 })] }));
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
  };
@@ -6,3 +6,5 @@ type Story = StoryObj<typeof DrawerCreditsCard>;
6
6
  export declare const Default: Story;
7
7
  export declare const NearLimit: Story;
8
8
  export declare const Collapsed: Story;
9
+ export declare const Disabled: Story;
10
+ export declare const CollapsedDisabled: Story;
@@ -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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.6.0",
4
+ "version": "0.6.2",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",