-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redo darkmode using MUI's latest CSS variables approach. MUI does mor…
…e of the work, no need to pass darkMode around.
- Loading branch information
Showing
25 changed files
with
425 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,46 @@ | ||
import { CssBaseline, GlobalStyles } from "@mui/material"; | ||
import { Experimental_CssVarsProvider as CssVarsProvider, experimental_extendTheme as extendTheme } from "@mui/material/styles"; | ||
import { BrowserRouter, Route, Routes } from "react-router-dom"; | ||
import Analyser from "./Analyser"; | ||
import Browser from "./Browser"; | ||
import Deforum from "./Deforum"; | ||
import FunctionDoc from "./FunctionDoc"; | ||
import Labs from "./Labs"; | ||
import Raw from "./Raw"; | ||
import Header from "./components/Header"; | ||
import { themeFactory } from "./theme"; | ||
|
||
const App = () => { | ||
return <> | ||
<Header title="Parseq Legacy – deprecated" /> | ||
<a href="/">Go home.</a> | ||
</>; | ||
|
||
const theme = extendTheme(themeFactory()); | ||
|
||
return <CssVarsProvider theme={theme}> | ||
<CssBaseline /> | ||
<GlobalStyles | ||
styles={{ | ||
code: { | ||
fontFamily: "source-code-pro, Menlo, Monaco, Consolas, 'Courier New',monospace", | ||
background: theme.vars.palette.codeBackground.main, | ||
wordWrap: "break-word", | ||
boxDecorationBreak: "clone", | ||
padding: ".1rem .1rem .1rem", | ||
borderRadius: ".2rem" | ||
} | ||
}} | ||
/> | ||
<BrowserRouter> | ||
<Header /> | ||
<Routes> | ||
<Route path="/" element={<Deforum />} /> | ||
<Route path="/deforum" element={<Deforum />} /> | ||
<Route path="/browser" element={<Browser />} /> | ||
<Route path="/analyser" element={<Analyser />} /> | ||
<Route path="/labs" element={<Labs />} /> | ||
<Route path="/raw" element={<Raw />} /> | ||
<Route path="/functionDocs" element={<FunctionDoc />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
</CssVarsProvider>; | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,12 @@ | ||
import React, { useCallback, useMemo, useState } from "react"; | ||
import Header from "./components/Header"; | ||
import ParseqUI from './ParseqUI'; | ||
import {createTheme, ThemeOptions, ThemeProvider} from '@mui/material/styles'; | ||
import { useMediaQuery } from "@mui/material"; | ||
import { UserSettings } from "./UserSettings"; | ||
|
||
const Deforum = () => { | ||
|
||
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); | ||
const [darkMode, setDarkMode] = useState(prefersDarkMode); | ||
const theme = useMemo(() => createTheme(themeFactory(darkMode)), [darkMode]); | ||
const updateDarkMode = useCallback((darkMode: boolean) => { | ||
setDarkMode(darkMode); | ||
UserSettings.setDarkMode(darkMode); | ||
}, []); | ||
|
||
// Retrieve dark mode setting from local db | ||
UserSettings.getDarkMode().then((darkMode) => { | ||
if (darkMode !== undefined) { | ||
setDarkMode(darkMode); | ||
} | ||
}); | ||
|
||
return (<ThemeProvider theme={theme}> | ||
<Header title="Parseq for Deforum" darkMode={darkMode} updateDarkMode={updateDarkMode} /> | ||
|
||
return (<> | ||
{/* @ts-ignore */} | ||
<ParseqUI | ||
defaultTemplate='catduck' | ||
darkMode={darkMode} /> | ||
|
||
</ThemeProvider>) | ||
defaultTemplate='catduck'/> | ||
</>) | ||
} | ||
|
||
export default Deforum; | ||
|
||
function themeFactory(darkMode: boolean): ThemeOptions { | ||
return { | ||
palette: { | ||
mode: darkMode ? 'dark' : 'light', | ||
background: { | ||
default: darkMode ? '#252525' : '#fff', | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.