Skip to content

Commit

Permalink
feat(FileUploader): FileUploader size prop update (#8462)
Browse files Browse the repository at this point in the history
* feat(Button): start size work on Button

* feat(Button): finish size prop update

* feat(Button): revert xl, 2xl changes

* feat(Button): add xl, 2xl updates behind feature flag

* feat(FileUploader): update size prop

* chore(storybook): remove old story

* test(snapshot): update snapshot tests

* test(snapshot): remove snapshot from different pr

* chore(tests): update snapshots

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
tw15egan and kodiakhq[bot] authored May 13, 2021
1 parent f151656 commit 36087e5
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@
}
}

.#{$prefix}--file__selected-file--field {
// V11: Remove --field
.#{$prefix}--file__selected-file--field,
.#{$prefix}--file__selected-file--md {
min-height: rem(40px);
gap: $carbon--spacing-03 $carbon--spacing-05;
}
Expand Down Expand Up @@ -192,7 +194,9 @@
padding: $carbon--spacing-02 0;
}

.#{$prefix}--file__selected-file--invalid.#{$prefix}--file__selected-file--field {
// V11: Remove --field
.#{$prefix}--file__selected-file--invalid.#{$prefix}--file__selected-file--field,
.#{$prefix}--file__selected-file--invalid.#{$prefix}--file__selected-file--md {
padding: $carbon--spacing-03 0;
}

Expand All @@ -206,7 +210,10 @@
padding-top: rem(7px);
}

// V11: Remove --field
.#{$prefix}--file__selected-file--invalid.#{$prefix}--file__selected-file--field
.#{$prefix}--form-requirement,
.#{$prefix}--file__selected-file--invalid.#{$prefix}--file__selected-file--md
.#{$prefix}--form-requirement {
padding-top: rem(11px);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,9 @@ Map {
"default",
"field",
"small",
"sm",
"md",
"lg",
],
],
"type": "oneOf",
Expand Down Expand Up @@ -2731,6 +2734,9 @@ Map {
"default",
"field",
"small",
"sm",
"md",
"lg",
],
],
"type": "oneOf",
Expand Down Expand Up @@ -2788,6 +2794,9 @@ Map {
"default",
"field",
"small",
"sm",
"md",
"lg",
],
],
"type": "oneOf",
Expand Down Expand Up @@ -2827,6 +2836,9 @@ Map {
"default",
"field",
"small",
"sm",
"md",
"lg",
],
],
"type": "oneOf",
Expand Down
11 changes: 8 additions & 3 deletions packages/react/src/components/FileUploader/FileUploader-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ const buttonKinds = {
'Danger Primary (danger--primary)': 'danger--primary',
'Tertiary (tertiary)': 'tertiary',
};

const sizes = {
Default: 'default',
Field: 'field',
Small: 'small',
'Compat check - Field': 'field',
'Compat check - Small': 'small',
'Compat check - default': 'default',
'Small (sm)': 'sm',
'Medium (md)': 'md',
'Large (lg) - Default': 'lg',
};

const filenameStatuses = {
'Edit (edit)': 'edit',
'Complete (complete)': 'complete',
Expand Down
7 changes: 4 additions & 3 deletions packages/react/src/components/FileUploader/FileUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ export default class FileUploader extends React.Component {
/**
* Specify the size of the FileUploaderButton, from a list of available
* sizes. For `default` buttons, this prop can remain unspecified.
* V11: `default`, `field`, and `small` will be removed
*/
size: PropTypes.oneOf(['default', 'field', 'small']),
size: PropTypes.oneOf(['default', 'field', 'small', 'sm', 'md', 'lg']),
};

static defaultProps = {
Expand Down Expand Up @@ -179,8 +180,8 @@ export default class FileUploader extends React.Component {
});

const selectedFileClasses = classNames(`${prefix}--file__selected-file`, {
[`${prefix}--file__selected-file--field`]: size === 'field',
[`${prefix}--file__selected-file--sm`]: size === 'small',
[`${prefix}--file__selected-file--md`]: size === 'field' || size === 'md',
[`${prefix}--file__selected-file--sm`]: size === 'small' || size === 'sm',
});

return (
Expand Down
12 changes: 7 additions & 5 deletions packages/react/src/components/FileUploader/FileUploaderButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ function FileUploaderButton({
const classes = cx(`${prefix}--btn`, className, {
[`${prefix}--btn--${buttonKind}`]: buttonKind,
[`${prefix}--btn--disabled`]: disabled,
[`${prefix}--btn--field`]: size === 'field',
[`${prefix}--btn--sm`]: size === 'small',
// V11: remove field, small
[`${prefix}--btn--md`]: size === 'field' || size === 'md',
[`${prefix}--btn--sm`]: size === 'small' || size === 'sm',
});

// Adjust label text state based on changes to the labelText prop
Expand Down Expand Up @@ -174,10 +175,11 @@ FileUploaderButton.propTypes = {
role: PropTypes.string,

/**
* Specify the size of the button, from a list of available sizes.
* For `default` buttons, this prop can remain unspecified.
* Specify the size of the FileUploaderButton, from a list of available
* sizes. For `default` buttons, this prop can remain unspecified.
* V11: `default`, `field`, and `small` will be removed
*/
size: PropTypes.oneOf(['default', 'field', 'small']),
size: PropTypes.oneOf(['default', 'field', 'small', 'sm', 'md', 'lg']),

/**
* Provide a custom tabIndex value for the <FileUploaderButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ FileUploaderDropContainer.propTypes = {

/**
* Specify the size of the uploaded items, from a list of available
* sizes. For `default` size, this prop can remain unspecified.
* sizes. For `default` buttons, this prop can remain unspecified.
* V11: `default`, `field`, and `small` will be removed
*/
size: PropTypes.oneOf(['default', 'field', 'small']),
size: PropTypes.oneOf(['default', 'field', 'small', 'sm', 'md', 'lg']),

/**
* Provide a custom tabIndex value for the <FileUploaderButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function FileUploaderItem({
const { current: id } = useRef(uuid || uid());
const classes = cx(`${prefix}--file__selected-file`, {
[`${prefix}--file__selected-file--invalid`]: invalid,
[`${prefix}--file__selected-file--field`]: size === 'field',
[`${prefix}--file__selected-file--sm`]: size === 'small',
[`${prefix}--file__selected-file--md`]: size === 'field' || size === 'md',
[`${prefix}--file__selected-file--sm`]: size === 'small' || size === 'sm',
});
return (
<span className={classes} {...other}>
Expand Down Expand Up @@ -107,9 +107,10 @@ FileUploaderItem.propTypes = {

/**
* Specify the size of the uploaded items, from a list of available
* sizes. For `default` size, this prop can remain unspecified.
* sizes. For `default` buttons, this prop can remain unspecified.
* V11: `default`, `field`, and `small` will be removed
*/
size: PropTypes.oneOf(['default', 'field', 'small']),
size: PropTypes.oneOf(['default', 'field', 'small', 'sm', 'md', 'lg']),

/**
* Status of the file upload
Expand Down

0 comments on commit 36087e5

Please sign in to comment.