Feature / Add working notifications with only twitter for now (#102)

* Add working notifications with only twitter for now

* feat(notification-bar): I didnt copy from NP

* Make default browser visibility true

* feat(notifications): Collapse when no more notifications after closing one
This commit is contained in:
J Francisco Rader authored and GitHub committed 2021-02-18 19:21:07 -05:00
1 parent 11af8bfb5a
commit 40ec19a349
19 files changed
+497 -153

No files matched your search

+17 -5
View File
@@ -2,7 +2,7 @@ import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Avatar from '@material-ui/core/Avatar';
import { green } from '@material-ui/core/colors';
import { Button } from '@material-ui/core';
import { Badge, Button } from '@material-ui/core';
interface IStyles {
root: any;
@@ -28,7 +28,13 @@ const useStyles = makeStyles(
})
);
export const AppIcon = ({ id, name, icon, backgroundColor, color }) => {
export const AppIcon = ({
name,
icon,
backgroundColor,
color,
notification,
}) => {
const classes = useStyles({
backgroundColor: backgroundColor || green[50],
color: color || green[400],
@@ -36,9 +42,15 @@ export const AppIcon = ({ id, name, icon, backgroundColor, color }) => {
return (
<Button className={classes.root}>
<Avatar className={classes.avatar}>
{icon || name[0].toUpperCase()}
</Avatar>
<Badge
color="error"
badgeContent={notification?.badge}
invisible={!notification || notification.badge < 2}
>
<Avatar className={classes.avatar}>
{icon || name[0].toUpperCase()}
</Avatar>
</Badge>
</Button>
);
};
@@ -1,33 +0,0 @@
import React, { createContext, useState, useEffect, useRef } from 'react';
export const SnackbarContext = createContext(null);
function SnackbarProvider({ children }) {
const [alert, setAlert] = useState(null);
const timer = useRef(null);
useEffect(() => {
if (alert) {
clearTimeout(timer.current)
timer.current = setTimeout(() => {
setAlert(null)
}, 1000);
}
return () => clearTimeout(timer.current)
}, [alert]);
const addAlert = (value) => setAlert(value);
const value = { addAlert, alert }
return (
<SnackbarContext.Provider value={value}>
<>
{children}
</>
</SnackbarContext.Provider>
)
}
export default SnackbarProvider;