Unified file link format

This commit is contained in:
He4eT 2021-02-19 04:17:47 +05:00
commit 19e051045d
5 changed files with 96 additions and 13 deletions

34
src/views/Index.js Normal file
View file

@ -0,0 +1,34 @@
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'
export default function () {
const [targetName, setTargetName] = useState(null)
const [targetURL, setTargetURL] = useState(null)
const playButton = (
<Link href={`/#/play/default/${encodeURIComponent(targetURL)}`}>
Play "{targetName}"
</Link>)
return (
<main>
<ul>
<li>
<URLSelector
emitName={setTargetName}
emitURL={setTargetURL} />
</li>
<li>
<FileSelector
emitName={setTargetName}
emitURL={setTargetURL} />
</li>
</ul>
{ targetURL ? playButton : null }
</main>)
}

11
src/views/Player.jsx Normal file
View file

@ -0,0 +1,11 @@
import { h } from 'preact'
export default function ({params: {theme, encodedUrl}}) {
const url = decodeURIComponent(encodedUrl)
return (
<div>
{theme} <br/>
{url}
</div>)
}