Move form to page

This commit is contained in:
Nikita Karamov 2023-09-02 18:00:47 +02:00
parent 12aa0823d9
commit 9828b123d9
No known key found for this signature in database
GPG key ID: 41D6F71EE78E77CD
2 changed files with 29 additions and 46 deletions

View file

@ -1,41 +0,0 @@
---
/*!
* This file is part of Share₂Fedi
* https://github.com/kytta/share2fedi
*
* SPDX-FileCopyrightText: © 2023 Nikita Karamov <me@kytta.dev>
* SPDX-License-Identifier: AGPL-3.0-only
*/
import InstanceSelect from "@components/instance-select.astro";
const { prefilledText, prefilledInstance } = Astro.props;
---
<form
id="form"
action="/api/share"
method="POST"
>
<label data-translate="postText">
Post text
<textarea
name="text"
id="text"
rows="7"
placeholder="Whats on your mind?"
required
data-translate="postTextPlaceholder"
data-translate-attribute="placeholder"
>{prefilledText}</textarea
>
</label>
<InstanceSelect {prefilledInstance} />
<input
type="submit"
value="Publish"
data-translate="publish"
data-translate-attribute="value"
/>
</form>

View file

@ -7,7 +7,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import Layout from "@layouts/layout.astro";
import Form from "@components/form.astro";
import InstanceSelect from "@components/instance-select.astro";
const searchParameters = new URL(Astro.request.url).searchParams;
const prefilledText = searchParameters.get("text");
@ -15,8 +15,32 @@ const prefilledInstance = searchParameters.get("instance");
---
<Layout title="Share₂Fedi — an instance-agnostic share page for the Fediverse">
<Form
{prefilledText}
{prefilledInstance}
/>
<form
id="form"
action="/api/share"
method="POST"
>
<label data-translate="postText">
Post text
<textarea
name="text"
id="text"
rows="7"
placeholder="Whats on your mind?"
required
data-translate="postTextPlaceholder"
data-translate-attribute="placeholder"
>{prefilledText}</textarea
>
</label>
<InstanceSelect {prefilledInstance} />
<input
type="submit"
value="Publish"
data-translate="publish"
data-translate-attribute="value"
/>
</form>
</Layout>