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

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