2023-08-15 00:13:15 +02:00
|
|
|
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 = '',
|
2023-08-15 18:38:36 +02:00
|
|
|
danger = false,
|
|
|
|
disabled = false,
|
2023-08-15 00:13:15 +02:00
|
|
|
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', {
|
2023-08-15 18:38:36 +02:00
|
|
|
'mm-button-secondary--type-danger': danger,
|
|
|
|
'mm-button-secondary--disabled': disabled,
|
2023-08-15 00:13:15 +02:00
|
|
|
})}
|
|
|
|
size={size}
|
|
|
|
ref={ref}
|
|
|
|
{...{ disabled, ...(props as ButtonBaseProps<C>) }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|