Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 04adebe

Browse files
committed
emotion: GlobalSnackbar
1 parent eeb1b93 commit 04adebe

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

site/src/components/GlobalSnackbar/GlobalSnackbar.tsx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { makeStyles } from "@mui/styles";
2-
import { useCallback, useState, FC } from "react";
1+
import { type FC, useCallback, useState } from "react";
32
import { useCustomEvent } from "hooks/events";
4-
import { CustomEventListener } from "utils/events";
3+
import type { CustomEventListener } from "utils/events";
54
import { EnterpriseSnackbar } from "./EnterpriseSnackbar";
65
import { ErrorIcon } from "../Icons/ErrorIcon";
76
import { Typography } from "../Typography/Typography";
87
import {
9-
AdditionalMessage,
8+
type AdditionalMessage,
109
isNotificationList,
1110
isNotificationText,
1211
isNotificationTextPrefixed,
1312
MsgType,
14-
NotificationMsg,
13+
type NotificationMsg,
1514
SnackbarEventType,
1615
} from "./utils";
16+
import { type Interpolation, type Theme } from "@emotion/react";
1717

1818
const variantFromMsgType = (type: MsgType) => {
1919
if (type === MsgType.Error) {
@@ -26,7 +26,6 @@ const variantFromMsgType = (type: MsgType) => {
2626
};
2727

2828
export const GlobalSnackbar: FC = () => {
29-
const styles = useStyles();
3029
const [open, setOpen] = useState<boolean>(false);
3130
const [notification, setNotification] = useState<NotificationMsg>();
3231

@@ -47,7 +46,7 @@ export const GlobalSnackbar: FC = () => {
4746
key={idx}
4847
gutterBottom
4948
variant="body2"
50-
className={styles.messageSubtitle}
49+
css={styles.messageSubtitle}
5150
>
5251
{msg}
5352
</Typography>
@@ -58,17 +57,17 @@ export const GlobalSnackbar: FC = () => {
5857
key={idx}
5958
gutterBottom
6059
variant="body2"
61-
className={styles.messageSubtitle}
60+
css={styles.messageSubtitle}
6261
>
6362
<strong>{msg.prefix}:</strong> {msg.text}
6463
</Typography>
6564
);
6665
} else if (isNotificationList(msg)) {
6766
return (
68-
<ul className={styles.list} key={idx}>
67+
<ul css={styles.list} key={idx}>
6968
{msg.map((item, idx) => (
7069
<li key={idx}>
71-
<Typography variant="body2" className={styles.messageSubtitle}>
70+
<Typography variant="body2" css={styles.messageSubtitle}>
7271
{item}
7372
</Typography>
7473
</li>
@@ -89,12 +88,12 @@ export const GlobalSnackbar: FC = () => {
8988
open={open}
9089
variant={variantFromMsgType(notification.msgType)}
9190
message={
92-
<div className={styles.messageWrapper}>
91+
<div css={styles.messageWrapper}>
9392
{notification.msgType === MsgType.Error && (
94-
<ErrorIcon className={styles.errorIcon} />
93+
<ErrorIcon css={styles.errorIcon} />
9594
)}
96-
<div className={styles.message}>
97-
<Typography variant="body1" className={styles.messageTitle}>
95+
<div css={styles.message}>
96+
<Typography variant="body1" css={styles.messageTitle}>
9897
{notification.msg}
9998
</Typography>
10099
{notification.additionalMsgs &&
@@ -112,7 +111,7 @@ export const GlobalSnackbar: FC = () => {
112111
);
113112
};
114113

115-
const useStyles = makeStyles((theme) => ({
114+
const styles = {
116115
list: {
117116
paddingLeft: 0,
118117
},
@@ -126,11 +125,11 @@ const useStyles = makeStyles((theme) => ({
126125
fontSize: 14,
127126
fontWeight: 600,
128127
},
129-
messageSubtitle: {
128+
messageSubtitle: (theme) => ({
130129
marginTop: theme.spacing(1.5),
131-
},
132-
errorIcon: {
130+
}),
131+
errorIcon: (theme) => ({
133132
color: theme.palette.error.contrastText,
134133
marginRight: theme.spacing(2),
135-
},
136-
}));
134+
}),
135+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)