jiti-meet/react/features/base/ui/components/web/ClickableIcon.tsx

55 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-09-13 07:36:00 +00:00
import { Theme } from '@mui/material';
import React from 'react';
2022-09-13 07:36:00 +00:00
import { makeStyles } from 'tss-react/mui';
import { isMobileBrowser } from '../../../environment/utils';
import Icon from '../../../icons/components/Icon';
interface IProps {
accessibilityLabel: string;
icon: Function;
onClick: () => void;
}
2022-09-13 07:36:00 +00:00
const useStyles = makeStyles()((theme: Theme) => {
return {
button: {
padding: '2px',
backgroundColor: theme.palette.action03,
border: 0,
outline: 0,
borderRadius: `${theme.shape.borderRadius}px`,
'&:hover': {
backgroundColor: theme.palette.ui02
},
'&:active': {
backgroundColor: theme.palette.ui03
},
'&.is-mobile': {
padding: '10px'
}
}
};
});
const ClickableIcon = ({ accessibilityLabel, icon, onClick }: IProps) => {
2022-09-13 07:36:00 +00:00
const { classes: styles, cx } = useStyles();
const isMobile = isMobileBrowser();
2022-09-13 07:36:00 +00:00
return (
<button
aria-label = { accessibilityLabel }
className = { cx(styles.button, isMobile && 'is-mobile') }
onClick = { onClick }>
<Icon
size = { 24 }
src = { icon } />
</button>
);
};
export default ClickableIcon;