From 05e7d65b85b9a0da7ddbd627cb4cd32cb6e1a9b0 Mon Sep 17 00:00:00 2001 From: Tanner Summers Date: Tue, 1 Feb 2022 17:30:10 -0600 Subject: [PATCH 1/3] feat(react): added disabled prop to file uploader --- .../FileUploader/FileUploader-story.js | 1 + .../components/FileUploader/FileUploader.js | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/react/src/components/FileUploader/FileUploader-story.js b/packages/react/src/components/FileUploader/FileUploader-story.js index 3e9622b675e6..4ad08f671440 100644 --- a/packages/react/src/components/FileUploader/FileUploader-story.js +++ b/packages/react/src/components/FileUploader/FileUploader-story.js @@ -87,6 +87,7 @@ const props = { ), buttonLabel: text('The button label (buttonLabel)', 'Add file'), buttonKind: buttonKind || 'primary', + disabled: boolean('Disabled (disabled)', false), size: select('Button size (size)', sizes, 'default'), filenameStatus: select( 'Status for file name (filenameStatus)', diff --git a/packages/react/src/components/FileUploader/FileUploader.js b/packages/react/src/components/FileUploader/FileUploader.js index 019e3414fc35..67638fa67f2b 100644 --- a/packages/react/src/components/FileUploader/FileUploader.js +++ b/packages/react/src/components/FileUploader/FileUploader.js @@ -38,6 +38,11 @@ export default class FileUploader extends React.Component { */ className: PropTypes.string, + /** + * Specify whether file input is disabled + */ + disabled: PropTypes.bool, + /** * Specify the status of the File Upload */ @@ -100,6 +105,7 @@ export default class FileUploader extends React.Component { static contextType = PrefixContext; static defaultProps = { + disabled: false, iconDescription: FeatureFlags.enabled('enable-v11-release') ? undefined : 'Provide icon description', @@ -167,6 +173,7 @@ export default class FileUploader extends React.Component { iconDescription, buttonLabel, buttonKind, + disabled, filenameStatus, labelDescription, labelTitle, @@ -186,6 +193,11 @@ export default class FileUploader extends React.Component { [className]: className, }); + const getHelperLabelClasses = (baseClass) => + classNames(baseClass, { + [`${prefix}--label-description--disabled`]: disabled, + }); + const selectedFileClasses = classNames(`${prefix}--file__selected-file`, { [`${prefix}--file__selected-file--md`]: size === 'field' || size === 'md', [`${prefix}--file__selected-file--sm`]: size === 'small' || size === 'sm', @@ -194,10 +206,15 @@ export default class FileUploader extends React.Component { return (
{FeatureFlags.enabled('enable-v11-release') && !labelTitle ? null : ( -

{labelTitle}

+

+ {labelTitle} +

)} -

{labelDescription}

+

+ {labelDescription} +

Date: Tue, 1 Feb 2022 20:16:14 -0600 Subject: [PATCH 2/3] test(react): updated FileUploader snapshot --- packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap index 7155a54aee3f..f06bda059594 100644 --- a/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap +++ b/packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap @@ -2587,6 +2587,7 @@ Map { "accept": Array [], "buttonKind": "primary", "buttonLabel": "", + "disabled": false, "filenameStatus": "uploading", "iconDescription": "Provide icon description", "multiple": false, @@ -2622,6 +2623,9 @@ Map { "className": Object { "type": "string", }, + "disabled": Object { + "type": "bool", + }, "filenameStatus": Object { "args": Array [ Array [ From f49058222f70071342ec5232bab74ba7ece1be00 Mon Sep 17 00:00:00 2001 From: Taylor Jones Date: Wed, 2 Feb 2022 16:59:08 -0600 Subject: [PATCH 3/3] chore(fileuploader): add disabled prop arg control to v11 storybook --- .../src/components/FileUploader/next/FileUploader.stories.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react/src/components/FileUploader/next/FileUploader.stories.js b/packages/react/src/components/FileUploader/next/FileUploader.stories.js index f0cfdd0d7147..f06128b9f2c0 100644 --- a/packages/react/src/components/FileUploader/next/FileUploader.stories.js +++ b/packages/react/src/components/FileUploader/next/FileUploader.stories.js @@ -56,6 +56,7 @@ _FileUploader.args = { accept: ['.jpg', '.png'], name: '', multiple: true, + disabled: false, iconDescription: 'Clear file', }; _FileUploader.argTypes = {