mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 09:27:23 +00:00
Rearrange components
This commit is contained in:
parent
e44831db08
commit
90f630f277
13 changed files with 10 additions and 8 deletions
15
src/components/FileSelector/LocalFileSelector.jsx
Normal file
15
src/components/FileSelector/LocalFileSelector.jsx
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { h } from 'preact'
|
||||
|
||||
export default function ({ setTargetName, setTargetUrl }) {
|
||||
const fileInputHandler = ({ target }) => {
|
||||
const file = target.files[0]
|
||||
setTargetName(file.name)
|
||||
setTargetUrl(`${URL.createObjectURL(file)}#${file.name}`)
|
||||
target.value = null
|
||||
}
|
||||
|
||||
return (
|
||||
<input
|
||||
type='file'
|
||||
onChange={fileInputHandler} />)
|
||||
}
|
||||
23
src/components/FileSelector/TargetURLSelector.jsx
Normal file
23
src/components/FileSelector/TargetURLSelector.jsx
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import { h } from 'preact'
|
||||
|
||||
export default function ({ setTargetName, setTargetUrl }) {
|
||||
const urlRE = /^(http|https):\/\/[^ "]+$/
|
||||
|
||||
const emit = url => {
|
||||
setTargetName(url)
|
||||
setTargetUrl(url)
|
||||
}
|
||||
|
||||
const urlInputHandler = ({ target }) => {
|
||||
const url = target.value
|
||||
emit(urlRE.test(url)
|
||||
? url
|
||||
: null)
|
||||
}
|
||||
|
||||
return (
|
||||
<input
|
||||
type='text'
|
||||
placeholder='https://...'
|
||||
onInput={urlInputHandler} />)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue