You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

QuickActionButton.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // @flow
  2. import { makeStyles } from '@material-ui/styles';
  3. import React from 'react';
  4. type Props = {
  5. /**
  6. * Label used for accessibility.
  7. */
  8. accessibilityLabel: string,
  9. /**
  10. * Additional class name for custom styles.
  11. */
  12. className: string,
  13. /**
  14. * Children of the component.
  15. */
  16. children: string | React$Node,
  17. /**
  18. * Click handler.
  19. */
  20. onClick: Function,
  21. /**
  22. * Data test id.
  23. */
  24. testId?: string
  25. }
  26. const useStyles = makeStyles(theme => {
  27. return {
  28. button: {
  29. backgroundColor: theme.palette.action01,
  30. color: theme.palette.text01,
  31. borderRadius: `${theme.shape.borderRadius}px`,
  32. ...theme.typography.labelBold,
  33. lineHeight: `${theme.typography.labelBold.lineHeight}px`,
  34. padding: '8px 12px',
  35. display: 'flex',
  36. justifyContent: 'center',
  37. alignItems: 'center',
  38. border: 0,
  39. '&:hover': {
  40. backgroundColor: theme.palette.action01Hover
  41. }
  42. }
  43. };
  44. });
  45. const QuickActionButton = ({ accessibilityLabel, className, children, onClick, testId }: Props) => {
  46. const styles = useStyles();
  47. return (<button
  48. aria-label = { accessibilityLabel }
  49. className = { `${styles.button} ${className}` }
  50. data-testid = { testId }
  51. onClick = { onClick }>
  52. {children}
  53. </button>);
  54. };
  55. export default QuickActionButton;