mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
66292330fe
* button to TS migration working demo style props broken mapping - need switch working types file working types fix dependent imports of Button variant mapping working types fix lint fix test fix ButtonSize issue on QuizContent box fix test if this works fix button being used on QuizContent fix button_variant import readme fix * fix button import * fix primary button as anchor hover * deprecated * button to TS migration fix lint fix test * fix rebase issue * fix rebase issue * lint fix
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import type { PolymorphicRef } from '../box';
|
|
import { ButtonPrimary } from '../button-primary';
|
|
import { ButtonSecondary } from '../button-secondary';
|
|
import { ButtonLink } from '../button-link';
|
|
import type { ButtonPrimaryProps } from '../button-primary/button-primary.types';
|
|
import type { ButtonSecondaryProps } from '../button-secondary/button-secondary.types';
|
|
import type { ButtonLinkProps } from '../button-link/button-link.types';
|
|
import type { ButtonProps, ButtonComponent } from './button.types';
|
|
|
|
import { ButtonVariant } from './button.types';
|
|
|
|
export const Button: ButtonComponent = React.forwardRef(
|
|
<C extends React.ElementType = 'button' | 'a'>(
|
|
{ variant, ...props }: ButtonProps<C>,
|
|
ref?: PolymorphicRef<C>,
|
|
) => {
|
|
switch (variant) {
|
|
case ButtonVariant.Primary:
|
|
return (
|
|
<ButtonPrimary ref={ref} {...(props as ButtonPrimaryProps<C>)} />
|
|
);
|
|
case ButtonVariant.Secondary:
|
|
return (
|
|
<ButtonSecondary ref={ref} {...(props as ButtonSecondaryProps<C>)} />
|
|
);
|
|
case ButtonVariant.Link:
|
|
return <ButtonLink ref={ref} {...(props as ButtonLinkProps<C>)} />;
|
|
default:
|
|
return (
|
|
<ButtonPrimary ref={ref} {...(props as ButtonPrimaryProps<C>)} />
|
|
);
|
|
}
|
|
},
|
|
);
|