2020-12-20 13:50:12 +01:00
|
|
|
<style>
|
|
|
|
#form {
|
2020-12-25 10:03:50 +01:00
|
|
|
box-sizing: border-box;
|
2020-12-20 13:50:12 +01:00
|
|
|
flex: 1;
|
|
|
|
display: flex;
|
|
|
|
min-width: 300px;
|
|
|
|
}
|
|
|
|
|
|
|
|
#form input {
|
|
|
|
margin: 5px;
|
|
|
|
}
|
2020-12-20 15:24:25 +01:00
|
|
|
|
|
|
|
input#url {
|
|
|
|
flex: 1;
|
|
|
|
font-size: 1rem;
|
|
|
|
}
|
2020-12-25 10:03:50 +01:00
|
|
|
|
|
|
|
.input--error {
|
|
|
|
border: 1px solid firebrick;
|
|
|
|
}
|
2020-12-20 13:50:12 +01:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { createEvent } from '../actions'
|
2020-12-20 15:24:25 +01:00
|
|
|
import logger from '../services/logger'
|
2020-12-20 13:50:12 +01:00
|
|
|
|
2020-12-25 09:59:13 +01:00
|
|
|
export let error
|
|
|
|
export let pending
|
|
|
|
|
2020-12-20 13:50:12 +01:00
|
|
|
let value
|
2020-12-25 10:15:28 +01:00
|
|
|
let form
|
2020-12-20 13:50:12 +01:00
|
|
|
|
|
|
|
const onChange = (e) => {
|
|
|
|
value = e.currentTarget.value
|
|
|
|
}
|
|
|
|
|
2020-12-25 10:03:50 +01:00
|
|
|
let inputClasses = ''
|
|
|
|
$: inputClasses = [
|
|
|
|
error ? 'input--error' : '',
|
|
|
|
pending ? 'input--pending': '',
|
|
|
|
].join(' ')
|
|
|
|
console.log(inputClasses)
|
|
|
|
|
2020-12-20 13:50:12 +01:00
|
|
|
const handleSubmit = async (e) => {
|
2020-12-25 10:15:28 +01:00
|
|
|
if (!form.reportValidity()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-12-20 13:50:12 +01:00
|
|
|
e.preventDefault()
|
|
|
|
createEvent(value, { logger })
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-12-25 10:15:28 +01:00
|
|
|
<form id="form" bind:this={form}>
|
2020-12-20 13:50:12 +01:00
|
|
|
<input
|
|
|
|
required
|
|
|
|
pattern="^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?|\d+$"
|
|
|
|
id="url"
|
|
|
|
name="url"
|
2020-12-25 10:03:50 +01:00
|
|
|
class={inputClasses}
|
2020-12-20 13:50:12 +01:00
|
|
|
bind:value={value}
|
2020-12-25 09:59:13 +01:00
|
|
|
disabled={pending}
|
2020-12-20 13:50:12 +01:00
|
|
|
placeholder="Paste / type FB event URL or event number..."
|
|
|
|
title="Please insert Facebook Event URL / Number"
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
id="submit"
|
2020-12-25 10:03:50 +01:00
|
|
|
class={inputClasses}
|
2020-12-20 13:50:12 +01:00
|
|
|
type='submit'
|
|
|
|
value='Submit'
|
2020-12-25 09:59:13 +01:00
|
|
|
disabled={pending}
|
2020-12-20 13:50:12 +01:00
|
|
|
on:click={handleSubmit}
|
|
|
|
/>
|
|
|
|
</form>
|