Extract form as a separate component
This commit is contained in:
parent
84be267e16
commit
56db514d15
2 changed files with 39 additions and 25 deletions
34
src/components/form.astro
Normal file
34
src/components/form.astro
Normal file
|
@ -0,0 +1,34 @@
|
|||
---
|
||||
/*!
|
||||
* © 2023 Nikita Karamov
|
||||
* Licensed under AGPL v3 or later
|
||||
*/
|
||||
import InstanceSelect from "@components/instance-select.astro";
|
||||
|
||||
const { prefilledText, prefilledInstance } = Astro.props;
|
||||
---
|
||||
|
||||
<form
|
||||
id="js-s2f-form"
|
||||
action="/api/share"
|
||||
method="POST"
|
||||
>
|
||||
<label>
|
||||
Post text
|
||||
<textarea
|
||||
name="text"
|
||||
id="text"
|
||||
rows="7"
|
||||
placeholder="What's on your mind?"
|
||||
required
|
||||
>{prefilledText}</textarea
|
||||
>
|
||||
</label>
|
||||
|
||||
<InstanceSelect {prefilledInstance} />
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
value="Publish"
|
||||
/>
|
||||
</form>
|
|
@ -4,7 +4,7 @@
|
|||
* Licensed under AGPL v3 or later
|
||||
*/
|
||||
import Layout from "@layouts/layout.astro";
|
||||
import InstanceSelect from "@components/instance-select.astro";
|
||||
import Form from "@components/form.astro";
|
||||
import { Content as PrivacyNotice } from "@pages/_privacy.md";
|
||||
import { Content as Licence } from "@pages/_licence.md";
|
||||
|
||||
|
@ -23,30 +23,10 @@ const prefilledInstance = searchParameters.get("instance");
|
|||
/>
|
||||
</header>
|
||||
<main>
|
||||
<form
|
||||
id="js-s2f-form"
|
||||
action="/api/share"
|
||||
method="POST"
|
||||
>
|
||||
<label>
|
||||
Post text
|
||||
<textarea
|
||||
name="text"
|
||||
id="text"
|
||||
rows="7"
|
||||
placeholder="What's on your mind?"
|
||||
required
|
||||
>{prefilledText}</textarea
|
||||
>
|
||||
</label>
|
||||
|
||||
<InstanceSelect prefilledInstance={prefilledInstance} />
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
value="Publish"
|
||||
/>
|
||||
</form>
|
||||
<Form
|
||||
{prefilledText}
|
||||
{prefilledInstance}
|
||||
/>
|
||||
</main>
|
||||
<aside>
|
||||
<p>
|
||||
|
|
Reference in a new issue