feat: introduce Home model and refactor views

This commit is contained in:
Prad Nukala 2024-10-02 20:23:28 -04:00
parent 8d8935c045
commit 42c5ab642e
17 changed files with 154 additions and 44 deletions

View File

@ -1,6 +1,6 @@
package home package home
templ MarketingFooter() { templ Footer() {
<!-- Site footer --> <!-- Site footer -->
<footer> <footer>
<div class="max-w-5xl mx-auto px-4 sm:px-6"> <div class="max-w-5xl mx-auto px-4 sm:px-6">

View File

@ -8,7 +8,7 @@ package home
import "github.com/a-h/templ" import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime" import templruntime "github.com/a-h/templ/runtime"
func MarketingFooter() templ.Component { func Footer() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 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 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {

View File

@ -1,6 +1,6 @@
package home package home
templ MarketingHeader() { templ Header() {
<!-- Site header --> <!-- Site header -->
<header class="absolute top-2 md:top-6 w-full z-30"> <header class="absolute top-2 md:top-6 w-full z-30">
<div class="px-4 sm:px-6"> <div class="px-4 sm:px-6">

View File

@ -8,7 +8,7 @@ package home
import "github.com/a-h/templ" import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime" import templruntime "github.com/a-h/templ/runtime"
func MarketingHeader() templ.Component { func Header() templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 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 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {

View File

@ -5,15 +5,15 @@ import (
"github.com/onsonr/sonr/pkg/nebula/models" "github.com/onsonr/sonr/pkg/nebula/models"
) )
templ View(hero *models.Hero) { templ View(home *models.Home) {
@blocks.LayoutNoBody("Sonr.ID", true) { @blocks.LayoutNoBody("Sonr.ID", true) {
@MarketingHeader() @Header()
@SectionHero(hero) @SectionHero(home.Hero)
@Highlights() @Highlights()
@Features() @Features()
@Bento() @Bento()
@Lowlights() @Lowlights()
@CallToAction() @CallToAction()
@MarketingFooter() @Footer()
} }
} }

View File

@ -13,7 +13,7 @@ import (
"github.com/onsonr/sonr/pkg/nebula/models" "github.com/onsonr/sonr/pkg/nebula/models"
) )
func View(hero *models.Hero) templ.Component { func View(home *models.Home) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { 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 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@ -46,7 +46,7 @@ func View(hero *models.Hero) templ.Component {
}() }()
} }
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = MarketingHeader().Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = Header().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -54,7 +54,7 @@ func View(hero *models.Hero) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = SectionHero(hero).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = SectionHero(home.Hero).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@ -102,7 +102,7 @@ func View(hero *models.Hero) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = MarketingFooter().Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = Footer().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }

View File

@ -0,0 +1,12 @@
// Code generated from Pkl module `models`. DO NOT EDIT.
package models
type Bento struct {
Title string `pkl:"title"`
Description string `pkl:"description"`
PrimaryButton *Button `pkl:"primaryButton"`
SecondaryButton *Button `pkl:"secondaryButton"`
}

View File

@ -0,0 +1,12 @@
// Code generated from Pkl module `models`. DO NOT EDIT.
package models
type CallToAction struct {
Title string `pkl:"title"`
Description string `pkl:"description"`
PrimaryButton *Button `pkl:"primaryButton"`
SecondaryButton *Button `pkl:"secondaryButton"`
}

View File

@ -0,0 +1,10 @@
// Code generated from Pkl module `models`. DO NOT EDIT.
package models
type Features struct {
Title string `pkl:"title"`
Description string `pkl:"description"`
Image *Image `pkl:"image"`
}

View File

@ -15,4 +15,6 @@ type Hero struct {
SecondaryButton *Button `pkl:"secondaryButton"` SecondaryButton *Button `pkl:"secondaryButton"`
Image *Image `pkl:"image"` Image *Image `pkl:"image"`
Stats []*Stat `pkl:"stats"`
} }

View File

@ -0,0 +1,10 @@
// Code generated from Pkl module `models`. DO NOT EDIT.
package models
type Highlights struct {
Title string `pkl:"title"`
Description string `pkl:"description"`
Image *Image `pkl:"image"`
}

View File

@ -3,6 +3,4 @@ package models
type Home struct { type Home struct {
Hero *Hero `pkl:"hero"` Hero *Hero `pkl:"hero"`
Stats *Stats `pkl:"stats"`
} }

View File

@ -0,0 +1,10 @@
// Code generated from Pkl module `models`. DO NOT EDIT.
package models
type Lowlights struct {
Title string `pkl:"title"`
Description string `pkl:"description"`
Image *Image `pkl:"image"`
}

View File

@ -9,10 +9,15 @@ func init() {
pkl.RegisterMapping("models#Hero", Hero{}) pkl.RegisterMapping("models#Hero", Hero{})
pkl.RegisterMapping("models#Button", Button{}) pkl.RegisterMapping("models#Button", Button{})
pkl.RegisterMapping("models#Image", Image{}) pkl.RegisterMapping("models#Image", Image{})
pkl.RegisterMapping("models#Stats", Stats{}) pkl.RegisterMapping("models#Stat", Stat{})
pkl.RegisterMapping("models#Link", Link{}) pkl.RegisterMapping("models#Link", Link{})
pkl.RegisterMapping("models#SocialLink", SocialLink{}) pkl.RegisterMapping("models#SocialLink", SocialLink{})
pkl.RegisterMapping("models#Input", Input{}) pkl.RegisterMapping("models#Input", Input{})
pkl.RegisterMapping("models#Highlights", Highlights{})
pkl.RegisterMapping("models#Features", Features{})
pkl.RegisterMapping("models#Bento", Bento{})
pkl.RegisterMapping("models#Lowlights", Lowlights{})
pkl.RegisterMapping("models#CallToAction", CallToAction{})
pkl.RegisterMapping("models#Footer", Footer{}) pkl.RegisterMapping("models#Footer", Footer{})
pkl.RegisterMapping("models#RegistrationForm", RegistrationForm{}) pkl.RegisterMapping("models#RegistrationForm", RegistrationForm{})
} }

View File

@ -1,5 +1,6 @@
amends "https://pkl.sh/uiux.pkl"; amends "https://pkl.sh/uiux.pkl";
home = new Home {
hero = new Hero { hero = new Hero {
titleFirst = "Simplified"; titleFirst = "Simplified";
titleEmphasis = "self-custody"; titleEmphasis = "self-custody";
@ -18,18 +19,19 @@ hero = new Hero {
width = "500"; width = "500";
height = "500"; height = "500";
}; };
stats {
new Stat {
value = "476K";
label = "Assets packed with power beyond your imagination.";
};
new Stat {
value = "1.44K";
label = "Assets packed with power beyond your imagination.";
};
new Stat {
value = "1.5M+";
label = "Assets packed with power beyond your imagination.";
}
}; };
stats = new Stats {
firstValue = "476K";
firstLabel = "Assets packed with power beyond your imagination.";
secondValue = "1.44K";
secondLabel = "Assets packed with power beyond your imagination.";
thirdValue = "1.5M+";
thirdLabel = "Assets packed with power beyond your imagination.";
}; };
home = new Home {
hero = hero;
stats = stats;
}; };

View File

@ -12,5 +12,5 @@ func Home(c echo.Context) error {
if err != nil { if err != nil {
return err return err
} }
return echoResponse(c, home.View(mdls.Home.Hero)) return echoResponse(c, home.View(mdls.Home))
} }

