Get and set site name
This commit is contained in:
@ -4,40 +4,37 @@ import (
|
||||
h "git.codemonkeysoftware.net/b/hatmill"
|
||||
a "git.codemonkeysoftware.net/b/hatmill/attribute"
|
||||
e "git.codemonkeysoftware.net/b/hatmill/element"
|
||||
"git.codemonkeysoftware.net/b/peachy-go"
|
||||
"git.codemonkeysoftware.net/b/peachy-go/desktop/fields"
|
||||
"git.codemonkeysoftware.net/b/peachy-go/hx"
|
||||
)
|
||||
|
||||
func hxGet(url string) h.Attrib {
|
||||
return h.Attrib{
|
||||
Key: "hx-get",
|
||||
Value: a.String(url),
|
||||
func HomePage(db *peachy.DB) (func() h.ParentElement, error) {
|
||||
siteName, err := db.SiteName()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
func hxTrigger(event string) h.Attrib {
|
||||
return h.Attrib{
|
||||
Key: "hx-trigger",
|
||||
Value: a.String(event),
|
||||
}
|
||||
}
|
||||
|
||||
func hxTarget(target string) h.Attrib {
|
||||
return h.Attrib{
|
||||
Key: "hx-target",
|
||||
Value: a.String(target),
|
||||
}
|
||||
}
|
||||
|
||||
func HomePage() h.ParentElement {
|
||||
return e.Div()(
|
||||
e.H1()(h.Text("[untitled]")),
|
||||
e.Button(
|
||||
a.Type("button"),
|
||||
hxGet("/hello"),
|
||||
hxTrigger("click"),
|
||||
hxTarget("#hello"),
|
||||
)(h.Text("Click Here!")),
|
||||
e.Div(a.Id("hello"))(),
|
||||
)
|
||||
return func() h.ParentElement {
|
||||
return e.Div()(
|
||||
e.Input(
|
||||
a.Type("text"),
|
||||
a.Value(siteName),
|
||||
a.Placeholder("site name"),
|
||||
a.Name(fields.SiteName),
|
||||
hx.Trigger("change"),
|
||||
hx.Target("this"),
|
||||
hx.Patch("/site"),
|
||||
hx.Swap(hx.OuterHTML),
|
||||
),
|
||||
e.Button(
|
||||
a.Type("button"),
|
||||
hx.Get("/hello"),
|
||||
hx.Trigger("click"),
|
||||
hx.Target("#hello"),
|
||||
)(h.Text("Click Here!")),
|
||||
e.Div(a.Id("hello"))(),
|
||||
)
|
||||
}, nil
|
||||
}
|
||||
|
||||
func Splash() h.Term {
|
||||
|
Reference in New Issue
Block a user