From 8bec7ba3fb11d99b188873a660470c87bb902167 Mon Sep 17 00:00:00 2001 From: Jandson Vitorino Date: Tue, 13 Jun 2023 12:03:09 -0300 Subject: [PATCH 01/14] Implementacao do DarkMode --- frontend/components/Header.js | 40 +++++++++++++++++++++------- frontend/pages/_app.js | 33 ++++++++++++++++------- frontend/pages/themes/dark.js | 0 frontend/pages/themes/light.js | 0 frontend/styles/components/Footer.js | 2 +- frontend/styles/components/Header.js | 2 +- frontend/styles/pages/products.js | 2 +- frontend/styles/pages/tutorials.js | 5 +++- 8 files changed, 62 insertions(+), 22 deletions(-) create mode 100644 frontend/pages/themes/dark.js create mode 100644 frontend/pages/themes/light.js diff --git a/frontend/components/Header.js b/frontend/components/Header.js index e206f97..95f2533 100644 --- a/frontend/components/Header.js +++ b/frontend/components/Header.js @@ -9,18 +9,27 @@ import { MenuItem, Toolbar, Typography -} from '@mui/material' +} +from '@mui/material' import { useRouter } from 'next/router' -import React from 'react' +import { ListItemIcon } from '@mui/material'; -import { GitHub, Twitter, YouTube } from '@mui/icons-material' +import React from 'react' +import { + GitHub, + Twitter, + YouTube, + Brightness4, + Brightness7, + Logout +} from '@mui/icons-material' import MoreIcon from '@mui/icons-material/MoreVert' import TokenDialog from '../components/TokenDialog' import { useAuth } from '../contexts/AuthContext' import useStyles from '../styles/components/Header' import Link from './Link' -function Header() { +function Header({ darkMode, setDarkMode }) { const classes = useStyles() const router = useRouter() const { user, logout } = useAuth() @@ -55,9 +64,7 @@ function Header() { } const handleTokenOpen = () => { - // Fecha o menu setAnchorEl(null) - // Abre a Dialog Token Api setOpen(true) } @@ -65,6 +72,10 @@ function Header() { setOpen(false) } + const handleToggleDarkMode = () => { + setDarkMode(prevMode => !prevMode) + } + return (
@@ -80,6 +91,14 @@ function Header() {
{user?.username} + + {darkMode ? : } + API Token - Logout + + + + + Logout + - {router.pathname === '/' && ( - {/*

Photo-z Server

*/} Photo-z Server diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index 87127ee..0bfe725 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -1,30 +1,41 @@ import CssBaseline from '@mui/material/CssBaseline' -import { ThemeProvider } from '@mui/styles' +import { ThemeProvider, createTheme } from '@mui/material/styles' import Head from 'next/head' import { useRouter } from 'next/router' import PropTypes from 'prop-types' -import { useEffect } from 'react' +import { useEffect, useState } from 'react' import { QueryClient, QueryClientProvider } from 'react-query' import Footer from '../components/Footer' -import Header from '../components/Header' import { AuthProvider } from '../contexts/AuthContext' import '../styles/global.css' -import light from '../themes/light' +import Header from '../components/Header' const queryClient = new QueryClient() export default function MyApp(props) { const { Component, pageProps } = props const route = useRouter() + const [darkMode, setDarkMode] = useState(false) useEffect(() => { - // Remove the server-side injected CSS. const jssStyles = document.querySelector('#jss-server-side') if (jssStyles) { jssStyles.parentElement.removeChild(jssStyles) } }, []) + const light = createTheme({ + palette: { + mode: 'light', + }, + }) + + const dark = createTheme({ + palette: { + mode: 'dark', + }, + }) + return ( <> @@ -35,10 +46,8 @@ export default function MyApp(props) { /> - - {/* CssBaseline kickstart an elegant, consistent, and simple baseline to build upon. */} + - {/* Overwriting some global CSS. */}
- {route.pathname !== '/login' &&
} + {route.pathname !== '/login' && ( +
+ )} {route.pathname !== '/login' &&