diff --git a/pkg/nebula/assets/config.pkl b/pkg/nebula/assets/config.pkl index 3d0a285ad..d8f6de5f5 100644 --- a/pkg/nebula/assets/config.pkl +++ b/pkg/nebula/assets/config.pkl @@ -16,7 +16,7 @@ hero = new Hero { image = new Image { src = "https://cdn.sonr.id/img/hero-clipped.svg"; width = "560"; - height = "560; + height = "560"; }; }; diff --git a/pkg/nebula/models/formstate/FormState.pkl.go b/pkg/nebula/models/formstate/FormState.pkl.go new file mode 100644 index 000000000..68199f2c1 --- /dev/null +++ b/pkg/nebula/models/formstate/FormState.pkl.go @@ -0,0 +1,40 @@ +// Code generated from Pkl module `models`. DO NOT EDIT. +package formstate + +import ( + "encoding" + "fmt" +) + +type FormState string + +const ( + Initial FormState = "initial" + Error FormState = "error" + Success FormState = "success" + Warning FormState = "warning" +) + +// String returns the string representation of FormState +func (rcv FormState) String() string { + return string(rcv) +} + +var _ encoding.BinaryUnmarshaler = new(FormState) + +// UnmarshalBinary implements encoding.BinaryUnmarshaler for FormState. +func (rcv *FormState) UnmarshalBinary(data []byte) error { + switch str := string(data); str { + case "initial": + *rcv = Initial + case "error": + *rcv = Error + case "success": + *rcv = Success + case "warning": + *rcv = Warning + default: + return fmt.Errorf(`illegal: "%s" is not a valid FormState`, str) + } + return nil +} diff --git a/pkg/nebula/nebula.go b/pkg/nebula/nebula.go index 518eac2db..617eeb43f 100644 --- a/pkg/nebula/nebula.go +++ b/pkg/nebula/nebula.go @@ -15,7 +15,7 @@ import ( var embeddedFiles embed.FS //go:embed assets/config.pkl -var config string +var config []byte func getHTTPFS() (http.FileSystem, error) { fsys, err := fs.Sub(embeddedFiles, "assets") @@ -27,7 +27,7 @@ func getHTTPFS() (http.FileSystem, error) { // UseAssets is a middleware that serves static files from the embedded assets func UseAssets(e *echo.Echo) error { - err := models.LoadFromString(context.Background(), config) + err := models.LoadFromString(context.Background(), string(config)) if err != nil { return err } @@ -38,5 +38,10 @@ func UseAssets(e *echo.Echo) error { assets := http.FileServer(fsys) e.GET("/", echo.WrapHandler(assets)) e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets))) + e.GET("/_nebula/config", handleGetConfig) return nil } + +func handleGetConfig(c echo.Context) error { + return c.Blob(http.StatusOK, "application/octet-stream", config) +} diff --git a/pkg/nebula/pages/register.templ b/pkg/nebula/pages/register.templ index 83c3c2120..7dbf62e14 100644 --- a/pkg/nebula/pages/register.templ +++ b/pkg/nebula/pages/register.templ @@ -3,15 +3,7 @@ package pages import ( "github.com/labstack/echo/v4" "github.com/onsonr/sonr/pkg/nebula/components/blocks" -) - -type FormState string - -const ( - InitialForm FormState = "initial" - ErrorForm FormState = "error" - SuccessForm FormState = "success" - WarningForm FormState = "warning" + "github.com/onsonr/sonr/pkg/nebula/models/formstate" ) func Register(c echo.Context) error { @@ -24,7 +16,7 @@ templ registerView(c echo.Context) { @blocks.H2("Account Registration") @blocks.Spacer() @blocks.Breadcrumbs() - @basicInfoForm(InitialForm) + @basicInfoForm(formstate.Initial) @blocks.Spacer() @blocks.Button(blocks.GET("/", "#register-view")) { @blocks.Text("Cancel") @@ -33,7 +25,7 @@ templ registerView(c echo.Context) { } } -templ basicInfoForm(state FormState) { +templ basicInfoForm(state formstate.FormState) { switch (state) { default:
diff --git a/pkg/nebula/pages/register_templ.go b/pkg/nebula/pages/register_templ.go index 6e53e51bc..a419fd775 100644 --- a/pkg/nebula/pages/register_templ.go +++ b/pkg/nebula/pages/register_templ.go @@ -11,15 +11,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/labstack/echo/v4" "github.com/onsonr/sonr/pkg/nebula/components/blocks" -) - -type FormState string - -const ( - InitialForm FormState = "initial" - ErrorForm FormState = "error" - SuccessForm FormState = "success" - WarningForm FormState = "warning" + "github.com/onsonr/sonr/pkg/nebula/models/formstate" ) func Register(c echo.Context) error { @@ -95,7 +87,7 @@ func registerView(c echo.Context) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = basicInfoForm(InitialForm).Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = basicInfoForm(formstate.Initial).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -149,7 +141,7 @@ func registerView(c echo.Context) templ.Component { }) } -func basicInfoForm(state FormState) templ.Component { +func basicInfoForm(state formstate.FormState) 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 { diff --git a/pkl/uiux.pkl b/pkl/uiux.pkl index b84fcdfa8..6198e8355 100644 --- a/pkl/uiux.pkl +++ b/pkl/uiux.pkl @@ -4,6 +4,8 @@ module models import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl" +typealias FormState = "initial" | "error" | "success" | "warning" + class Image { src: String width: String