Home view

This commit is contained in:
He4eT 2021-02-19 04:48:24 +05:00
commit c48d6ec305
3 changed files with 15 additions and 7 deletions

41
src/views/Home.js Normal file
View file

@ -0,0 +1,41 @@
import { h } from 'preact'
import { useState } from 'preact/hooks'
import { Link } from 'wouter-preact'
import FileSelector from '~/src/components/FileSelector'
import URLSelector from '~/src/components/URLSelector'
import { buildPlayLinkHref } from '~/src/utils/utils.routing'
export default function () {
const [targetName, setTargetName] = useState(null)
const [targetURL, setTargetURL] = useState(null)
const playButton = (
<Link href={buildPlayLinkHref(targetURL)}>
Play "{targetName}"
</Link>)
return (
<main>
<p>
You can browse some <Link href='/top100'>
games from IFDB
</Link> or play a game from a file.
</p>
<ul>
<li>
<FileSelector
emitName={setTargetName}
emitURL={setTargetURL} />
</li>
<li>
<URLSelector
emitName={setTargetName}
emitURL={setTargetURL} />
</li>
</ul>
{ targetURL ? playButton : null }
</main>)
}