notifications changes
parent
702c108db0
commit
d931ef4db1
|
@ -90,7 +90,8 @@ export default function Notification({ variant, ...props }) {
|
||||||
<div className={classes.messageContainer}>
|
<div className={classes.messageContainer}>
|
||||||
<Typography
|
<Typography
|
||||||
className={classnames({
|
className={classnames({
|
||||||
[classes.containedTypography]: variant === "contained"
|
[classes.containedTypography]: variant === "contained",
|
||||||
|
[classes.roundedTypography]: variant === "rounded"
|
||||||
})}
|
})}
|
||||||
variant={props.typographyVariant}
|
variant={props.typographyVariant}
|
||||||
size={variant !== "contained" && !props.typographyVariant && "md"}
|
size={variant !== "contained" && !props.typographyVariant && "md"}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { makeStyles } from "@material-ui/styles";
|
import { makeStyles } from "@material-ui/styles";
|
||||||
|
|
||||||
export default makeStyles(theme => ({
|
export default makeStyles((theme) => ({
|
||||||
notificationContainer: {
|
notificationContainer: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center"
|
||||||
},
|
},
|
||||||
notificationContained: {
|
notificationContained: {
|
||||||
borderRadius: 45,
|
borderRadius: 45,
|
||||||
height: 45,
|
height: 45,
|
||||||
boxShadow: theme.customShadows.widgetDark,
|
boxShadow: theme.customShadows.widgetDark
|
||||||
},
|
},
|
||||||
notificationContainedShadowless: {
|
notificationContainedShadowless: {
|
||||||
boxShadow: "none",
|
boxShadow: "none"
|
||||||
},
|
},
|
||||||
notificationIconContainer: {
|
notificationIconContainer: {
|
||||||
minWidth: 45,
|
minWidth: 45,
|
||||||
|
@ -20,28 +20,31 @@ export default makeStyles(theme => ({
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
fontSize: 24,
|
fontSize: 24
|
||||||
},
|
},
|
||||||
notificationIconContainerContained: {
|
notificationIconContainerContained: {
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
color: "#FFFFFF80",
|
color: "#FFFFFF80"
|
||||||
},
|
},
|
||||||
notificationIconContainerRounded: {
|
notificationIconContainerRounded: {
|
||||||
marginRight: theme.spacing(2),
|
marginRight: theme.spacing(2)
|
||||||
},
|
},
|
||||||
containedTypography: {
|
containedTypography: {
|
||||||
color: "white",
|
color: "white"
|
||||||
|
},
|
||||||
|
roundedTypography: {
|
||||||
|
color: "#4A4A4A"
|
||||||
},
|
},
|
||||||
messageContainer: {
|
messageContainer: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
flexGrow: 1,
|
flexGrow: 1
|
||||||
},
|
},
|
||||||
extraButton: {
|
extraButton: {
|
||||||
color: "white",
|
color: "white",
|
||||||
"&:hover, &:focus": {
|
"&:hover, &:focus": {
|
||||||
background: "transparent",
|
background: "transparent"
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -33,7 +33,6 @@ export const toastDispatchActions = (dispatch) => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const ToastProvider = ({ children }) => {
|
const ToastProvider = ({ children }) => {
|
||||||
// var [errorToastId, setErrorToastId] = useState(null);
|
|
||||||
const [state, dispatch] = useReducer(toastReducer, toastInitialState);
|
const [state, dispatch] = useReducer(toastReducer, toastInitialState);
|
||||||
const dispatchActions = useMemo(() => toastDispatchActions(dispatch), [
|
const dispatchActions = useMemo(() => toastDispatchActions(dispatch), [
|
||||||
dispatch
|
dispatch
|
||||||
|
@ -56,8 +55,6 @@ const ToastProvider = ({ children }) => {
|
||||||
|
|
||||||
const notify = useCallback(
|
const notify = useCallback(
|
||||||
(message, type, extraButtonClick) => {
|
(message, type, extraButtonClick) => {
|
||||||
// if (errorToastId && type === "error") return;
|
|
||||||
|
|
||||||
let componentProps;
|
let componentProps;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -79,6 +76,22 @@ const ToastProvider = ({ children }) => {
|
||||||
extraButtonClick
|
extraButtonClick
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
case "defence":
|
||||||
|
componentProps = {
|
||||||
|
type: "defence",
|
||||||
|
message,
|
||||||
|
variant: "contained",
|
||||||
|
color: "info"
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case "disk":
|
||||||
|
componentProps = {
|
||||||
|
type: "disc",
|
||||||
|
message,
|
||||||
|
variant: "rounded",
|
||||||
|
color: "info"
|
||||||
|
};
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
componentProps = {
|
componentProps = {
|
||||||
type: "shipped",
|
type: "shipped",
|
||||||
|
@ -92,12 +105,9 @@ const ToastProvider = ({ children }) => {
|
||||||
type,
|
type,
|
||||||
position: positions[state.position],
|
position: positions[state.position],
|
||||||
progressClassName: classes.progress,
|
progressClassName: classes.progress,
|
||||||
// onClose: type === "error" && (() => setErrorToastId(null)),
|
|
||||||
className: classes.notification
|
className: classes.notification
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (type === "error") setErrorToastId(toastId);
|
|
||||||
|
|
||||||
return toastId;
|
return toastId;
|
||||||
},
|
},
|
||||||
[sendNotification, classes, state.position]
|
[sendNotification, classes, state.position]
|
||||||
|
@ -107,6 +117,9 @@ const ToastProvider = ({ children }) => {
|
||||||
() => ({
|
() => ({
|
||||||
...dispatchActions,
|
...dispatchActions,
|
||||||
info: (message) => notify(message, "info"),
|
info: (message) => notify(message, "info"),
|
||||||
|
error: (message) => notify(message, "error"),
|
||||||
|
success: (message) => notify(message, "success"),
|
||||||
|
defence: (message) => notify(message, "defence"),
|
||||||
notify
|
notify
|
||||||
}),
|
}),
|
||||||
[dispatchActions, notify]
|
[dispatchActions, notify]
|
||||||
|
|
|
@ -146,6 +146,22 @@ export default function NotificationsPage(props) {
|
||||||
>
|
>
|
||||||
Success Message
|
Success Message
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="info"
|
||||||
|
onClick={() => notify("Defence message", "defence")}
|
||||||
|
className={classnames(classes.notificationCallButton)}
|
||||||
|
>
|
||||||
|
Defence Message
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
color="info"
|
||||||
|
onClick={() => notify("The disk is full", "disk")}
|
||||||
|
className={classnames(classes.notificationCallButton)}
|
||||||
|
>
|
||||||
|
Full disk message
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</Widget>
|
</Widget>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
Loading…
Reference in New Issue