htmgo/starter-template/pages/index.go

41 lines
845 B
Go
Raw Normal View History

2024-09-11 00:52:18 +00:00
package pages
import (
2024-09-17 17:13:22 +00:00
"github.com/labstack/echo/v4"
2024-09-14 00:05:55 +00:00
"github.com/maddalax/htmgo/framework/h"
2024-09-17 17:13:22 +00:00
"starter-template/pages/base"
"starter-template/partials"
2024-09-11 00:52:18 +00:00
)
2024-09-17 17:13:22 +00:00
func IndexPage(c echo.Context) *h.Page {
return h.NewPage(h.Html(
2024-09-17 17:13:22 +00:00
h.HxExtension(base.Extensions()),
2024-09-17 17:29:33 +00:00
h.Class("bg-red-200 flex flex-col items-center h-full w-full"),
h.Head(
h.Link("/public/main.css", "stylesheet"),
2024-09-14 00:05:55 +00:00
h.Script("/public/htmgo.js"),
),
h.Body(
h.Class("flex flex-col gap-4"),
h.Div(h.Class("flex gap-2 mt-6"),
Button(),
Button(),
Button(),
2024-09-17 18:35:44 +00:00
Button(),
),
),
))
2024-09-11 00:52:18 +00:00
}
func Button() h.Ren {
2024-09-17 17:29:33 +00:00
return h.Button(h.Class("btn bg-green-500 p-4 rounded text-white"),
h.Text("my button"),
h.AfterRequest(
h.SetDisabled(true),
h.RemoveClass("bg-red-600"),
h.AddClass("bg-gray-500"),
),
h.GetPartial(partials.SamplePartial),
)
}