Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ClickableIcon.tsx 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import React from 'react';
  2. import { makeStyles } from 'tss-react/mui';
  3. import { isMobileBrowser } from '../../../environment/utils';
  4. import Icon from '../../../icons/components/Icon';
  5. interface IProps {
  6. accessibilityLabel: string;
  7. icon: Function;
  8. id?: string;
  9. onClick: () => void;
  10. }
  11. const useStyles = makeStyles()(theme => {
  12. return {
  13. button: {
  14. padding: '2px',
  15. backgroundColor: theme.palette.action03,
  16. border: 0,
  17. outline: 0,
  18. borderRadius: `${theme.shape.borderRadius}px`,
  19. '&:hover': {
  20. backgroundColor: theme.palette.ui02
  21. },
  22. '&:focus': {
  23. outline: 0,
  24. boxShadow: `0px 0px 0px 2px ${theme.palette.focus01}`
  25. },
  26. '&:active': {
  27. backgroundColor: theme.palette.ui03
  28. },
  29. '&.is-mobile': {
  30. padding: '10px'
  31. }
  32. }
  33. };
  34. });
  35. const ClickableIcon = ({ accessibilityLabel, icon, id, onClick }: IProps) => {
  36. const { classes: styles, cx } = useStyles();
  37. const isMobile = isMobileBrowser();
  38. return (
  39. <button
  40. aria-label = { accessibilityLabel }
  41. className = { cx(styles.button, isMobile && 'is-mobile') }
  42. id = { id }
  43. onClick = { onClick }>
  44. <Icon
  45. size = { 24 }
  46. src = { icon } />
  47. </button>
  48. );
  49. };
  50. export default ClickableIcon;