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-02-02 21:15:26 +01:00
|
|
|
import {
|
|
|
|
BackgroundColor,
|
|
|
|
Color,
|
|
|
|
Size,
|
|
|
|
} 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-03-22 03:19:49 +01:00
|
|
|
disabled,
|
2023-02-02 21:15:26 +01:00
|
|
|
size = Size.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-03-22 03:19:49 +01:00
|
|
|
'mm-button-link--disabled': disabled,
|
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}
|
2023-02-02 21:15:26 +01:00
|
|
|
backgroundColor={BackgroundColor.transparent}
|
|
|
|
color={danger ? Color.errorDefault : Color.primaryDefault}
|
2023-01-26 19:32:11 +01:00
|
|
|
borderRadius={null}
|
2023-02-22 18:42:06 +01:00
|
|
|
startIconProps={{
|
|
|
|
size: size === BUTTON_LINK_SIZES.INHERIT ? Size.inherit : Size.SM,
|
|
|
|
}}
|
|
|
|
endIconProps={{
|
2023-02-02 21:15:26 +01:00
|
|
|
size: size === BUTTON_LINK_SIZES.INHERIT ? Size.inherit : Size.SM,
|
2023-01-26 19:32:11 +01:00
|
|
|
}}
|
|
|
|
iconLoadingProps={{
|
2023-02-02 21:15:26 +01:00
|
|
|
size: size === BUTTON_LINK_SIZES.INHERIT ? Size.inherit : Size.MD,
|
2023-01-26 19:32:11 +01:00
|
|
|
}}
|
2023-03-22 03:19:49 +01:00
|
|
|
{...{ disabled, ...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-03-22 03:19:49 +01:00
|
|
|
/**
|
|
|
|
* Boolean to disable button
|
|
|
|
*/
|
|
|
|
disabled: 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,
|
|
|
|
};
|