1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/ui/components/component-library/button/button.js
Hakeemullah J. Yousufzai 1f0c0d041c
Update Button prop name type to variant (#18774)
* Update Button prop name type to variant

* fix: lint errors on running test cases

* change remaining files

* change typo: BUTTON_VARIANTS to BUTTON_VARIANT

* fix: button.test.js lint errors

* update: button instances & import in remaing files

* fix: prettier warnings

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-04-26 11:17:25 -05:00

35 lines
1.0 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { ButtonPrimary } from '../button-primary';
import { ButtonSecondary } from '../button-secondary';
import { ButtonLink } from '../button-link';
import { BUTTON_VARIANT } from './button.constants';
export const Button = ({ variant, ...props }) => {
switch (variant) {
case BUTTON_VARIANT.PRIMARY:
return <ButtonPrimary {...props} />;
case BUTTON_VARIANT.SECONDARY:
return <ButtonSecondary {...props} />;
case BUTTON_VARIANT.LINK:
return <ButtonLink {...props} />;
default:
return <ButtonPrimary {...props} />;
}
};
Button.propTypes = {
/**
* 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`
*/
variant: PropTypes.oneOf(Object.values(BUTTON_VARIANT)),
/**
* Button accepts all the props from ButtonPrimary (same props as ButtonSecondary & ButtonLink)
*/
...ButtonPrimary.propTypes,
};