2022-10-14 00:39:22 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
|
|
|
import { ButtonBase } from '../button-base';
|
2023-01-26 19:32:11 +01:00
|
|
|
import { COLORS, TEXT, SIZES } from '../../../helpers/constants/design-system';
|
2022-10-14 00:39:22 +02:00
|
|
|
import { BUTTON_LINK_SIZES } from './button-link.constants';
|
|
|
|
|
|
|
|
export const ButtonLink = ({
|
|
|
|
className,
|
|
|
|
danger,
|
2023-01-26 19:32:11 +01:00
|
|
|
size = SIZES.AUTO,
|
2022-10-14 00:39:22 +02:00
|
|
|
...props
|
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<ButtonBase
|
|
|
|
className={classnames(className, 'mm-button-link', {
|
|
|
|
'mm-button-link--type-danger': danger,
|
2023-01-26 19:32:11 +01:00
|
|
|
'mm-button-link--size-inherit': size === BUTTON_LINK_SIZES.INHERIT,
|
|
|
|
'mm-button-link--size-auto': size === BUTTON_LINK_SIZES.AUTO,
|
2022-10-14 00:39:22 +02:00
|
|
|
})}
|
2023-01-26 19:32:11 +01:00
|
|
|
paddingLeft={0}
|
|
|
|
paddingRight={0}
|
|
|
|
size={size === BUTTON_LINK_SIZES.INHERIT ? null : size}
|
2022-11-18 21:36:33 +01:00
|
|
|
backgroundColor={COLORS.TRANSPARENT}
|
2023-01-26 19:32:11 +01:00
|
|
|
color={danger ? COLORS.ERROR_DEFAULT : COLORS.PRIMARY_DEFAULT}
|
|
|
|
borderRadius={null}
|
|
|
|
textProps={{
|
|
|
|
variant:
|
|
|
|
size === BUTTON_LINK_SIZES.INHERIT ? TEXT.INHERIT : TEXT.BODY_MD,
|
|
|
|
}}
|
|
|
|
iconProps={{
|
|
|
|
size: size === BUTTON_LINK_SIZES.INHERIT ? SIZES.INHERIT : SIZES.SM,
|
|
|
|
}}
|
|
|
|
iconLoadingProps={{
|
|
|
|
size: size === BUTTON_LINK_SIZES.INHERIT ? SIZES.INHERIT : SIZES.MD,
|
|
|
|
}}
|
2023-01-30 19:33:08 +01:00
|
|
|
{...props}
|
2022-10-14 00:39:22 +02:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ButtonLink.propTypes = {
|
|
|
|
/**
|
|
|
|
* An additional className to apply to the ButtonLink.
|
|
|
|
*/
|
|
|
|
className: PropTypes.string,
|
|
|
|
/**
|
|
|
|
* Boolean to change button type to Danger when true
|
|
|
|
*/
|
|
|
|
danger: PropTypes.bool,
|
2023-01-13 22:58:09 +01:00
|
|
|
/**
|
2023-01-26 19:32:11 +01:00
|
|
|
* Possible size values: 'SIZES.AUTO'(auto), 'SIZES.SM'(32px), 'SIZES.MD'(40px), 'SIZES.LG'(48px), 'SIZES.INHERIT'(inherits parents font-size)
|
|
|
|
* Default value is 'SIZES.AUTO'.
|
2022-10-14 00:39:22 +02:00
|
|
|
*/
|
|
|
|
size: PropTypes.oneOf(Object.values(BUTTON_LINK_SIZES)),
|
|
|
|
/**
|
|
|
|
* ButtonLink accepts all the props from ButtonBase
|
|
|
|
*/
|
|
|
|
...ButtonBase.propTypes,
|
|
|
|
};
|