mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Adding correct types so ButtonBase and all button variants ButtonPrimary, ButtonSecondary, ButtonLink and Button accept Text props (#20647)
This commit is contained in:
parent
6a17d76efc
commit
e2789cbe82
@ -1,10 +1,7 @@
|
||||
import { ReactNode } from 'react';
|
||||
import type {
|
||||
StyleUtilityProps,
|
||||
PolymorphicComponentPropWithRef,
|
||||
} from '../box';
|
||||
import type { PolymorphicComponentPropWithRef } from '../box';
|
||||
import { IconColor } from '../../../helpers/constants/design-system';
|
||||
import { TextDirection, TextProps } from '../text';
|
||||
import { TextDirection, TextProps, TextStyleUtilityProps } from '../text';
|
||||
import { IconName } from '../icon';
|
||||
import type { IconProps } from '../icon';
|
||||
|
||||
@ -15,7 +12,9 @@ export enum ButtonBaseSize {
|
||||
}
|
||||
|
||||
export type ValidButtonTagType = 'button' | 'a';
|
||||
export interface ButtonBaseStyleUtilityProps extends StyleUtilityProps {
|
||||
|
||||
export interface ButtonBaseStyleUtilityProps
|
||||
extends Omit<TextStyleUtilityProps, 'as' | 'children' | 'ellipsis'> {
|
||||
/**
|
||||
* The polymorphic `as` prop allows you to change the root HTML element of the Button component between `button` and `a` tag
|
||||
*
|
||||
|
@ -13,7 +13,7 @@ import { ButtonLinkSize, ButtonLinkComponent } from './button-link.types';
|
||||
export const ButtonLink: ButtonLinkComponent = React.forwardRef(
|
||||
<C extends React.ElementType = 'button' | 'a'>(
|
||||
{
|
||||
className,
|
||||
className = '',
|
||||
color,
|
||||
danger = false,
|
||||
disabled = false,
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
export const ButtonPrimary: ButtonPrimaryComponent = React.forwardRef(
|
||||
<C extends React.ElementType = 'button' | 'a'>(
|
||||
{
|
||||
className,
|
||||
className = '',
|
||||
danger = false,
|
||||
disabled = false,
|
||||
size = ButtonPrimarySize.Md,
|
||||
|
@ -23,15 +23,15 @@ type ButtonPropsByVariant = {
|
||||
[ButtonVariant.Primary]: {
|
||||
variant?: ButtonVariant.Primary;
|
||||
size?: ValidButtonSize; // Allows for only ButtonSize.Sm, ButtonSize.Md, ButtonSize.Lg
|
||||
} & Omit<ButtonPrimaryStyleUtilityProps, 'size'>;
|
||||
} & Omit<ButtonPrimaryStyleUtilityProps, 'size' | 'variant'>;
|
||||
[ButtonVariant.Secondary]: {
|
||||
variant?: ButtonVariant.Secondary;
|
||||
size?: ValidButtonSize; // Allows for only ButtonSize.Sm, ButtonSize.Md, ButtonSize.Lg
|
||||
} & Omit<ButtonSecondaryStyleUtilityProps, 'size'>;
|
||||
} & Omit<ButtonSecondaryStyleUtilityProps, 'size' | 'variant'>;
|
||||
[ButtonVariant.Link]: {
|
||||
variant?: ButtonVariant.Link;
|
||||
size?: ButtonSize;
|
||||
} & Omit<ButtonLinkStyleUtilityProps, 'size'>;
|
||||
} & Omit<ButtonLinkStyleUtilityProps, 'size' | 'variant'>;
|
||||
};
|
||||
|
||||
type ButtonPropsMap = {
|
||||
|
Loading…
Reference in New Issue
Block a user