generated from ryanatkn/fuz_template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Toot_Input.svelte
38 lines (33 loc) · 1022 Bytes
/
Toot_Input.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<script lang="ts">
import Alert from '@ryanatkn/fuz/Alert.svelte';
import {slide} from 'svelte/transition';
import type {SvelteHTMLElements} from 'svelte/elements';
import {parse_mastodon_status_url} from '$lib/mastodon.js';
interface Props {
url: string;
attrs?: SvelteHTMLElements['input'] | undefined;
}
let {url = $bindable(), attrs}: Props = $props(); // eslint-disable-line prefer-const
const parsed = $derived(parse_mastodon_status_url(url));
const invalid = $derived(!!(url && !parsed));
</script>
<fieldset>
<div class="row" class:mb_lg={invalid}>
<label title="where to load the toot" class="flex_1 row">
<a class="icon_button box mr_lg" style:font-size="var(--size_xl)" href={url || undefined}
>🔗</a
>
<input
bind:value={url}
placeholder="> toot url"
onfocus={(e) => e.currentTarget.select()}
{...attrs}
/>
</label>
</div>
{#if invalid}
<div transition:slide>
<Alert status="error">invalid Mastodon status url</Alert>
</div>
{/if}
</fieldset>