From d838790b8fbca371750d3c51c4d38bb841fe7ef0 Mon Sep 17 00:00:00 2001 From: nimbleghost <132819643+nimbleghost@users.noreply.github.com> Date: Wed, 28 Jun 2023 20:42:34 +0200 Subject: [PATCH] Fix ntfy upgrade banner in dark mode --- web/src/components/ActionBar.jsx | 5 ++++- web/src/components/Navigation.jsx | 22 +++++++++++++++++----- web/src/components/theme.js | 2 -- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/web/src/components/ActionBar.jsx b/web/src/components/ActionBar.jsx index 6a36cdb6..62a16286 100644 --- a/web/src/components/ActionBar.jsx +++ b/web/src/components/ActionBar.jsx @@ -44,7 +44,10 @@ const ActionBar = (props) => { { Navigation.width = navWidth; const NavList = (props) => { + const theme = useTheme(); const { t } = useTranslation(); const navigate = useNavigate(); const location = useLocation(); @@ -190,7 +192,11 @@ const NavList = (props) => { - {showUpgradeBanner && } + {showUpgradeBanner && ( + // The text background gradient didn't seem to do well with switching between light/dark mode, + // So adding a `key` forces React to replace the entire component when the theme changes + + )} { ); }; -const UpgradeBanner = () => { +const UpgradeBanner = ({ mode }) => { const { t } = useTranslation(); const [dialogKey, setDialogKey] = useState(0); const [dialogOpen, setDialogOpen] = useState(false); @@ -220,13 +226,16 @@ const UpgradeBanner = () => { width: `${Navigation.width - 1}px`, bottom: 0, mt: "auto", - background: "linear-gradient(150deg, rgba(196, 228, 221, 0.46) 0%, rgb(255, 255, 255) 100%)", + background: + mode === "light" + ? "linear-gradient(150deg, rgba(196, 228, 221, 0.46) 0%, rgb(255, 255, 255) 100%)" + : "linear-gradient(150deg, #203631 0%, #2a6e60 100%)", }} > - + { style: { fontWeight: 500, fontSize: "1.1rem", - background: "-webkit-linear-gradient(45deg, #09009f, #00ff95 80%)", + background: + mode === "light" + ? "-webkit-linear-gradient(45deg, #09009f, #00ff95 80%)" + : "-webkit-linear-gradient(45deg,rgb(255, 255, 255), #00ff95 80%)", WebkitBackgroundClip: "text", WebkitTextFillColor: "transparent", }, diff --git a/web/src/components/theme.js b/web/src/components/theme.js index f789a0c5..cdfaf07d 100644 --- a/web/src/components/theme.js +++ b/web/src/components/theme.js @@ -34,7 +34,6 @@ export const lightPalette = { error: { main: "#c30000", }, - actionBarBackground: "linear-gradient(150deg, #338574 0%, #56bda8 100%)", }; /** @type {import("@mui/material").ThemeOptions['palette']} */ @@ -52,7 +51,6 @@ export const darkPalette = { error: { main: "#fe4d2e", }, - actionBarBackground: "linear-gradient(150deg, #203631 0%, #2a6e60 100%)", }; export default themeOptions;