mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
refactor: reorganize pkl files for better separation of concerns
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package home
|
||||
|
||||
import "github.com/onsonr/sonr/pkg/nebula/models"
|
||||
import (
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/ui"
|
||||
"github.com/onsonr/sonr/pkg/nebula/models"
|
||||
)
|
||||
|
||||
templ SectionHero(hero *models.Hero) {
|
||||
<!-- Hero -->
|
||||
@@ -24,12 +27,8 @@ templ SectionHero(hero *models.Hero) {
|
||||
{ hero.Subtitle }
|
||||
</p>
|
||||
<div class="max-w-xs mx-auto sm:max-w-none sm:inline-flex sm:justify-center space-y-4 sm:space-y-0 sm:space-x-4">
|
||||
<div>
|
||||
<div class="btn cursor-pointer text-zinc-100 bg-zinc-900 hover:bg-zinc-800 w-full shadow" hx-swap="afterend" hx-get={ hero.PrimaryButton.Href }>{ hero.PrimaryButton.Text }</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="btn cursor-pointer text-zinc-600 bg-white hover:text-zinc-900 w-full shadow" hx-swap="afterend" hx-get={ hero.SecondaryButton.Href }>{ hero.SecondaryButton.Text }</div>
|
||||
</div>
|
||||
@ui.PrimaryButton(hero.PrimaryButton.Href, hero.PrimaryButton.Text)
|
||||
@ui.SecondaryButton(hero.SecondaryButton.Href, hero.SecondaryButton.Text)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
package register
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/blocks"
|
||||
"github.com/onsonr/sonr/pkg/nebula/models/formstate"
|
||||
)
|
||||
|
||||
templ View(c echo.Context) {
|
||||
@blocks.Layout("Sonr.ID", true) {
|
||||
@blocks.Card("register-view", blocks.SizeMedium) {
|
||||
@blocks.Spacer()
|
||||
@blocks.Breadcrumbs()
|
||||
@basicInfoForm(formstate.Initial)
|
||||
@blocks.Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templ basicInfoForm(state formstate.FormState) {
|
||||
switch (state) {
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package ui
|
||||
|
||||
templ PrimaryButton(href string, text string) {
|
||||
<div>
|
||||
<div class="btn cursor-pointer text-zinc-100 bg-zinc-900 hover:bg-zinc-800 w-full shadow" hx-swap="afterend" hx-get={ href }>{ text }</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
templ SecondaryButton(href string, text string) {
|
||||
<div>
|
||||
<div class="btn cursor-pointer text-zinc-600 bg-white hover:text-zinc-900 w-full shadow" hx-swap="afterend" hx-get={ href }>{ text }</div>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Feature struct {
|
||||
Title string `pkl:"title"`
|
||||
|
||||
Description string `pkl:"description"`
|
||||
|
||||
Icon string `pkl:"icon"`
|
||||
|
||||
Image *Image `pkl:"image"`
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type Form interface {
|
||||
GetTitle() string
|
||||
|
||||
GetDescription() string
|
||||
|
||||
GetInputs() []*Input
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
package models
|
||||
|
||||
type Highlights struct {
|
||||
Title string `pkl:"title"`
|
||||
Heading string `pkl:"heading"`
|
||||
|
||||
Description string `pkl:"description"`
|
||||
Subheading string `pkl:"subheading"`
|
||||
|
||||
Image *Image `pkl:"image"`
|
||||
Highlights []*Highlight `pkl:"highlights"`
|
||||
}
|
||||
|
||||
@@ -3,4 +3,16 @@ package models
|
||||
|
||||
type Home struct {
|
||||
Hero *Hero `pkl:"hero"`
|
||||
|
||||
Highlights []*Highlight `pkl:"highlights"`
|
||||
|
||||
Features []*Features `pkl:"features"`
|
||||
|
||||
Bento *Bento `pkl:"bento"`
|
||||
|
||||
Lowlights []*Lowlights `pkl:"lowlights"`
|
||||
|
||||
CallToAction *CallToAction `pkl:"callToAction"`
|
||||
|
||||
Footer *Footer `pkl:"footer"`
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
import "github.com/onsonr/sonr/pkg/nebula/models/inputtype"
|
||||
|
||||
type Input struct {
|
||||
Label string `pkl:"label"`
|
||||
|
||||
Type string `pkl:"type"`
|
||||
Type inputtype.InputType `pkl:"type"`
|
||||
|
||||
Placeholder string `pkl:"placeholder"`
|
||||
|
||||
@@ -14,5 +16,5 @@ type Input struct {
|
||||
|
||||
Help *string `pkl:"help"`
|
||||
|
||||
Required bool `pkl:"required"`
|
||||
Required *bool `pkl:"required"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package models
|
||||
|
||||
type RegisterFormData interface {
|
||||
Form
|
||||
}
|
||||
|
||||
var _ RegisterFormData = (*RegisterFormDataImpl)(nil)
|
||||
|
||||
type RegisterFormDataImpl struct {
|
||||
Title string `pkl:"title"`
|
||||
|
||||
Description string `pkl:"description"`
|
||||
|
||||
Inputs []*Input `pkl:"inputs"`
|
||||
}
|
||||
|
||||
func (rcv *RegisterFormDataImpl) GetTitle() string {
|
||||
return rcv.Title
|
||||
}
|
||||
|
||||
func (rcv *RegisterFormDataImpl) GetDescription() string {
|
||||
return rcv.Description
|
||||
}
|
||||
|
||||
func (rcv *RegisterFormDataImpl) GetInputs() []*Input {
|
||||
return rcv.Inputs
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
// 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
|
||||
}
|
||||
@@ -10,15 +10,15 @@ func init() {
|
||||
pkl.RegisterMapping("models#Button", Button{})
|
||||
pkl.RegisterMapping("models#Image", Image{})
|
||||
pkl.RegisterMapping("models#Stat", Stat{})
|
||||
pkl.RegisterMapping("models#Link", Link{})
|
||||
pkl.RegisterMapping("models#SocialLink", SocialLink{})
|
||||
pkl.RegisterMapping("models#Input", Input{})
|
||||
pkl.RegisterMapping("models#Highlight", Highlight{})
|
||||
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#RegistrationForm", RegistrationForm{})
|
||||
pkl.RegisterMapping("models#SocialLink", SocialLink{})
|
||||
pkl.RegisterMapping("models#Link", Link{})
|
||||
pkl.RegisterMapping("models#Input", Input{})
|
||||
pkl.RegisterMapping("models#Feature", Feature{})
|
||||
pkl.RegisterMapping("models#Highlights", Highlights{})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// Code generated from Pkl module `models`. DO NOT EDIT.
|
||||
package inputtype
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type InputType string
|
||||
|
||||
const (
|
||||
Text InputType = "text"
|
||||
Password InputType = "password"
|
||||
Email InputType = "email"
|
||||
Credential InputType = "credential"
|
||||
File InputType = "file"
|
||||
)
|
||||
|
||||
// String returns the string representation of InputType
|
||||
func (rcv InputType) String() string {
|
||||
return string(rcv)
|
||||
}
|
||||
|
||||
var _ encoding.BinaryUnmarshaler = new(InputType)
|
||||
|
||||
// UnmarshalBinary implements encoding.BinaryUnmarshaler for InputType.
|
||||
func (rcv *InputType) UnmarshalBinary(data []byte) error {
|
||||
switch str := string(data); str {
|
||||
case "text":
|
||||
*rcv = Text
|
||||
case "password":
|
||||
*rcv = Password
|
||||
case "email":
|
||||
*rcv = Email
|
||||
case "credential":
|
||||
*rcv = Credential
|
||||
case "file":
|
||||
*rcv = File
|
||||
default:
|
||||
return fmt.Errorf(`illegal: "%s" is not a valid InputType`, str)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
+197
-1
@@ -1,6 +1,8 @@
|
||||
amends "https://pkl.sh/uiux.pkl";
|
||||
amends "https://pkl.sh/UIUX.pkl";
|
||||
|
||||
home = new Home {
|
||||
|
||||
// Hero
|
||||
hero = new Hero {
|
||||
titleFirst = "Simplified";
|
||||
titleEmphasis = "self-custody";
|
||||
@@ -34,4 +36,198 @@ home = new Home {
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// Highlights
|
||||
highlights {
|
||||
new Highlight {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/highlight-1.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
new Highlight {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/highlight-2.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Features
|
||||
features {
|
||||
new Features {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/feature-1.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
new Features {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/feature-2.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
new Features {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/feature-3.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Bento
|
||||
bento = new Bento {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
primaryButton = new Button {
|
||||
text = "Get Started";
|
||||
href = "/register";
|
||||
};
|
||||
secondaryButton = new Button {
|
||||
text = "Learn More";
|
||||
href = "/about";
|
||||
};
|
||||
};
|
||||
|
||||
// Lowlights
|
||||
lowlights {
|
||||
new Lowlights {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/lowlight-1.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
new Lowlights {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
image = new Image {
|
||||
src = "https://cdn.sonr.id/img/lowlight-2.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// Call to Action
|
||||
callToAction = new CallToAction {
|
||||
title = "Simplified";
|
||||
description = "Sonr is a modern re-imagination of online user identity, empowering users to take ownership of their digital footprint and unlocking a new era of self-sovereignty.";
|
||||
primaryButton = new Button {
|
||||
text = "Get Started";
|
||||
href = "/register";
|
||||
};
|
||||
secondaryButton = new Button {
|
||||
text = "Learn More";
|
||||
href = "/about";
|
||||
};
|
||||
};
|
||||
|
||||
// Footer
|
||||
footer = new Footer {
|
||||
logo = new Image {
|
||||
src = "https://cdn.sonr.id/img/logo.svg";
|
||||
width = "500";
|
||||
height = "500";
|
||||
};
|
||||
|
||||
mediumLink = new SocialLink {
|
||||
link = new Link {
|
||||
text = "Medium";
|
||||
href = "https://medium.com/sonr-io";
|
||||
};
|
||||
icon = "https://cdn.sonr.id/img/medium.svg";
|
||||
};
|
||||
|
||||
twitterLink = new SocialLink {
|
||||
link = new Link {
|
||||
text = "Twitter";
|
||||
href = "https://twitter.com/sonr";
|
||||
};
|
||||
icon = "https://cdn.sonr.id/img/twitter.svg";
|
||||
};
|
||||
|
||||
discordLink = new SocialLink {
|
||||
link = new Link {
|
||||
text = "Discord";
|
||||
href = "https://discord.com/invite/sonr";
|
||||
};
|
||||
icon = "https://cdn.sonr.id/img/discord.svg";
|
||||
};
|
||||
|
||||
githubLink = new SocialLink {
|
||||
link = new Link {
|
||||
text = "GitHub";
|
||||
href = "https://github.com/sonr-io";
|
||||
};
|
||||
icon = "https://cdn.sonr.id/img/github.svg";
|
||||
};
|
||||
|
||||
companyLinks {
|
||||
new Link {
|
||||
text = "About";
|
||||
href = "https://sonr.io/about";
|
||||
};
|
||||
new Link {
|
||||
text = "Careers";
|
||||
href = "https://sonr.io/careers";
|
||||
};
|
||||
new Link {
|
||||
text = "Partners";
|
||||
href = "https://sonr.io/partners";
|
||||
};
|
||||
new Link {
|
||||
text = "Investors";
|
||||
href = "https://sonr.io/investors";
|
||||
};
|
||||
new Link {
|
||||
text = "Newsroom";
|
||||
href = "https://sonr.io/newsroom";
|
||||
};
|
||||
new Link {
|
||||
text = "Blog";
|
||||
href = "https://sonr.io/blog";
|
||||
};
|
||||
};
|
||||
|
||||
resourcesLinks {
|
||||
new Link {
|
||||
text = "Docs";
|
||||
href = "https://docs.sonr.io";
|
||||
};
|
||||
new Link {
|
||||
text = "Whitepaper";
|
||||
href = "https://sonr.io/whitepaper";
|
||||
};
|
||||
new Link {
|
||||
text = "FAQ";
|
||||
href = "https://sonr.io/faq";
|
||||
};
|
||||
new Link {
|
||||
text = "Terms of Service";
|
||||
href = "https://sonr.io/terms";
|
||||
};
|
||||
new Link {
|
||||
text = "Privacy Policy";
|
||||
href = "https://sonr.io/privacy";
|
||||
};
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/grant"
|
||||
)
|
||||
|
||||
func Authorize(c echo.Context) error {
|
||||
return echoResponse(c, grant.View(c))
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/home"
|
||||
"github.com/onsonr/sonr/pkg/nebula/models"
|
||||
)
|
||||
|
||||
func Home(c echo.Context) error {
|
||||
mdls, err := models.GetModels()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return echoResponse(c, home.View(mdls.Home))
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/login"
|
||||
)
|
||||
|
||||
func Login(c echo.Context) error {
|
||||
return echoResponse(c, login.Modal(c))
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/grant"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/home"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/login"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/profile"
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/register"
|
||||
"github.com/onsonr/sonr/pkg/nebula/models"
|
||||
)
|
||||
|
||||
func Authorize(c echo.Context) error {
|
||||
return echoResponse(c, grant.View(c))
|
||||
}
|
||||
|
||||
func Home(c echo.Context) error {
|
||||
mdls, err := models.GetModels()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return echoResponse(c, home.View(mdls.Home))
|
||||
}
|
||||
|
||||
func Login(c echo.Context) error {
|
||||
return echoResponse(c, login.Modal(c))
|
||||
}
|
||||
|
||||
func Profile(c echo.Context) error {
|
||||
return echoResponse(c, profile.View(c))
|
||||
}
|
||||
|
||||
func Register(c echo.Context) error {
|
||||
return echoResponse(c, register.Modal(c))
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/profile"
|
||||
)
|
||||
|
||||
func Profile(c echo.Context) error {
|
||||
return echoResponse(c, profile.View(c))
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
"github.com/onsonr/sonr/pkg/nebula/components/register"
|
||||
)
|
||||
|
||||
func Register(c echo.Context) error {
|
||||
return echoResponse(c, register.Modal(c))
|
||||
}
|
||||
Reference in New Issue
Block a user