fix: use templui checkbox for shopping list item
This commit is contained in:
parent
c473c88c33
commit
998d3cb300
1 changed files with 11 additions and 9 deletions
|
|
@ -3,6 +3,7 @@ package shoppinglist
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.juancwu.dev/juancwu/budgit/internal/model"
|
"git.juancwu.dev/juancwu/budgit/internal/model"
|
||||||
|
"git.juancwu.dev/juancwu/budgit/internal/ui/components/checkbox"
|
||||||
)
|
)
|
||||||
|
|
||||||
templ ListItem(list *model.ShoppingList) {
|
templ ListItem(list *model.ShoppingList) {
|
||||||
|
|
@ -16,15 +17,16 @@ templ ListItem(list *model.ShoppingList) {
|
||||||
|
|
||||||
templ ItemDetail(spaceID string, item *model.ListItem) {
|
templ ItemDetail(spaceID string, item *model.ListItem) {
|
||||||
<div id={ "item-" + item.ID } class="flex items-center gap-2 p-2 border-b">
|
<div id={ "item-" + item.ID } class="flex items-center gap-2 p-2 border-b">
|
||||||
<input
|
@checkbox.Checkbox(checkbox.Props{
|
||||||
type="checkbox"
|
ID: "item-" + item.ID + "-checkbox",
|
||||||
name="is_checked"
|
Name: "is_checked",
|
||||||
checked?={ item.IsChecked }
|
Checked: item.IsChecked,
|
||||||
hx-patch={ fmt.Sprintf("/app/spaces/%s/lists/%s/items/%s", spaceID, item.ListID, item.ID) }
|
Attributes: templ.Attributes{
|
||||||
hx-target={ "#item-" + item.ID }
|
"hx-patch": fmt.Sprintf("/app/spaces/%s/lists/%s/items/%s", spaceID, item.ListID, item.ID),
|
||||||
hx-swap="outerHTML"
|
"hx-target": "#item-" + item.ID,
|
||||||
class="checkbox"
|
"hx-swap": "outerHTML",
|
||||||
/>
|
},
|
||||||
|
})
|
||||||
<span class={ templ.KV("line-through text-muted-foreground", item.IsChecked) }>{ item.Name }</span>
|
<span class={ templ.KV("line-through text-muted-foreground", item.IsChecked) }>{ item.Name }</span>
|
||||||
<button
|
<button
|
||||||
hx-delete={ fmt.Sprintf("/app/spaces/%s/lists/%s/items/%s", spaceID, item.ListID, item.ID) }
|
hx-delete={ fmt.Sprintf("/app/spaces/%s/lists/%s/items/%s", spaceID, item.ListID, item.ID) }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue