mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
feat(SnackbarProvider): interface update | wrap around phone
This commit is contained in:
1 parent
babce2f568
commit
c38fe9ef66
3 files changed
+39
-15
No files matched your search
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user