Create the context and setup for theming.
This commit is contained in:
parent
09656ee76c
commit
521de9ec70
|
@ -1,4 +1,3 @@
|
|||
body,
|
||||
.love-dark {
|
||||
--border-radius: 8px;
|
||||
--foreground-1: #f2efff;
|
||||
|
|
|
@ -9,14 +9,23 @@ import {Router} from 'preact-router';
|
|||
import HomePage from './pages/home.js';
|
||||
import NotFoundPage from './pages/not-found.js';
|
||||
import ReleasePage from './pages/release.js';
|
||||
import {themeContext, themes} from './utilities/themes.js';
|
||||
|
||||
const savedTheme = window.localStorage.getItem('theme');
|
||||
const activeTheme =
|
||||
themes.find((theme) => theme.cssClass === savedTheme) ?? themes[0];
|
||||
|
||||
document.body.classList.value = activeTheme.cssClass;
|
||||
|
||||
render(
|
||||
html`
|
||||
<${themeContext.Provider} value=${activeTheme}>
|
||||
<${Router}>
|
||||
<${HomePage} path="/" />
|
||||
<${ReleasePage} path="/release/:mbid" />
|
||||
<${NotFoundPage} default />
|
||||
<//>
|
||||
<//>
|
||||
`,
|
||||
document.body,
|
||||
);
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import {createContext} from 'preact';
|
||||
|
||||
type Theme = {
|
||||
cssClass: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export const themes: Theme[] = [
|
||||
{
|
||||
cssClass: 'love-dark',
|
||||
name: 'Love Dark',
|
||||
},
|
||||
];
|
||||
|
||||
export const themeContext = createContext<Theme>(themes[0]);
|
Loading…
Reference in New Issue