@beydesign/storybook 0.6.1 → 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
|
};
|
|
@@ -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
|
}
|