2022-10-06 06:51:02 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
|
|
|
import { ButtonBase } from '../button-base';
|
2023-02-02 21:15:26 +01:00
|
|
|
import {
|
|
|
|
BackgroundColor,
|
|
|
|
TextColor,
|
|
|
|
} from '../../../helpers/constants/design-system';
|
2022-10-06 06:51:02 +02:00
|
|
|
import { BUTTON_PRIMARY_SIZES } from './button-primary.constants';
|
|
|
|
|
|
|
|
export const ButtonPrimary = ({
|
|
|
|
className,
|
|
|
|
danger,
|
2023-01-13 22:58:09 +01:00
|
|
|
disabled,
|
2022-10-06 06:51:02 +02:00
|
|
|
size = BUTTON_PRIMARY_SIZES.MD,
|
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<ButtonBase
|
2023-02-02 21:15:26 +01:00
|
|
|
backgroundColor={
|
|
|
|
danger ? BackgroundColor.errorDefault : BackgroundColor.primaryDefault
|
|
|
|
}
|
|
|
|
color={danger ? TextColor.errorInverse : TextColor.primaryInverse}
|
2022-10-06 06:51:02 +02:00
|
|
|
className={classnames(className, 'mm-button-primary', {
|
|
|
|
'mm-button-primary--type-danger': danger,
|
2023-01-13 22:58:09 +01:00
|
|
|
'mm-button-primary--disabled': disabled,
|
2022-10-06 06:51:02 +02:00
|
|
|
})}
|
|
|
|
size={size}
|
2023-01-13 22:58:09 +01:00
|
|
|
{...{ disabled, ...props }}
|
2022-10-06 06:51:02 +02:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonPrimary.propTypes = {
|
|
|
|
/**
|
|
|
|
* An additional className to apply to the ButtonPrimary.
|
|
|
|
*/
|
|
|
|
className: PropTypes.string,
|
|
|
|
/**
|
2022-11-09 22:55:13 +01:00
|
|
|
* When true, `ButtonPrimary` color becomes Danger.
|
2022-10-06 06:51:02 +02:00
|
|
|
*/
|
|
|
|
danger: PropTypes.bool,
|
2023-01-13 22:58:09 +01:00
|
|
|
/**
|
|
|
|
* Boolean to disable button
|
|
|
|
*/
|
|
|
|
disabled: PropTypes.bool,
|
2022-10-06 06:51:02 +02:00
|
|
|
/**
|
2022-11-14 22:41:03 +01:00
|
|
|
* Possible size values: 'SIZES.SM'(32px), 'SIZES.MD'(40px), 'SIZES.LG'(48px).
|
2022-10-06 06:51:02 +02:00
|
|
|
* Default value is 'SIZES.MD'.
|
|
|
|
*/
|
|
|
|
size: PropTypes.oneOf(Object.values(BUTTON_PRIMARY_SIZES)),
|
|
|
|
/**
|
|
|
|
* ButtonPrimary accepts all the props from ButtonBase
|
|
|
|
*/
|
|
|
|
...ButtonBase.propTypes,
|
|
|
|
};
|