Skip to content

Commit 2a82aa4

Browse files
div-LeoLeonardo Di Vittorio
and
Leonardo Di Vittorio
authored
feat(file picker ):keep action button (#301)
* feat: add keeActionButton boolean * docs: add documentation for keepActionButton * fix: make keepActionButton optional * refactor: use alwaysShowActionButton --------- Co-authored-by: Leonardo Di Vittorio <[email protected]>
1 parent 617045d commit 2a82aa4

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/components/FilePicker/FilePicker.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ interface FilePickerProps extends MarginProps, ComponentPropsWithoutRef<'input'>
3535
* it works better when short
3636
*/
3737
buttonText: string;
38+
/**
39+
* Keep the action button displayed instead of showing the success state.
40+
*/
41+
alwaysShowActionButton?: boolean;
3842
/**
3943
* Whether or not the component should render an error state
4044
*/
@@ -134,6 +138,7 @@ const FilePicker: FC<FilePickerProps> = ({
134138
onFileChange = () => undefined,
135139
onChange = () => undefined,
136140
disabled = false,
141+
alwaysShowActionButton = false,
137142
...nonInputProps
138143
}: FilePickerProps) => {
139144
const inputEl = useRef<HTMLInputElement>(null);
@@ -190,7 +195,7 @@ const FilePicker: FC<FilePickerProps> = ({
190195
</Text>
191196
</Box>
192197
<Box display={{ _: 'none', medium: 'flex' }} alignItems="center" justifyContent="top">
193-
{validFileSelected ? (
198+
{!alwaysShowActionButton && validFileSelected ? (
194199
<CheckCircleOutlineIcon color={ICON_FILE_FEEDBACK_COLOR} />
195200
) : (
196201
<InputButton variant="secondary" type="button" tabIndex={-1} onClick={onClickHandler}>
@@ -201,7 +206,7 @@ const FilePicker: FC<FilePickerProps> = ({
201206
<Box display={{ _: 'flex', medium: 'none' }} alignItems="top">
202207
{validFileSelected ? <CheckCircleOutlineIcon color={ICON_FILE_FEEDBACK_COLOR} /> : <ShareIcon />}
203208
</Box>
204-
</Outliner>
209+
</Outliner>
205210
</Box>
206211
);
207212
};

src/components/FilePicker/docs/FilePicker.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ The example below will demostrate how to create compositions of `FilePicker`
6767
name="logo"
6868
onChange={(e) => console.log('onChange', e)}
6969
onFileChange={(file, e) => console.log('onFileChange', file, e)}
70+
alwaysShowActionButton
7071
mt={1}
7172
/>
7273
<FilePicker

src/components/FilePicker/docs/FilePickerPropsTable.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export const FilePickerPropsTable: FC = () => {
3030
description:
3131
'Text to display within component button, it describes the main action, it works better when short.'
3232
},
33+
{
34+
name: 'alwaysShowActionButton',
35+
type: 'boolean',
36+
description:
37+
'Keep the action button displayed instead of showing the success state.',
38+
defaultValue: 'false'
39+
},
3340
{
3441
name: 'error',
3542
type: 'boolean',

0 commit comments

Comments
 (0)