Skip to content

Commit

Permalink
feat(file uploader): button override (uber#1137)
Browse files Browse the repository at this point in the history
* feat(button override): first attempt (#1045)

* feat(button override): second attempt (#1045)

* Changes requested in review 1

* Changes requested in review 2
  • Loading branch information
IgorWilbert authored and chasestarr committed Apr 15, 2019
1 parent 7faabac commit 61a00d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/file-uploader/file-uploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ function FileUploader(props: PropsT) {
overrides.HiddenInput,
StyledHiddenInput,
);
const [ButtonComponent, buttonProps] = getOverrides(
overrides.ButtonComponent,
Button,
);

const afterFileDrop = !!(
props.progressAmount ||
Expand Down Expand Up @@ -106,7 +110,7 @@ function FileUploader(props: PropsT) {
{locale.fileuploader.or}
</ContentMessage>

<Button
<ButtonComponent
aria-controls="fileupload"
disabled={props.disabled}
kind={KIND.minimal}
Expand All @@ -118,9 +122,10 @@ function FileUploader(props: PropsT) {
}}
role="button"
{...prefixedStyledProps}
{...buttonProps}
>
{locale.fileuploader.browseFiles}
</Button>
</ButtonComponent>
</React.Fragment>
)}

Expand Down Expand Up @@ -167,7 +172,7 @@ function FileUploader(props: PropsT) {
</ContentMessage>
)}
{props.errorMessage ? (
<Button
<ButtonComponent
kind={KIND.minimal}
onClick={() => {
props.onRetry && props.onRetry();
Expand All @@ -179,9 +184,9 @@ function FileUploader(props: PropsT) {
}}
>
{locale.fileuploader.retry}
</Button>
</ButtonComponent>
) : (
<Button
<ButtonComponent
kind={KIND.minimal}
onClick={() => {
props.onCancel && props.onCancel();
Expand All @@ -193,7 +198,7 @@ function FileUploader(props: PropsT) {
}}
>
{locale.fileuploader.cancel}
</Button>
</ButtonComponent>
)}
</React.Fragment>
)}
Expand Down
1 change: 1 addition & 0 deletions src/file-uploader/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type OverridesT<T> = {|
HiddenInput?: OverrideT<T>,
ProgressMessage?: OverrideT<T>,
ErrorMessage?: OverrideT<T>,
ButtonComponent?: OverrideT<T>,
|};

export type PropsT = {|
Expand Down

0 comments on commit 61a00d4

Please sign in to comment.