mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Themes: init
This commit is contained in:
parent
251fa153f0
commit
cbc6207ad9
9 changed files with 108 additions and 46 deletions
59
src/index.js
59
src/index.js
|
|
@ -1,35 +1,50 @@
|
|||
import { h, render } from 'preact'
|
||||
import { Link, Route, Router, Switch } from 'wouter-preact'
|
||||
import { useState } from 'preact/hooks'
|
||||
import { Route, Router, Switch } from 'wouter-preact'
|
||||
|
||||
import { useHashLocation } from '~/src/utils/utils.routing'
|
||||
import {
|
||||
DEFAULT_THEME,
|
||||
themeList,
|
||||
assertTheme
|
||||
} from '~/src/themes/themes'
|
||||
|
||||
import Home from '~/src/views/Home'
|
||||
import Player from '~/src/views/Player'
|
||||
|
||||
import '~/src/style/base.css'
|
||||
|
||||
function App () {
|
||||
const [currentTheme, setCurrentTheme] =
|
||||
useState(DEFAULT_THEME)
|
||||
|
||||
const setTheme = theme =>
|
||||
setCurrentTheme(assertTheme(theme))
|
||||
|
||||
return (
|
||||
<Router hook={useHashLocation}>
|
||||
<div className='App'>
|
||||
<nav>
|
||||
<Link href='/'>Root</Link>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
<Switch>
|
||||
<Route
|
||||
path='/'
|
||||
component={Home} />
|
||||
<Route
|
||||
path='/play/:theme/:encodedUrl'
|
||||
component={Player} />
|
||||
<Route path='/top100'>
|
||||
top100
|
||||
</Route>
|
||||
<Route>
|
||||
404
|
||||
</Route>
|
||||
</Switch>
|
||||
</main>
|
||||
<div className={['app', currentTheme].join(' ')}>
|
||||
<Switch>
|
||||
<Route path='/'>
|
||||
<Home {...{
|
||||
setTheme,
|
||||
themeList,
|
||||
currentTheme
|
||||
}} />
|
||||
</Route>
|
||||
<Route path='/play/:theme/:encodedUrl'>
|
||||
{params => <Player {...{
|
||||
setTheme,
|
||||
...params
|
||||
}} />}
|
||||
</Route>
|
||||
<Route path='/top100'>
|
||||
top100
|
||||
</Route>
|
||||
<Route>
|
||||
404
|
||||
</Route>
|
||||
</Switch>
|
||||
</div>
|
||||
</Router>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue