feat(SnackbarProvider): interface update | wrap around phone

This commit is contained in:
Christopher committed 2021-02-09 19:19:36 +01:00
1 parent babce2f568
commit c38fe9ef66
3 files changed
+39 -15

No files matched your search

+25 -4
View File
@@ -1,12 +1,25 @@
import React, { createContext, useState, useEffect, useMemo, useCallback } from 'react';
import { SnackBar } from './SnackBar';
import Alert from './Alert';
import { makeStyles } from '@material-ui/core/styles';
import { Snackbar } from '@material-ui/core';
const useStyles = makeStyles(() => ({
alert: {
position: 'absolute',
bottom: '15%',
right: '25%',
margin: '0 auto',
textAlign: 'center'
}
}))
export const SnackbarContext = createContext(null);
const AUTO_HIDE = 2000;
const AUTO_HIDE = 1500;
function SnackbarProvider({ children }) {
const [alerts, setAlerts] = useState([]);
const classes = useStyles();
const alertIdx = alerts.join(',');
@@ -21,8 +34,16 @@ function SnackbarProvider({ children }) {
return (
<SnackbarContext.Provider value={value}>
{children}
{alerts.map((alert) => <SnackBar key={alert}>{alert}</SnackBar>)}
<>
{children}
{alerts.map((alert) => (
<div className={classes.alert}>
<Alert auto key={alert} severity="success" variant="filled">
{alert}
</Alert>
</div>
))}
</>
</SnackbarContext.Provider>
)
}