Darkmode anche in mobile

pull/1/head
Antonio De Lucreziis 2 years ago
parent 360fa42606
commit c7c8ce9d48

@ -2,13 +2,21 @@ import { ComboBox } from './ComboBox.jsx'
import { Help } from './Help.jsx' import { Help } from './Help.jsx'
import { Icon } from './Icon.jsx' import { Icon } from './Icon.jsx'
export const HamburgerMenu = ({ onClose, mode, setMode, source, setSource }) => { export const HamburgerMenu = ({ onClose, mode, setMode, source, setSource, theme, setTheme }) => {
return ( return (
<div class="menu"> <div class="menu">
<div class="header"> <div class="header">
<div class="option-group">
<button class="flat icon" onClick={onClose}> <button class="flat icon" onClick={onClose}>
<Icon name="close" /> <Icon name="close" />
</button> </button>
<button
class="icon"
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
>
<Icon name={theme === 'dark' ? 'dark_mode' : 'light_mode'} />
</button>
</div>
<div class="item logo"> <div class="item logo">
<img src="logo-circuit-board.svg" alt="logo" /> / <span>Orario</span> <img src="logo-circuit-board.svg" alt="logo" /> / <span>Orario</span>
</div> </div>

@ -1,7 +1,16 @@
import { CompoundButton } from './CompoundButton.jsx' import { CompoundButton } from './CompoundButton.jsx'
import { Icon } from './Icon.jsx' import { Icon } from './Icon.jsx'
export const Toolbar = ({ mode, setMode, source, setSource, onShowMenu, onHelp, theme, setTheme }) => { export const Toolbar = ({
mode,
setMode,
source,
setSource,
onShowMenu,
onHelp,
theme,
setTheme,
}) => {
return ( return (
<div class="toolbar"> <div class="toolbar">
<div class="mobile"> <div class="mobile">
@ -53,8 +62,11 @@ export const Toolbar = ({ mode, setMode, source, setSource, onShowMenu, onHelp,
</button> </button>
</div> </div>
<div class="item option"> <div class="item option">
<button class="icon" onClick={() => setTheme(theme==="dark"?"light":"dark")}> <button
<Icon name={theme==="dark"?"dark_mode":"light_mode"} /> class="icon"
onClick={() => setTheme(theme === 'dark' ? 'light' : 'dark')}
>
<Icon name={theme === 'dark' ? 'dark_mode' : 'light_mode'} />
</button> </button>
</div> </div>
<div class="item option"> <div class="item option">

@ -103,10 +103,10 @@ const App = ({}) => {
setEventi(eventi) setEventi(eventi)
}, [source]) }, [source])
const [theme, setTheme] = useState(localStorage.getItem("theme") ?? "light") const [theme, setTheme] = useState(localStorage.getItem('theme') ?? 'light')
document.body.classList.toggle("dark-mode", theme === "dark") document.body.classList.toggle('dark-mode', theme === 'dark')
localStorage.setItem("theme", theme) localStorage.setItem('theme', theme)
return ( return (
<> <>
@ -158,6 +158,8 @@ const App = ({}) => {
setMode, setMode,
source, source,
setSource, setSource,
theme,
setTheme,
onClose: () => { onClose: () => {
setShowMobileMenu(false) setShowMobileMenu(false)
}, },

@ -850,6 +850,7 @@ body {
justify-content: space-between; justify-content: space-between;
border-bottom: 1px solid var(--border-500); border-bottom: 1px solid var(--border-500);
.logo { .logo {
display: flex; display: flex;
align-items: center; align-items: center;
@ -860,6 +861,11 @@ body {
gap: 0.25rem; gap: 0.25rem;
} }
.option-group {
display: flex;
gap: 0.5rem;
}
} }
.options { .options {

Loading…
Cancel
Save