No Description

Button.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import './button.css';
  4. /**
  5. * Primary UI component for user interaction
  6. */
  7. export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
  8. const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
  9. return (
  10. <button
  11. type="button"
  12. className={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
  13. style={backgroundColor && { backgroundColor }}
  14. {...props}
  15. >
  16. {label}
  17. </button>
  18. );
  19. };
  20. Button.propTypes = {
  21. /**
  22. * Is this the principal call to action on the page?
  23. */
  24. primary: PropTypes.bool,
  25. /**
  26. * What background color to use
  27. */
  28. backgroundColor: PropTypes.string,
  29. /**
  30. * How large should the button be?
  31. */
  32. size: PropTypes.oneOf(['small', 'medium', 'large']),
  33. /**
  34. * Button contents
  35. */
  36. label: PropTypes.string.isRequired,
  37. /**
  38. * Optional click handler
  39. */
  40. onClick: PropTypes.func,
  41. };
  42. Button.defaultProps = {
  43. backgroundColor: null,
  44. primary: false,
  45. size: 'medium',
  46. onClick: undefined,
  47. };