Added Wails3/HTMX example GUI
This commit is contained in:
40
desktop/pages/HomePage.go
Normal file
40
desktop/pages/HomePage.go
Normal 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
26
desktop/pages/Page.go
Normal 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(),
|
||||
),
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user