From 5daf95c99c4fcf8a3926550f153c8b91c9e4a0d3 Mon Sep 17 00:00:00 2001 From: Bruno Loch Date: Tue, 2 May 2023 23:02:14 +0000 Subject: [PATCH] =?UTF-8?q?teste=20de=20mudan=C3=A7a=20de=20tema=20para=20?= =?UTF-8?q?modo=20escuro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/sections/settings/color-theme.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 frontend/src/sections/settings/color-theme.js diff --git a/frontend/src/sections/settings/color-theme.js b/frontend/src/sections/settings/color-theme.js new file mode 100644 index 0000000..1a5bff5 --- /dev/null +++ b/frontend/src/sections/settings/color-theme.js @@ -0,0 +1,62 @@ +import * as React from 'react'; +import IconButton from '@mui/material/IconButton'; +import Box from '@mui/material/Box'; +import { useTheme, ThemeProvider, createTheme } from '@mui/material/styles'; +import Brightness4Icon from '@mui/icons-material/Brightness4'; +import Brightness7Icon from '@mui/icons-material/Brightness7'; + +const ColorModeContext = React.createContext({ toggleColorMode: () => {} }); + +function MyApp() { + const theme = useTheme(); + const colorMode = React.useContext(ColorModeContext); + return ( + + {theme.palette.mode} mode + + {theme.palette.mode === 'dark' ? : } + + + ); +} + +export default function ToggleColorMode() { + const [mode, setMode] = React.useState<'light' | 'dark'>('light'); + const colorMode = React.useMemo( + () => ({ + toggleColorMode: () => { + setMode((prevMode) => (prevMode === 'light' ? 'dark' : 'light')); + }, + }), + [], + ); + + const theme = React.useMemo( + () => + createTheme({ + palette: { + mode, + }, + }), + [mode], + ); + + return ( + + + + + + ); +} \ No newline at end of file