Files
new-phone-who-dis/phone/src/ui/components/AppIcon.tsx
T
J Francisco RaderandChristopher 41674968ab Notification alert stays on if it is an incoming call and phone is closed (#115)
* Phone now shows all the time slide a bit if incoming call exists | can close alerts!

* Improve animation

* Improve call controls

* Make alerts not overflow | Call modal is navigable out :)

* Open modal when accepting call

* Cant navigate back from homepage

* Avoid call route if no call active + rename things

* Impprove main apps icons sizes

* hover effect to app icons :)

* Revert interface change

* fix(phone/dialer): resolve not calling when adding contacts

Co-authored-by: Christopher <[email protected]>
2021-02-26 21:45:01 -05:00

69 lines
1.7 KiB
TypeScript

import React from 'react';
import { fade, makeStyles, Theme } from '@material-ui/core/styles';
import Avatar from '@material-ui/core/Avatar';
import { green } from '@material-ui/core/colors';
import { Badge, Button, Tooltip, Zoom } from '@material-ui/core';
import { useTranslation } from 'react-i18next';
const useStyles = makeStyles<Theme, { color: string; backgroundColor: string }>(
(theme) => ({
root: {
padding: 0,
marginTop: theme.spacing(3),
},
avatar: {
'&:hover': {
backgroundColor: ({ backgroundColor }) => fade(backgroundColor, 0.6),
},
backgroundColor: ({ backgroundColor }) => backgroundColor,
color: ({ color }) => color,
boxShadow: theme.shadows[2],
width: theme.spacing(8),
height: theme.spacing(8),
fontSize: theme.typography.h4.fontSize,
},
tooltip: {
fontSize: 12,
},
})
);
export const AppIcon = ({
id,
nameLocale,
name,
icon,
backgroundColor,
color,
notification,
}) => {
const { t } = useTranslation();
const classes = useStyles({
backgroundColor: backgroundColor || green[50],
color: color || green[400],
});
return (
<Tooltip
arrow
key={id}
title={t(nameLocale)}
placement='top'
classes={{ tooltip: classes.tooltip }}
TransitionComponent={Zoom}
>
<Button className={classes.root}>
<Badge
color='error'
badgeContent={notification?.badge}
invisible={!notification || notification.badge < 2}
>
<Avatar className={classes.avatar}>
{icon || name[0].toUpperCase()}
</Avatar>
</Badge>
</Button>
</Tooltip>
);
};