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.

ClickableIcon.tsx 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { Theme } from '@mui/material';
  2. import React from 'react';
  3. import { makeStyles } from 'tss-react/mui';
  4. import { isMobileBrowser } from '../../../environment/utils';
  5. import Icon from '../../../icons/components/Icon';
  6. interface IProps {
  7. accessibilityLabel: string;
  8. icon: Function;
  9. onClick: () => void;
  10. }
  11. const useStyles = makeStyles()((theme: 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. '&:active': {
  23. backgroundColor: theme.palette.ui03
  24. },
  25. '&.is-mobile': {
  26. padding: '10px'
  27. }
  28. }
  29. };
  30. });
  31. const ClickableIcon = ({ accessibilityLabel, icon, onClick }: IProps) => {
  32. const { classes: styles, cx } = useStyles();
  33. const isMobile = isMobileBrowser();
  34. return (
  35. <button
  36. aria-label = { accessibilityLabel }
  37. className = { cx(styles.button, isMobile && 'is-mobile') }
  38. onClick = { onClick }>
  39. <Icon
  40. size = { 24 }
  41. src = { icon } />
  42. </button>
  43. );
  44. };
  45. export default ClickableIcon;