1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 09:57:02 +01:00

Updating props to optional and providing defaults (#20448)

This commit is contained in:
George Marshall 2023-08-15 09:38:36 -07:00 committed by GitHub
parent b0fcb12b99
commit 19de95dba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 21 deletions

View File

@ -15,10 +15,6 @@ The `ButtonLink` is an extension of `ButtonBase` to support link styles
<ArgsTable of={ButtonLink} /> <ArgsTable of={ButtonLink} />
The `ButtonLink` accepts all [ButtonBase](/docs/components-componentlibrary-buttonbase--default-story#props) component props
<ArgsTable of={ButtonBase} />
### Size ### Size
Use the `size` prop and the `ButtonLinkSize` enum from `./ui/components/component-library` to change the size of `ButtonLink`. Defaults to `ButtonLinkSize.Auto` Use the `size` prop and the `ButtonLinkSize` enum from `./ui/components/component-library` to change the size of `ButtonLink`. Defaults to `ButtonLinkSize.Auto`

View File

@ -15,9 +15,9 @@ export const ButtonLink: ButtonLinkComponent = React.forwardRef(
{ {
className, className,
color, color,
danger, danger = false,
disabled, disabled = false,
loading, loading = false,
size = ButtonLinkSize.Auto, size = ButtonLinkSize.Auto,
...props ...props
}: ButtonLinkProps<C>, }: ButtonLinkProps<C>,

View File

@ -16,20 +16,20 @@ export interface ButtonLinkStyleUtilityProps
/** /**
* Boolean to change button type to Danger when true * Boolean to change button type to Danger when true
*/ */
danger: boolean; danger?: boolean;
/** /**
* Boolean to disable button * Boolean to disable button
*/ */
disabled: boolean; disabled?: boolean;
/** /**
* Boolean to show loading spinner in button * Boolean to show loading spinner in button
*/ */
loading: boolean; loading?: boolean;
/** /**
* Possible size values: 'ButtonLinkSize.Auto'(auto), 'ButtonLinkSize.Sm'(32px), 'ButtonLinkSize.Md'(40px), 'ButtonLinkSize.Lg'(48px), 'ButtonLinkSize.Inherit'(inherits parents font-size) * Possible size values: 'ButtonLinkSize.Auto'(auto), 'ButtonLinkSize.Sm'(32px), 'ButtonLinkSize.Md'(40px), 'ButtonLinkSize.Lg'(48px), 'ButtonLinkSize.Inherit'(inherits parents font-size)
* Default value is 'ButtonLinkSize.Auto'. * Default value is 'ButtonLinkSize.Auto'.
*/ */
size: ButtonLinkSize; size?: ButtonLinkSize;
} }
export type ButtonLinkProps<C extends React.ElementType> = export type ButtonLinkProps<C extends React.ElementType> =

View File

@ -18,8 +18,8 @@ export const ButtonPrimary: ButtonPrimaryComponent = React.forwardRef(
<C extends React.ElementType = 'button' | 'a'>( <C extends React.ElementType = 'button' | 'a'>(
{ {
className, className,
danger, danger = false,
disabled, disabled = false,
size = ButtonPrimarySize.Md, size = ButtonPrimarySize.Md,
...props ...props
}: ButtonPrimaryProps<C>, }: ButtonPrimaryProps<C>,

View File

@ -13,21 +13,21 @@ export interface ButtonPrimaryStyleUtilityProps
/** /**
* Boolean to change button type to Danger when true * Boolean to change button type to Danger when true
*/ */
danger: boolean; danger?: boolean;
/** /**
* Boolean to disable button * Boolean to disable button
*/ */
disabled: boolean; disabled?: boolean;
/** /**
* Boolean to show loading spinner in button * Boolean to show loading spinner in button
*/ */
loading: boolean; loading?: boolean;
/** /**
* Possible size values: 'ButtonPrimarySize.Sm'(32px), * Possible size values: 'ButtonPrimarySize.Sm'(32px),
* 'ButtonPrimarySize.Md'(40px), 'ButtonPrimarySize.Lg'(48px) * 'ButtonPrimarySize.Md'(40px), 'ButtonPrimarySize.Lg'(48px)
* Default value is 'ButtonPrimarySize.Auto'. * Default value is 'ButtonPrimarySize.Auto'.
*/ */
size: ButtonPrimarySize; size?: ButtonPrimarySize;
} }
export type ButtonPrimaryProps<C extends React.ElementType> = export type ButtonPrimaryProps<C extends React.ElementType> =

View File

@ -14,8 +14,8 @@ export const ButtonSecondary: ButtonSecondaryComponent = React.forwardRef(
<C extends React.ElementType = 'button' | 'a'>( <C extends React.ElementType = 'button' | 'a'>(
{ {
className = '', className = '',
danger, danger = false,
disabled, disabled = false,
size = ButtonSecondarySize.Md, size = ButtonSecondarySize.Md,
...props ...props
}: ButtonSecondaryProps<C>, }: ButtonSecondaryProps<C>,
@ -28,8 +28,8 @@ export const ButtonSecondary: ButtonSecondaryComponent = React.forwardRef(
borderColor={buttonColor} borderColor={buttonColor}
color={buttonColor} color={buttonColor}
className={classnames(className, 'mm-button-secondary', { className={classnames(className, 'mm-button-secondary', {
'mm-button-secondary--type-danger': Boolean(danger), 'mm-button-secondary--type-danger': danger,
'mm-button-secondary--disabled': Boolean(disabled), 'mm-button-secondary--disabled': disabled,
})} })}
size={size} size={size}
ref={ref} ref={ref}