Todo/pages/templates/root_templ.go

288 lines
14 KiB
Go
Raw Normal View History

2024-08-18 04:29:25 +00:00
// Code generated by templ - DO NOT EDIT.
2024-08-20 05:26:47 +00:00
// templ: version: v0.2.747
2024-08-18 04:29:25 +00:00
package templates
//lint:file-ignore SA4006 This context is only used if a nested component is present.
import "github.com/a-h/templ"
2024-08-20 05:26:47 +00:00
import templruntime "github.com/a-h/templ/runtime"
2024-08-18 04:29:25 +00:00
import (
"fmt"
"github.com/Cameron-Reed1/todo-web/types"
)
func RootPage() templ.Component {
2024-08-20 05:26:47 +00:00
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
2024-08-18 04:29:25 +00:00
if !templ_7745c5c3_IsBuffer {
2024-08-20 05:26:47 +00:00
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
2024-08-18 04:29:25 +00:00
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
if templ_7745c5c3_Var1 == nil {
templ_7745c5c3_Var1 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<!doctype HTML><html lang=\"en-US\"><head><title>Todo</title><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><link rel=\"stylesheet\" href=\"/css/styles.css\"><script src=\"/js/script.js\"></script><script src=\"/js/lib/htmx.min.js\"></script><!-- Font Awesome --><script src=\"https://kit.fontawesome.com/469cdddb31.js\" crossorigin=\"anonymous\"></script></head><body><nav><div id=\"nav-container\"><div id=\"nav-left\"><a id=\"new-button\" href=\"#create-item\">New</a></div><div id=\"nav-center\"></div><div id=\"nav-right\"></div></div></nav><div id=\"main-content\"><div id=\"lists\"><div id=\"overdue-list\" class=\"todo-list\"><div class=\"todo-list-title\">Overdue</div><div class=\"todo-list-items\" hx-get=\"/overdue\" hx-trigger=\"load\" hx-swap=\"outerHTML\"></div><div class=\"new-item\"></div></div><div id=\"today-list\" class=\"todo-list\"><div class=\"todo-list-title\">Today</div><div class=\"todo-list-items\" hx-get=\"/today\" hx-trigger=\"load\" hx-swap=\"outerHTML\"></div><div class=\"new-item\"></div></div><div id=\"upcoming-list\" class=\"todo-list\"><div class=\"todo-list-title\">Upcoming</div><div class=\"todo-list-items\" hx-get=\"/upcoming\" hx-trigger=\"load\" hx-swap=\"outerHTML\"></div><div class=\"new-item\"></div></div></div><form id=\"create-item\" hx-post=\"/new\" hx-swap=\"none\"><div class=\"form-title\">Create new Todo</div><div class=\"form-container\"><div class=\"form-column\"><label for=\"name\">Name</label><br><input id=\"create-item-name\" type=\"text\" name=\"name\"><br><label for=\"start\">Start</label><br><input id=\"create-item-start\" name=\"start\" type=\"datetime-local\"><br><label for=\"due\">Due</label><br><input id=\"create-item-due\" name=\"due\" type=\"datetime-local\"></div><div class=\"form-column\"></div></div><div class=\"form-button-container\"><button id=\"create-save\" class=\"form-save-button button\" type=\"submit\">Save</button> <a class=\"form-close-button button\" href=\"#\">Close</a></div></form><form id=\"edit-item\" data-id=\"\" hx-put=\"/update\" hx-swap=\"outerHTML\"><div class=\"form-title\">Edit Todo</div><div class=\"form-container\"><div class=\"form-column\"><label for=\"name\">Name</label><br><input id=\"edit-item-name\" type=\"text\" name=\"name\"><br><label for=\"start\">Start</label><br><input id=\"edit-item-start\" name=\"start\" type=\"datetime-local\"><br><label for=\"due\">Due</label><br><input id=\"edit-item-due\" name=\"due\" type=\"datetime-local\"></div><div class=\"form-column\"></div></div><div class=\"form-button-container\"><button id=\"edit-save\" class=\"form-save-button button\" type=\"submit\">Save</button> <a class=\"form-close-button button\" href=\"#\">Close</a></div></form></div></body></html>")
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
2024-08-20 05:26:47 +00:00
func edit(item_id string) templ.ComponentScript {
return templ.ComponentScript{
Name: `__templ_edit_2f09`,
Function: `function __templ_edit_2f09(item_id){edit(item_id)
}`,
Call: templ.SafeScript(`__templ_edit_2f09`, item_id),
CallInline: templ.SafeScriptInline(`__templ_edit_2f09`, item_id),
}
}
2024-08-18 04:29:25 +00:00
func TodoItem(item types.Todo) templ.Component {
2024-08-20 05:26:47 +00:00
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
2024-08-18 04:29:25 +00:00
if !templ_7745c5c3_IsBuffer {
2024-08-20 05:26:47 +00:00
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
2024-08-18 04:29:25 +00:00
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var2 := templ.GetChildren(ctx)
if templ_7745c5c3_Var2 == nil {
templ_7745c5c3_Var2 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div id=\"")
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
2024-08-20 05:26:47 +00:00
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("item-%d", item.Id))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 113, Col: 45}
2024-08-19 22:02:45 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"todo-item\" data-idnum=\"")
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
2024-08-20 05:26:47 +00:00
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", item.Id))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 113, Col: 105}
2024-08-19 22:02:45 +00:00
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" data-start=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", item.Start))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 113, Col: 150}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" data-due=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", item.Due))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 113, Col: 191}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-19 22:02:45 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><input type=\"checkbox\" name=\"completed\"")
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if item.Completed {
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" checked")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" hx-patch=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(string(templ.URL(fmt.Sprintf("/set/%d", item.Id))))
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 114, Col: 137}
2024-08-18 04:29:25 +00:00
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div class=\"todo-text\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(item.Text)
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 115, Col: 42}
2024-08-18 04:29:25 +00:00
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"todo-item-actions\"><i class=\"action-edit fa-solid fa-pencil\" onclick=\"edit(this.parentElement.parentElement.id)\"></i> <i class=\"action-delete fa-solid fa-trash\" hx-delete=\"")
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("/delete/%d", item.Id))
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 118, Col: 101}
2024-08-18 04:29:25 +00:00
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"closest .todo-item\" hx-swap=\"outerHTML\"></i></div></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
2024-08-19 22:02:45 +00:00
func OobTodoItem(targetSelector string, item types.Todo) templ.Component {
2024-08-20 05:26:47 +00:00
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
2024-08-18 04:29:25 +00:00
if !templ_7745c5c3_IsBuffer {
2024-08-20 05:26:47 +00:00
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
2024-08-18 04:29:25 +00:00
}
ctx = templ.InitializeContext(ctx)
2024-08-20 05:26:47 +00:00
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ.NopComponent
2024-08-18 04:29:25 +00:00
}
ctx = templ.ClearChildren(ctx)
2024-08-19 22:02:45 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div hx-swap-oob=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%s:%s", "afterend", targetSelector))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 124, Col: 71}
2024-08-19 22:02:45 +00:00
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = TodoItem(item).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}
func TodoList(fillerText string, items []types.Todo) templ.Component {
2024-08-20 05:26:47 +00:00
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
2024-08-19 22:02:45 +00:00
if !templ_7745c5c3_IsBuffer {
2024-08-20 05:26:47 +00:00
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
2024-08-19 22:02:45 +00:00
}
ctx = templ.InitializeContext(ctx)
2024-08-20 05:26:47 +00:00
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
if templ_7745c5c3_Var12 == nil {
templ_7745c5c3_Var12 = templ.NopComponent
2024-08-19 22:02:45 +00:00
}
ctx = templ.ClearChildren(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"todo-list-items\" data-item-count=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", len(items)))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 130, Col: 80}
2024-08-19 22:02:45 +00:00
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"><div class=\"filler-item\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-08-20 05:26:47 +00:00
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fillerText)
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
2024-08-20 05:26:47 +00:00
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pages/templates/root.templ`, Line: 131, Col: 45}
2024-08-19 22:02:45 +00:00
}
2024-08-20 05:26:47 +00:00
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
2024-08-19 22:02:45 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
2024-08-18 04:29:25 +00:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, item := range items {
templ_7745c5c3_Err = TodoItem(item).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
})
}