diff --git a/go.mod b/go.mod index 7189a49..8a4624a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/gofs-cli/template go 1.23.5 require ( - github.com/a-h/templ v0.3.819 + github.com/a-h/templ v0.3.833 github.com/go-chi/chi/v5 v5.2.0 github.com/go-chi/cors v1.2.1 ) diff --git a/go.sum b/go.sum index e7ce977..eba5e03 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/a-h/templ v0.3.819 h1:KDJ5jTFN15FyJnmSmo2gNirIqt7hfvBD2VXVDTySckM= github.com/a-h/templ v0.3.819/go.mod h1:iDJKJktpttVKdWoTkRNNLcllRI+BlpopJc+8au3gOUo= +github.com/a-h/templ v0.3.833 h1:L/KOk/0VvVTBegtE0fp2RJQiBm7/52Zxv5fqlEHiQUU= +github.com/a-h/templ v0.3.833/go.mod h1:cAu4AiZhtJfBjMY0HASlyzvkrtjnHWPeEsyGK2YYmfk= github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0= github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= diff --git a/internal/server/routes.go b/internal/server/routes.go index 0d19465..d4fb8db 100644 --- a/internal/server/routes.go +++ b/internal/server/routes.go @@ -6,6 +6,7 @@ import ( "github.com/gofs-cli/template/internal/server/assets" "github.com/gofs-cli/template/internal/server/handlers" activesearch "github.com/gofs-cli/template/internal/ui/pages/active-search" + "github.com/gofs-cli/template/internal/ui/pages/animations" bulkupdate "github.com/gofs-cli/template/internal/ui/pages/bulk-update" clicktoedit "github.com/gofs-cli/template/internal/ui/pages/click-to-edit" clicktoload "github.com/gofs-cli/template/internal/ui/pages/click-to-load" @@ -56,6 +57,11 @@ func (s *Server) Routes() { routesMux.Handle("GET /active-search", activesearch.Index()) routesMux.Handle("POST /active-search/search", activesearch.Search()) + // animations example + routesMux.Handle("GET /animations", animations.Index()) + routesMux.Handle("GET /animations/colors", animations.Colors()) + routesMux.Handle("POST /animations/fade_in_demo", animations.FadeIn()) + routesMux.Handle("GET /modal", home.Modal()) routesMux.Handle("GET /page1", page1.Index()) diff --git a/internal/ui/components/header/header_templ.go b/internal/ui/components/header/header_templ.go index 667778e..c85fbca 100644 --- a/internal/ui/components/header/header_templ.go +++ b/internal/ui/components/header/header_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package header //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/components/modal/modal_templ.go b/internal/ui/components/modal/modal_templ.go index ca24252..334c6ac 100644 --- a/internal/ui/components/modal/modal_templ.go +++ b/internal/ui/components/modal/modal_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package modal //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/components/toast/toast_templ.go b/internal/ui/components/toast/toast_templ.go index 9a61b49..e5357cd 100644 --- a/internal/ui/components/toast/toast_templ.go +++ b/internal/ui/components/toast/toast_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package toast //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/index_templ.go b/internal/ui/index_templ.go index 2e008e8..cfdacc7 100644 --- a/internal/ui/index_templ.go +++ b/internal/ui/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package ui //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/active-search/index_templ.go b/internal/ui/pages/active-search/index_templ.go index b1f5dcb..4963657 100644 --- a/internal/ui/pages/active-search/index_templ.go +++ b/internal/ui/pages/active-search/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package activesearch //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/animations/handlers.go b/internal/ui/pages/animations/handlers.go new file mode 100644 index 0000000..37523c0 --- /dev/null +++ b/internal/ui/pages/animations/handlers.go @@ -0,0 +1,37 @@ +package animations + +import ( + "math/rand/v2" + "net/http" + + "github.com/a-h/templ" + "github.com/gofs-cli/template/internal/ui" + "github.com/gofs-cli/template/internal/ui/components/header" +) + +func Index() http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + templ.Handler(ui.IndexPage(layout(header.Header(), body()))).ServeHTTP(w, r) + }) +} + +func Colors() http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + colors := []string{ + "red", + "blue", + "green", + "orange", + "pink", + } + color := colors[rand.IntN(len(colors))] + + templ.Handler(newColor(color)).ServeHTTP(w, r) + }) +} + +func FadeIn() http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + templ.Handler(fadeIn()).ServeHTTP(w, r) + }) +} diff --git a/internal/ui/pages/animations/index.templ b/internal/ui/pages/animations/index.templ new file mode 100644 index 0000000..9bd84e3 --- /dev/null +++ b/internal/ui/pages/animations/index.templ @@ -0,0 +1,57 @@ +package animations + +import "fmt" + +css classLayout() { + display: grid; +} + +css smooth() { + transition: all 1s ease-in; +} + +templ layout(header, body templ.Component) { +
+
+ @header +
+
+ @body +
+
+} + +templ body() { +

Animations:

+

Color throb:

+
+ Color Swap Demo +
+ @fadeIn() +} + +templ newColor(color string) { +
+ Color Swap Demo +
+} + +templ fadeIn() { + + +} diff --git a/internal/ui/pages/animations/index_templ.go b/internal/ui/pages/animations/index_templ.go new file mode 100644 index 0000000..3c118d8 --- /dev/null +++ b/internal/ui/pages/animations/index_templ.go @@ -0,0 +1,240 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.833 +package animations + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import "fmt" + +func classLayout() templ.CSSClass { + templ_7745c5c3_CSSBuilder := templruntime.GetBuilder() + templ_7745c5c3_CSSBuilder.WriteString(`display:grid;`) + templ_7745c5c3_CSSID := templ.CSSID(`classLayout`, templ_7745c5c3_CSSBuilder.String()) + return templ.ComponentCSSClass{ + ID: templ_7745c5c3_CSSID, + Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`), + } +} + +func smooth() templ.CSSClass { + templ_7745c5c3_CSSBuilder := templruntime.GetBuilder() + templ_7745c5c3_CSSBuilder.WriteString(`transition:all 1s ease-in;`) + templ_7745c5c3_CSSID := templ.CSSID(`smooth`, templ_7745c5c3_CSSBuilder.String()) + return templ.ComponentCSSClass{ + ID: templ_7745c5c3_CSSID, + Class: templ.SafeCSS(`.` + templ_7745c5c3_CSSID + `{` + templ_7745c5c3_CSSBuilder.String() + `}`), + } +} + +func layout(header, body templ.Component) templ.Component { + 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + var templ_7745c5c3_Var2 = []any{classLayout()} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = header.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = body.Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func body() templ.Component { + 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "

Animations:

Color throb:

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 = []any{smooth()} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var5...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "
Color Swap Demo
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = fadeIn().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func newColor(color string) templ.Component { + 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + var templ_7745c5c3_Var8 = []any{smooth()} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var8...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "
Color Swap Demo
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func fadeIn() templ.Component { + 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 + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/internal/ui/pages/bulk-update/index_templ.go b/internal/ui/pages/bulk-update/index_templ.go index 401b48e..8bb3995 100644 --- a/internal/ui/pages/bulk-update/index_templ.go +++ b/internal/ui/pages/bulk-update/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package bulkupdate //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/click-to-edit/index_templ.go b/internal/ui/pages/click-to-edit/index_templ.go index a2274d7..4b123d8 100644 --- a/internal/ui/pages/click-to-edit/index_templ.go +++ b/internal/ui/pages/click-to-edit/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package clicktoedit //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/click-to-load/index_templ.go b/internal/ui/pages/click-to-load/index_templ.go index 5ad702b..8ba365c 100644 --- a/internal/ui/pages/click-to-load/index_templ.go +++ b/internal/ui/pages/click-to-load/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package clicktoload //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/delete-row/index_templ.go b/internal/ui/pages/delete-row/index_templ.go index 05a2716..d6f13cb 100644 --- a/internal/ui/pages/delete-row/index_templ.go +++ b/internal/ui/pages/delete-row/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package deleterow //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/home/index_templ.go b/internal/ui/pages/home/index_templ.go index 00a2af3..8349b6f 100644 --- a/internal/ui/pages/home/index_templ.go +++ b/internal/ui/pages/home/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package home //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/inline-validation/index_templ.go b/internal/ui/pages/inline-validation/index_templ.go index a565cc3..f11d5da 100644 --- a/internal/ui/pages/inline-validation/index_templ.go +++ b/internal/ui/pages/inline-validation/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package inlinevalidation //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/notfound/notfound_templ.go b/internal/ui/pages/notfound/notfound_templ.go index 2725743..9c86135 100644 --- a/internal/ui/pages/notfound/notfound_templ.go +++ b/internal/ui/pages/notfound/notfound_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package notfound //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/page1/index_templ.go b/internal/ui/pages/page1/index_templ.go index 7cc9b7d..ac07218 100644 --- a/internal/ui/pages/page1/index_templ.go +++ b/internal/ui/pages/page1/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package page1 //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/page2/index_templ.go b/internal/ui/pages/page2/index_templ.go index 2120bc4..8db5163 100644 --- a/internal/ui/pages/page2/index_templ.go +++ b/internal/ui/pages/page2/index_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package page2 //lint:file-ignore SA4006 This context is only used if a nested component is present. diff --git a/internal/ui/pages/validation/inline_templ.go b/internal/ui/pages/validation/inline_templ.go index 90ad1c7..64b1f72 100644 --- a/internal/ui/pages/validation/inline_templ.go +++ b/internal/ui/pages/validation/inline_templ.go @@ -1,6 +1,6 @@ // Code generated by templ - DO NOT EDIT. -// templ: version: v0.3.819 +// templ: version: v0.3.833 package validation //lint:file-ignore SA4006 This context is only used if a nested component is present.