vigil/src/routes/create/+page.svelte

81 lines
1.7 KiB
Svelte
Raw Normal View History

2025-10-22 13:55:19 +02:00
<script lang="ts">
import Centered from "$lib/Centered.svelte";
import { getMe } from "$lib/globals.svelte";
import GuildSelect from "$lib/GuildSelect.svelte";
import PrivacySelect from "$lib/PrivacySelect.svelte";
2025-10-22 13:55:19 +02:00
import SLayout from "$lib/SLayout.svelte";
import { RiErrorWarningLine } from "svelte-remixicon";
2025-10-22 13:55:19 +02:00
let me = getMe();
let content = $state("");
let privacy = $state(0);
2025-10-22 13:55:19 +02:00
let contentLength = $derived(content.length);
</script>
{#if me}
<SLayout title="New post">
<form method="POST" class="card">
<p>Posting as <strong>@{me.username}</strong></p>
2025-10-22 13:55:19 +02:00
<label>
Post to: <!-- TODO autocomplete! -->
<GuildSelect />
</label>
2025-10-22 13:55:19 +02:00
<label>
<input type="text" name="title" maxlength=256 placeholder="An interesting title"/>
</label>
<label>
<textarea bind:value={content}></textarea>
<output><small class="faint">{contentLength} chars</small></output>
</label>
<PrivacySelect bind:value={privacy} />
{#if privacy === 0}
<span class="warning"><RiErrorWarningLine /> Your post will be PUBLIC!</span>
{/if}
2025-10-22 13:55:19 +02:00
<button class="card primary" disabled>Create</button>
2025-10-22 13:55:19 +02:00
</form>
{#snippet left()}
...
{/snippet}
{#snippet right()}
...
{/snippet}
2025-10-22 13:55:19 +02:00
</SLayout>
{:else}
<Centered>
You must be <a href="login">logged in</a> in order to create posts.
2025-10-22 13:55:19 +02:00
</Centered>
{/if}
<style>
textarea {
width: 100%;
background-color: inherit;
color: var(--text-primary);
min-height: 10em;
margin-top: 4px;
}
form {
display: flex;
flex-direction: column;
}
input[name="title"] {
width: 100%;
margin: 6px 0;
font-size: 1.25em;
}
</style>