1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 06:07:06 +01:00
metamask-extension/ui/components/component-library/button-secondary/button-secondary.tsx

41 lines
1.2 KiB
TypeScript
Raw Normal View History

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>) }}
/>
);
},
);