From 247886ce856c63099d90c89697180a85c2e720e1 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Wed, 23 Apr 2025 08:55:50 +0200 Subject: [PATCH 1/2] Simplify selector with a unique icon --- src/App.tsx | 2 +- src/ExtStates/NotAuthenticated.tsx | 2 +- src/components/Apps/AppsHomeDesktop.tsx | 2 +- src/components/DesktopSideBar.tsx | 2 +- src/components/Theme/ThemeSelector.tsx | 76 +++++-------------------- 5 files changed, 17 insertions(+), 67 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 7d3a7c7..7ce75de 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3681,7 +3681,7 @@ function App() { /> )} - + ); } diff --git a/src/ExtStates/NotAuthenticated.tsx b/src/ExtStates/NotAuthenticated.tsx index a892414..017e7ae 100644 --- a/src/ExtStates/NotAuthenticated.tsx +++ b/src/ExtStates/NotAuthenticated.tsx @@ -1058,7 +1058,7 @@ export const NotAuthenticated = ({ /> - + ); }; diff --git a/src/components/Apps/AppsHomeDesktop.tsx b/src/components/Apps/AppsHomeDesktop.tsx index d9ad291..d525c26 100644 --- a/src/components/Apps/AppsHomeDesktop.tsx +++ b/src/components/Apps/AppsHomeDesktop.tsx @@ -157,7 +157,7 @@ export const AppsHomeDesktop = ({ /> - + ); }; diff --git a/src/components/DesktopSideBar.tsx b/src/components/DesktopSideBar.tsx index d1c8a7a..2244334 100644 --- a/src/components/DesktopSideBar.tsx +++ b/src/components/DesktopSideBar.tsx @@ -139,7 +139,7 @@ export const DesktopSideBar = ({ )} - + ); }; diff --git a/src/components/Theme/ThemeSelector.tsx b/src/components/Theme/ThemeSelector.tsx index dbf9d90..b82c072 100644 --- a/src/components/Theme/ThemeSelector.tsx +++ b/src/components/Theme/ThemeSelector.tsx @@ -1,75 +1,25 @@ import { useThemeContext } from './ThemeContext'; -import { styled, Switch } from '@mui/material'; +import { IconButton, Tooltip } from '@mui/material'; +import LightModeIcon from '@mui/icons-material/LightMode'; +import DarkModeIcon from '@mui/icons-material/DarkMode'; -const ThemeSwitch = styled(Switch)(({ theme }) => ({ - width: 62, - height: 34, - padding: 7, - '& .MuiSwitch-switchBase': { - margin: 1, - padding: 0, - transform: 'translateX(6px)', - '&.Mui-checked': { - color: '#fff', - transform: 'translateX(22px)', - '& .MuiSwitch-thumb:before': { - backgroundImage: `url('data:image/svg+xml;utf8,')`, - }, - '& + .MuiSwitch-track': { - opacity: 1, - backgroundColor: '#aab4be', - ...theme.applyStyles('dark', { - backgroundColor: '#8796A5', - }), - }, - }, - }, - '& .MuiSwitch-thumb': { - backgroundColor: '#fde402', - width: 32, - height: 32, - '&::before': { - content: "''", - position: 'absolute', - width: '100%', - height: '100%', - left: 0, - top: 0, - backgroundRepeat: 'no-repeat', - backgroundPosition: 'center', - backgroundImage: `url('data:image/svg+xml;utf8,')`, - }, - ...theme.applyStyles('dark', { - backgroundColor: '#003892', - }), - }, - '& .MuiSwitch-track': { - opacity: 1, - backgroundColor: '#aab4be', - borderRadius: 20 / 2, - ...theme.applyStyles('dark', { - backgroundColor: '#8796A5', - }), - }, -})); - -const ThemeSelector = ({ style }) => { +const ThemeSelector = () => { const { themeMode, toggleTheme } = useThemeContext(); + return (
- + + + {themeMode === 'dark' ? : } + +
); }; From 104c4822bf2556532a18740f61d4edf28f3e5b9d Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Wed, 23 Apr 2025 09:05:07 +0200 Subject: [PATCH 2/2] Refactor icon position --- src/components/DesktopSideBar.tsx | 2 +- src/components/Theme/ThemeSelector.tsx | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/DesktopSideBar.tsx b/src/components/DesktopSideBar.tsx index 2244334..b25d206 100644 --- a/src/components/DesktopSideBar.tsx +++ b/src/components/DesktopSideBar.tsx @@ -118,7 +118,7 @@ export const DesktopSideBar = ({ - {/* */} + {isEnabledDevMode && ( { diff --git a/src/components/Theme/ThemeSelector.tsx b/src/components/Theme/ThemeSelector.tsx index b82c072..238ca00 100644 --- a/src/components/Theme/ThemeSelector.tsx +++ b/src/components/Theme/ThemeSelector.tsx @@ -9,10 +9,11 @@ const ThemeSelector = () => { return (