Skip to content

Commit

Permalink
Clean up props
Browse files Browse the repository at this point in the history
- This will fix our props tables and inferred `defaultProps` logic
  • Loading branch information
cee-chen committed Oct 18, 2023
1 parent e7c29fd commit b7dc9b4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 63 deletions.
26 changes: 9 additions & 17 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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> = (props) => {
const {
className,
buttonRef,
color: _color = 'primary',
fill,
...rest
} = props;

export const EuiButton: FunctionComponent<Props> = ({
className,
buttonRef,
size = 'm',
color: _color = 'primary',
fill,
...rest
}) => {
const buttonIsDisabled = isButtonDisabled({
href: rest.href,
isDisabled: rest.isDisabled || rest.disabled,
Expand All @@ -113,15 +112,8 @@ export const EuiButton: FunctionComponent<Props> = (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',
};
48 changes: 22 additions & 26 deletions src/components/button/button_empty/button_empty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,32 +87,28 @@ export type EuiButtonEmptyProps = ExclusiveUnion<
EuiButtonEmptyPropsForButton
>;

export const EuiButtonEmpty: FunctionComponent<EuiButtonEmptyProps> = (
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<EuiButtonEmptyProps> = ({
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,
Expand Down
38 changes: 18 additions & 20 deletions src/components/button/button_icon/button_icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,24 @@ type Props = ExclusiveUnion<
EuiButtonIconPropsForButton
>;

export const EuiButtonIcon: FunctionComponent<Props> = (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<Props> = ({
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,
Expand Down

0 comments on commit b7dc9b4

Please sign in to comment.