this repo has no description
1package frontend
2
3import (
4 "fmt"
5 "github.com/willdot/bskyfeedgen/store"
6)
7
8templ Bookmarks(bookmarks []store.Bookmark) {
9 @Base()
10 <div hx-ext="response-targets" class="flex justify-center items-center pt-6">
11 <form hx-post="/bookmarks" hx-trigger="submit" hx-target="#result" hx-swap="innerHTML" hx-target-error="#result" class="w-96" hx-on::after-request="this.reset()">
12 <input name="uri" class="rounded-lg w-full mb-2 p-4" placeholder="Add Post URI here"/>
13 <button class="py-1 px-4 w-full h-10 rounded-lg text-white bg-zinc-800">
14 Add Bookmark
15 </button>
16 <div id="result" class="text-red-500 font-bold items-center pt-6"></div>
17 </form>
18 </div>
19 <div hx-ext="response-targets" class="flex justify-center items-center pt-6">
20 <table class="min-w-half divide-y-2 divide-gray-200 bg-white text-sm">
21 <tbody class="divide-y divide-gray-200" id="bookmarks-table">
22 for _, bookmark := range bookmarks {
23 @bookmarkRow(bookmark)
24 }
25 </tbody>
26 </table>
27 </div>
28}
29
30templ bookmarkRow(bookmark store.Bookmark) {
31 <tr id={ fmt.Sprintf("bookmark-%s", bookmark.PostRKey) }>
32 <td class="px-4 py-2 font-medium text-gray-900">
33 <p class="font-medium text-sm text-blue-300">Author: { bookmark.AuthorHandle } </p>
34 <a class="font-medium text-sm" target="_blank" href={ templ.URL(bookmark.PostURI) }>{ bookmark.Content }</a>
35 </td>
36 <td class="whitespace-nowrap px-4 py-2 text-gray-700">
37 <button
38 hx-delete={ fmt.Sprintf("/bookmarks/%s", bookmark.PostRKey) }
39 hx-swap="delete"
40 hx-target={ fmt.Sprintf("#bookmark-%s", bookmark.PostRKey) }
41 class="flex items-center border py-1 px-2 rounded-lg hover:bg-red-300"
42 >
43 <p class="text-sm">Delete</p>
44 </button>
45 </td>
46 </tr>
47}
48
49templ NewBookmarkRow(bookmark store.Bookmark) {
50 <tbody hx-swap-oob="beforeend:#bookmarks-table">
51 @bookmarkRow(bookmark)
52 </tbody>
53}