View File

@ -5,7 +5,7 @@ module models
import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl" import "package://pkg.pkl-lang.org/pkl-go/pkl.golang@0.5.0#/go.pkl"
// ╭───────────────────────────────────────────────────────────╮ // ╭───────────────────────────────────────────────────────────╮
// │ General Components // │ General State
// ╰───────────────────────────────────────────────────────────╯ // ╰───────────────────────────────────────────────────────────╯
typealias FormState = "initial" | "error" | "success" | "warning" typealias FormState = "initial" | "error" | "success" | "warning"
@ -42,18 +42,24 @@ class Input {
} }
// ╭───────────────────────────────────────────────────────────╮ // ╭───────────────────────────────────────────────────────────╮
// │ Homepage Components // │ Data Models
// ╰───────────────────────────────────────────────────────────╯ // ╰───────────────────────────────────────────────────────────╯
class Stats { class Highlight {
firstValue: String title: String
firstLabel: String description: String
secondValue: String image: Image
secondLabel: String
thirdValue: String
thirdLabel: String
} }
class Stat {
value: String
label: String
}
// ╭───────────────────────────────────────────────────────────╮
// │ Homepage View Model │
// ╰───────────────────────────────────────────────────────────╯
class Hero { class Hero {
titleFirst: String titleFirst: String
titleEmphasis: String titleEmphasis: String
@ -62,6 +68,39 @@ class Hero {
primaryButton: Button primaryButton: Button
secondaryButton: Button secondaryButton: Button
image: Image image: Image
stats: Listing<Stat>
}
class Highlights {
title: String
description: String
image: Image
}
class Features {
title: String
description: String
image: Image
}
class Bento {
title: String
description: String
primaryButton: Button
secondaryButton: Button
}
class Lowlights {
title: String
description: String
image: Image
}
class CallToAction {
title: String
description: String
primaryButton: Button
secondaryButton: Button
} }
class Footer { class Footer {
@ -70,19 +109,17 @@ class Footer {
twitterLink: SocialLink twitterLink: SocialLink
discordLink: SocialLink discordLink: SocialLink
githubLink: SocialLink githubLink: SocialLink
companyLinks: List<Link> companyLinks: Listing<Link>
resourcesLinks: List<Link> resourcesLinks: Listing<Link>
} }
class Home { class Home {
hero: Hero hero: Hero
stats: Stats
} }
home : Home
// ╭───────────────────────────────────────────────────────────╮ // ╭───────────────────────────────────────────────────────────╮
// │ Registration Components // │ Registration View Model
// ╰───────────────────────────────────────────────────────────╯ // ╰───────────────────────────────────────────────────────────╯
class RegistrationForm { class RegistrationForm {
@ -92,3 +129,15 @@ class RegistrationForm {
inputs: List<Input> inputs: List<Input>
} }
// ╭───────────────────────────────────────────────────────────╮
// │ Login View Model │
// ╰───────────────────────────────────────────────────────────╯
// ╭───────────────────────────────────────────────────────────╮
// │ FINAL INPUTS │
// ╰───────────────────────────────────────────────────────────╯
// Pages
home : Home