您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ClickableIcon.tsx 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. '&: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, 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. onClick = { onClick }>
  43. <Icon
  44. size = { 24 }
  45. src = { icon } />
  46. </button>
  47. );
  48. };
  49. export default ClickableIcon;