2022-11-09 22:55:13 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import { ButtonPrimary } from '../button-primary';
|
|
|
|
import { ButtonSecondary } from '../button-secondary';
|
|
|
|
import { ButtonLink } from '../button-link';
|
|
|
|
|
2023-04-26 18:17:25 +02:00
|
|
|
import { BUTTON_VARIANT } from './button.constants';
|
2022-11-09 22:55:13 +01:00
|
|
|
|
2023-04-26 18:17:25 +02:00
|
|
|
export const Button = ({ variant, ...props }) => {
|
|
|
|
switch (variant) {
|
|
|
|
case BUTTON_VARIANT.PRIMARY:
|
2022-11-09 22:55:13 +01:00
|
|
|
return <ButtonPrimary {...props} />;
|
2023-04-26 18:17:25 +02:00
|
|
|
case BUTTON_VARIANT.SECONDARY:
|
2022-11-09 22:55:13 +01:00
|
|
|
return <ButtonSecondary {...props} />;
|
2023-04-26 18:17:25 +02:00
|
|
|
case BUTTON_VARIANT.LINK:
|
2022-11-09 22:55:13 +01:00
|
|
|
return <ButtonLink {...props} />;
|
|
|
|
default:
|
|
|
|
return <ButtonPrimary {...props} />;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Button.propTypes = {
|
|
|
|
/**
|
2023-04-26 18:17:25 +02:00
|
|
|
* Select the variant of Button.
|
|
|
|
* Possible values could be 'BUTTON_VARIANT.PRIMARY', 'BUTTON_VARIANT.SECONDARY', 'BUTTON_VARIANT.LINK'
|
|
|
|
* Button will default to `BUTTON_VARIANT.PRIMARY`
|
2022-11-09 22:55:13 +01:00
|
|
|
*/
|
2023-04-26 18:17:25 +02:00
|
|
|
variant: PropTypes.oneOf(Object.values(BUTTON_VARIANT)),
|
2022-11-09 22:55:13 +01:00
|
|
|
/**
|
|
|
|
* Button accepts all the props from ButtonPrimary (same props as ButtonSecondary & ButtonLink)
|
|
|
|
*/
|
|
|
|
...ButtonPrimary.propTypes,
|
|
|
|
};
|