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
Garrett Bear a28d727caf
Feat/16290/add button component (#16305)
* add button component

* add all button props

* update tests

* add button type prop

* fix base button size const

* add href prop to button base

* Update ui/components/component-library/button/README.mdx

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/button/README.mdx

Co-authored-by: George Marshall <george.marshall@consensys.net>

* update tests

* Update ui/components/component-library/button-primary/button-primary.js

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/button/README.mdx

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/button/button.stories.js

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/button/button.js

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/component-library/button/button.stories.js

Co-authored-by: George Marshall <george.marshall@consensys.net>

* update button props on readme

* linting issue fix

Co-authored-by: George Marshall <george.marshall@consensys.net>
2022-11-09 13:55:13 -08: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_TYPES } from './button.constants';
export const Button = ({ type, ...props }) => {
switch (type) {
case BUTTON_TYPES.PRIMARY:
return <ButtonPrimary {...props} />;
case BUTTON_TYPES.SECONDARY:
return <ButtonSecondary {...props} />;
case BUTTON_TYPES.LINK:
return <ButtonLink {...props} />;
default:
return <ButtonPrimary {...props} />;
}
};
Button.propTypes = {
/**
* Select the type of Button.
* Possible values could be 'BUTTON_TYPES.PRIMARY', 'BUTTON_TYPES.SECONDARY', 'BUTTON_TYPES.LINK'
* Button will default to `BUTTON_TYPES.PRIMARY`
*/
type: PropTypes.oneOf(Object.values(BUTTON_TYPES)),
/**
* Button accepts all the props from ButtonPrimary (same props as ButtonSecondary & ButtonLink)
*/
...ButtonPrimary.propTypes,
};