From b7dc9b4e896c552bec6c0c6b53103643ad9bbe6d Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Wed, 18 Oct 2023 13:49:43 -0700 Subject: [PATCH] Clean up props - This will fix our props tables and inferred `defaultProps` logic --- src/components/button/button.tsx | 26 ++++------ .../button/button_empty/button_empty.tsx | 48 +++++++++---------- .../button/button_icon/button_icon.tsx | 38 +++++++-------- 3 files changed, 49 insertions(+), 63 deletions(-) diff --git a/src/components/button/button.tsx b/src/components/button/button.tsx index d200b219b1a..5071bc67711 100644 --- a/src/components/button/button.tsx +++ b/src/components/button/button.tsx @@ -82,15 +82,14 @@ export type Props = ExclusiveUnion< * EuiButton is largely responsible for providing relevant props * and the logic for element-specific attributes */ -export const EuiButton: FunctionComponent = (props) => { - const { - className, - buttonRef, - color: _color = 'primary', - fill, - ...rest - } = props; - +export const EuiButton: FunctionComponent = ({ + className, + buttonRef, + size = 'm', + color: _color = 'primary', + fill, + ...rest +}) => { const buttonIsDisabled = isButtonDisabled({ href: rest.href, isDisabled: rest.isDisabled || rest.disabled, @@ -113,15 +112,8 @@ export const EuiButton: FunctionComponent = (props) => { className={classes} css={cssStyles} ref={buttonRef} + size={size} {...rest} /> ); }; - -EuiButton.displayName = 'EuiButton'; - -// Use defaultProps for simple pass-through props -EuiButton.defaultProps = { - size: 'm', - color: 'primary', -}; diff --git a/src/components/button/button_empty/button_empty.tsx b/src/components/button/button_empty/button_empty.tsx index 56bd8f6a5b9..a92a8cd133e 100644 --- a/src/components/button/button_empty/button_empty.tsx +++ b/src/components/button/button_empty/button_empty.tsx @@ -87,32 +87,28 @@ export type EuiButtonEmptyProps = ExclusiveUnion< EuiButtonEmptyPropsForButton >; -export const EuiButtonEmpty: FunctionComponent = ( - props -) => { - const { - children, - className, - iconType, - iconSide = 'left', - iconSize = 'm', - color: _color = 'primary', - size = 'm', - flush, - isDisabled: _isDisabled, - disabled, - isLoading, - href, - target, - rel, - type = 'button', - buttonRef, - contentProps, - textProps, - isSelected, - ...rest - } = props; - +export const EuiButtonEmpty: FunctionComponent = ({ + children, + className, + iconType, + iconSide = 'left', + iconSize = 'm', + color: _color = 'primary', + size = 'm', + flush, + isDisabled: _isDisabled, + disabled, + isLoading, + href, + target, + rel, + type = 'button', + buttonRef, + contentProps, + textProps, + isSelected, + ...rest +}) => { const isDisabled = isButtonDisabled({ isDisabled: _isDisabled || disabled, href, diff --git a/src/components/button/button_icon/button_icon.tsx b/src/components/button/button_icon/button_icon.tsx index 990d3f91606..43ba817ea03 100644 --- a/src/components/button/button_icon/button_icon.tsx +++ b/src/components/button/button_icon/button_icon.tsx @@ -100,26 +100,24 @@ type Props = ExclusiveUnion< EuiButtonIconPropsForButton >; -export const EuiButtonIcon: FunctionComponent = (props) => { - const { - className, - iconType, - iconSize = 'm', - color: _color = 'primary', - isDisabled: _isDisabled, - disabled, - href, - type = 'button', - display = 'empty', - target, - rel, - size = 'xs', - buttonRef, - isSelected, - isLoading, - ...rest - } = props; - +export const EuiButtonIcon: FunctionComponent = ({ + className, + iconType, + iconSize = 'm', + color: _color = 'primary', + isDisabled: _isDisabled, + disabled, + href, + type = 'button', + display = 'empty', + target, + rel, + size = 'xs', + buttonRef, + isSelected, + isLoading, + ...rest +}) => { const euiThemeContext = useEuiTheme(); const isDisabled = isButtonDisabled({ isDisabled: _isDisabled || disabled,