bin/views/pages/new.templ

65 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2023-09-12 22:30:58 +02:00
package pages
import (
"git.myrkvi.com/myrkvi/bin/models"
"git.myrkvi.com/myrkvi/bin/views/components"
"git.myrkvi.com/myrkvi/bin/views/partials"
)
templ NewFull(wantsText bool) {
@page(
NewPartial(wantsText),
models.DefaultMenu,
1,
"upload",
)
}
templ NewPartial(wantsText bool) {
<h2 class="text-xl">submit a new file</h2>
<form
hx-post="/new"
hx-encoding="multipart/form-data"
method="POST"
hx-target="#main-content"
>
<div class="my-2 grid grid-cols-1 sm:grid-cols-3 md:grid-cols-5 gap-4 max-w-sm md:max-w-lg">
<label class="col-span-1" for="name">
file name:
</label>
<input
class="col-span-2 md:col-span-4 justify-self-start
outline-2 bg-amber-50
hover:outline-slate-400 hover:outline-dotted
focus:outline-slate-600 focus:outline-dashed
active:outline-green-600"
type="text"
name="name"
id="name"
placeholder="foo.txt"
_="on change set #description's @placeholder to `some stuff about ${my value} ...`"
/>
<label for="lang" class="col-span-1">language:</label>
<div class="col-span-2 md:col-span-4">@components.ChooseSyntax("lang")</div>
<label class="col-span-1" for="description">description:</label>
<textarea
class="col-span-2 md:col-span-4 resize-none hover:resize justify-self-start
w-full outline-2 bg-amber-50
hover:outline-slate-400 hover:outline-dotted
focus:outline-slate-600 focus:outline-dashed
active:outline-green-600"
name="description"
id="description"
rows="3"
placeholder="some stuff about foo.txt ..."
/>
</div>
if wantsText {
@partials.NewTextSubmit()
<input type="text" name="wantsText" hidden value="true" />
} else {
@partials.NewFileUpload()
}
@components.SubmitFormButton("submit")
</form>
}