Files
comfychan/web/views/board.templ
T

49 lines
1.3 KiB
Templ

package views
import (
"fmt"
database "github.com/dominicf2001/comfychan/internal/database"
"github.com/dominicf2001/comfychan/web/views/shared"
)
templ NewThreadForm(board database.Board) {
<form
style="display: none;"
id="newThreadForm"
hx-swap="none"
hx-post={ fmt.Sprintf("/boards/%d/threads", board.Id) }
_="on htmx:afterRequest hide me then show #newThreadBtn then trigger refreshThreads on body"
>
<table>
<tbody>
<tr class="new-thread-form-field">
<th>Subject</th>
<td><input name="subject"/></td>
</tr>
<tr class="new-thread-form-field">
<th>Comment</th>
<td><textarea name="body" required></textarea></td>
</tr>
</tbody>
</table>
<button type="submit">Submit</button>
</form>
}
templ Board(board database.Board) {
@shared.Layout() {
<header class="board-header">
<img src="/static/img/banner-comfy.png"/>
<h1>
{ fmt.Sprintf("/%s/ - %s", board.Slug, board.Name) }
</h1>
<p>{ board.Tag }</p>
</header>
<div class="new-thread-container">
<button _="on click hide me then show #newThreadForm" id="newThreadBtn">[New Thread]</button>
@NewThreadForm(board)
</div>
<div hx-get={ fmt.Sprintf("/hx/boards/%d/catalog", board.Id) } hx-trigger="load, refreshThreads from:body"></div>
}
}