Added Wails3/HTMX example GUI

This commit is contained in:
2024-11-05 05:17:27 -07:00
parent d99293dba1
commit 90a87af526
31 changed files with 1481 additions and 47 deletions

40
desktop/pages/HomePage.go Normal file
View File

@ -0,0 +1,40 @@
package pages
import (
h "git.codemonkeysoftware.net/b/hatmill"
a "git.codemonkeysoftware.net/b/hatmill/attribute"
e "git.codemonkeysoftware.net/b/hatmill/element"
)
func hxGet(url string) h.Attrib {
return h.Attrib{
Key: "hx-get",
Value: a.String(url),
}
}
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.Button(
a.Type("button"),
hxGet("/hello"),
hxTrigger("click"),
hxTarget("#hello"),
)(h.Text("Click Here!")),
e.Div(a.Id("hello"))(),
)
}

26
desktop/pages/Page.go Normal file
View File

@ -0,0 +1,26 @@
package pages
import (
h "git.codemonkeysoftware.net/b/hatmill"
a "git.codemonkeysoftware.net/b/hatmill/attribute"
e "git.codemonkeysoftware.net/b/hatmill/element"
)
func Head() h.ParentElement {
return e.Head()(
e.Meta(a.Charset("utf-8")),
e.Meta(a.Name("viewport"), a.Content("width=device-width, initial-scale=1")),
e.Title()(h.Text("Peachy")),
e.Link(a.Rel("stylesheet"), a.Href("/static/css/main.css")),
e.Script(a.Src("/static/js/htmx-2.0.3.min.js"))(), // TODO change to pack it with the app
)
}
func Page[T h.Term](contents func() T) h.ParentElement {
return e.Html()(
Head(),
e.Body()(
contents(),
),
)
}