diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-04-20 01:17:32 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-05-16 00:55:01 +0200 |
commit | bf2dfbc65e1f702c64fd7d76356339b9b37ef5f7 (patch) | |
tree | 4eede1c4153e84c02ca19e5a7a5c292d4ce859ac /packages/renderer/src/components/NotificationBanner.tsx | |
parent | feat: Always show location bar on error (diff) | |
download | sophie-bf2dfbc65e1f702c64fd7d76356339b9b37ef5f7.tar.gz sophie-bf2dfbc65e1f702c64fd7d76356339b9b37ef5f7.tar.zst sophie-bf2dfbc65e1f702c64fd7d76356339b9b37ef5f7.zip |
feat(renderer): Insecure connection warning
Show a more prominent warning for insecure connections with a button
to try connecting over HTTPS if possible.
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'packages/renderer/src/components/NotificationBanner.tsx')
-rw-r--r-- | packages/renderer/src/components/NotificationBanner.tsx | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/packages/renderer/src/components/NotificationBanner.tsx b/packages/renderer/src/components/NotificationBanner.tsx deleted file mode 100644 index c759d46..0000000 --- a/packages/renderer/src/components/NotificationBanner.tsx +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2022 Kristóf Marussy <kristof@marussy.com> | ||
3 | * | ||
4 | * This file is part of Sophie. | ||
5 | * | ||
6 | * Sophie is free software: you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU Affero General Public License as | ||
8 | * published by the Free Software Foundation, version 3. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU Affero General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Affero General Public License | ||
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
17 | * | ||
18 | * SPDX-License-Identifier: AGPL-3.0-only | ||
19 | */ | ||
20 | |||
21 | import { Typography } from '@mui/material'; | ||
22 | import Alert, { AlertColor } from '@mui/material/Alert'; | ||
23 | import Box from '@mui/material/Box'; | ||
24 | import { styled } from '@mui/material/styles'; | ||
25 | import React, { ReactNode } from 'react'; | ||
26 | import { useTranslation } from 'react-i18next'; | ||
27 | |||
28 | const NotificationBannerRoot = styled(Alert)(({ theme }) => ({ | ||
29 | paddingTop: 7, | ||
30 | paddingBottom: 6, | ||
31 | // Match the height of the location bar. | ||
32 | minHeight: 53, | ||
33 | borderRadius: 0, | ||
34 | borderBottom: `1px solid ${theme.palette.divider}`, | ||
35 | '.MuiAlert-message': { | ||
36 | flexGrow: 1, | ||
37 | paddingTop: 0, | ||
38 | paddingBottom: 4, | ||
39 | display: 'flex', | ||
40 | flexWrap: 'wrap', | ||
41 | justifyContent: 'center', | ||
42 | }, | ||
43 | '.MuiAlert-action': { | ||
44 | paddingLeft: 0, | ||
45 | }, | ||
46 | })); | ||
47 | |||
48 | const NotificationBannerText = styled(Typography)(({ theme }) => ({ | ||
49 | fontSize: 'inherit', | ||
50 | paddingTop: theme.spacing(1), | ||
51 | paddingRight: theme.spacing(2), | ||
52 | flexGrow: 9999, | ||
53 | })); | ||
54 | |||
55 | const NotificationBannerButtons = styled(Box)(({ theme }) => ({ | ||
56 | fontSize: 'inherit', | ||
57 | paddingTop: theme.spacing(0.5), | ||
58 | paddingRight: theme.spacing(0.5), | ||
59 | display: 'flex', | ||
60 | flexWrap: 'wrap', | ||
61 | flexGrow: 1, | ||
62 | gap: theme.spacing(1), | ||
63 | '.MuiButton-root': { | ||
64 | flexGrow: 1, | ||
65 | }, | ||
66 | })); | ||
67 | |||
68 | export default function NotificationBanner({ | ||
69 | severity, | ||
70 | icon, | ||
71 | onClose, | ||
72 | buttons, | ||
73 | children, | ||
74 | }: { | ||
75 | severity?: AlertColor; | ||
76 | icon?: ReactNode; | ||
77 | onClose: () => void; | ||
78 | buttons?: ReactNode; | ||
79 | children?: ReactNode; | ||
80 | }): JSX.Element { | ||
81 | const { t } = useTranslation(); | ||
82 | |||
83 | return ( | ||
84 | <NotificationBannerRoot | ||
85 | severity={severity ?? 'success'} | ||
86 | icon={icon ?? false} | ||
87 | onClose={onClose} | ||
88 | closeText={t<string>('banner.close')} | ||
89 | > | ||
90 | <NotificationBannerText>{children}</NotificationBannerText> | ||
91 | {buttons && ( | ||
92 | <NotificationBannerButtons>{buttons}</NotificationBannerButtons> | ||
93 | )} | ||
94 | </NotificationBannerRoot> | ||
95 | ); | ||
96 | } | ||
97 | |||
98 | NotificationBanner.defaultProps = { | ||
99 | severity: 'success', | ||
100 | icon: false, | ||
101 | buttons: undefined, | ||
102 | children: undefined, | ||
103 | }; | ||