mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
7c2f7671b0
* ButtonSecondary to TS * updating components and addressing errors * lint and snapshot updates * using Boolean conversion for className * removing ValidButtonTag type * fix text color when link --------- Co-authored-by: garrettbear <gwhisten@gmail.com>
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import classnames from 'classnames';
|
|
|
|
import { ButtonBase, ButtonBaseProps } from '../button-base';
|
|
import { Color } from '../../../helpers/constants/design-system';
|
|
import { PolymorphicRef } from '../box';
|
|
import type { ButtonSecondaryProps } from './button-secondary.types';
|
|
import {
|
|
ButtonSecondarySize,
|
|
ButtonSecondaryComponent,
|
|
} from './button-secondary.types';
|
|
|
|
export const ButtonSecondary: ButtonSecondaryComponent = React.forwardRef(
|
|
<C extends React.ElementType = 'button' | 'a'>(
|
|
{
|
|
className = '',
|
|
danger,
|
|
disabled,
|
|
size = ButtonSecondarySize.Md,
|
|
...props
|
|
}: ButtonSecondaryProps<C>,
|
|
ref?: PolymorphicRef<C>,
|
|
) => {
|
|
const buttonColor = danger ? Color.errorDefault : Color.primaryDefault;
|
|
return (
|
|
<ButtonBase
|
|
backgroundColor={Color.transparent}
|
|
borderColor={buttonColor}
|
|
color={buttonColor}
|
|
className={classnames(className, 'mm-button-secondary', {
|
|
'mm-button-secondary--type-danger': Boolean(danger),
|
|
'mm-button-secondary--disabled': Boolean(disabled),
|
|
})}
|
|
size={size}
|
|
ref={ref}
|
|
{...{ disabled, ...(props as ButtonBaseProps<C>) }}
|
|
/>
|
|
);
|
|
},
|
|
);
|