Button.tsx 924 B

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