Skip to content

Commit

Permalink
chore(button): size audit (#10532)
Browse files Browse the repository at this point in the history
* chore(button): size audit

* chore(button): removed required from kind

* chore(button): updated tests

* chore(button): flag on size

* chore(button): v11 flag for size

* chore(button): removed next story

* chore(button): removed code from a merge from main to fix the icon
  • Loading branch information
sstrubberg authored Feb 1, 2022
1 parent 580ea3e commit 2227e35
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 282 deletions.
12 changes: 0 additions & 12 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,6 @@ Map {
},
"Button" => Object {
"$$typeof": Symbol(react.forward_ref),
"defaultProps": Object {
"dangerDescription": "danger",
"disabled": false,
"isExpressive": false,
"kind": "primary",
"size": "default",
"tabIndex": 0,
"tooltipAlignment": "center",
"tooltipPosition": "top",
"type": "button",
},
"propTypes": Object {
"as": Object {
"args": Array [
Expand Down Expand Up @@ -248,7 +237,6 @@ Map {
"tertiary",
],
],
"isRequired": true,
"type": "oneOf",
},
"onBlur": Object {
Expand Down
75 changes: 32 additions & 43 deletions packages/react/src/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,34 @@ import { usePrefix } from '../../internal/usePrefix';
import { useId } from '../../internal/useId';
import toggleClass from '../../tools/toggleClass';
import { useFeatureFlag } from '../FeatureFlags';
import * as FeatureFlags from '@carbon/feature-flags';

const Button = React.forwardRef(function Button(
{
children,
as,
children,
className,
disabled,
small,
size,
kind,
dangerDescription = 'danger',
disabled = false,
hasIconOnly = false,
href,
isExpressive,
isSelected,
tabIndex,
type,
renderIcon: ButtonImageElement,
dangerDescription,
iconDescription,
hasIconOnly,
tooltipPosition,
tooltipAlignment,
onClick,
isExpressive = false,
isSelected,
kind = 'primary',
onBlur,
onClick,
onFocus,
onMouseEnter,
onMouseLeave,
...other
renderIcon: ButtonImageElement,
size = FeatureFlags.enabled('enable-v11-release') ? 'lg' : 'default',
small,
tabIndex = 0,
tooltipAlignment = 'center',
tooltipPosition = 'top',
type = 'button',
...rest
},
ref
) {
Expand Down Expand Up @@ -222,7 +223,7 @@ const Button = React.forwardRef(function Button(
onFocus: composeEventHandlers([onFocus, handleFocus]),
onBlur: composeEventHandlers([onBlur, handleBlur]),
onClick: composeEventHandlers([onClick, handleClick]),
...other,
...rest,
...commonProps,
...otherProps,
},
Expand Down Expand Up @@ -300,7 +301,7 @@ Button.propTypes = {
/**
* Specify the kind of Button you want to create
*/
kind: PropTypes.oneOf(ButtonKinds).isRequired,
kind: PropTypes.oneOf(ButtonKinds),

/**
* Provide an optional function to be called when the button element
Expand Down Expand Up @@ -344,20 +345,20 @@ Button.propTypes = {
role: PropTypes.string,

/**
* Specify the size of the button, from a list of available sizes.
* For `default` buttons, this prop can remain unspecified or use `default`.
* In the next major release of Carbon, `default`, `field`, and `small` will be removed
* Specify the size of the button, from the following list of sizes:
*/
size: PropTypes.oneOf([
'default',
'field',
'small',
'sm',
'md',
'lg',
'xl',
'2xl',
]),
size: FeatureFlags.enabled('enable-v11-release')
? PropTypes.oneOf(['sm', 'md', 'lg', 'xl', '2xl'])
: PropTypes.oneOf([
'default',
'field',
'small',
'sm',
'md',
'lg',
'xl',
'2xl',
]),

/**
* Deprecated in v10 in favor of `size`.
Expand Down Expand Up @@ -391,16 +392,4 @@ Button.propTypes = {
type: PropTypes.oneOf(['button', 'reset', 'submit']),
};

Button.defaultProps = {
tabIndex: 0,
type: 'button',
disabled: false,
kind: 'primary',
size: 'default',
dangerDescription: 'danger',
tooltipAlignment: 'center',
tooltipPosition: 'top',
isExpressive: false,
};

export default Button;
75 changes: 0 additions & 75 deletions packages/react/src/components/Button/next/Button.stories.js

This file was deleted.

Loading

0 comments on commit 2227e35

Please sign in to comment.