feat(ui): implement profile page

This commit is contained in:
Prad Nukala
2024-09-22 02:51:52 -04:00
parent df96e8d562
commit ee7c4531c2
31 changed files with 214 additions and 198 deletions
+23
View File
@@ -0,0 +1,23 @@
package pages
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
templ Home(c echo.Context) {
@blocks.Card("home-view", blocks.SizeLarge) {
@blocks.H1("Sonr.ID")
@blocks.Text("A Decentralized Web Node Client for the Sonr Network.")
@blocks.Spacer()
<div class="flex flex-col gap-3">
@blocks.Button(blocks.GET("/register", "#home-view"), blocks.PrimaryButtonStyle()) {
@blocks.Text("Get Started")
}
@blocks.Button(blocks.GET("/login", "#home-view")) {
@blocks.Text("Login")
}
</div>
@blocks.PoweredBySonr()
}
}
@@ -1,7 +1,7 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778
package views
package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -13,11 +13,7 @@ import (
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func HomeView(c echo.Context) error {
return echoComponentResponse(c, renderHomeView())
}
func renderHomeView() templ.Component {
func Home(c echo.Context) 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 {
+19
View File
@@ -0,0 +1,19 @@
package pages
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
templ Login(c echo.Context) {
@blocks.Card("login-view", blocks.SizeLarge) {
@blocks.H1("Sonr.ID")
@blocks.Text("Neo-tree is a file manager for NeoFS.")
@blocks.Spacer()
@blocks.RadioGroup()
@blocks.Spacer()
@blocks.Button(blocks.GET("/", "#login-view")) {
@blocks.Text("Cancel")
}
}
}
@@ -1,7 +1,7 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778
package views
package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -13,11 +13,7 @@ import (
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func LoginView(c echo.Context) error {
return echoComponentResponse(c, renderLoginView())
}
func renderLoginView() templ.Component {
func Login(c echo.Context) 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 {
+13
View File
@@ -0,0 +1,13 @@
package pages
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
templ Authorize(c echo.Context) {
@blocks.Card("authorize-view", blocks.SizeMedium) {
@blocks.H1("Sonr.ID")
@blocks.Text("Neo-tree is a file manager for NeoFS.")
}
}
@@ -1,7 +1,7 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778
package views
package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -13,11 +13,7 @@ import (
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func AuthorizeView(c echo.Context) error {
return echoComponentResponse(c, renderAuthorizeView())
}
func renderAuthorizeView() templ.Component {
func Authorize(c echo.Context) 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 {
+13
View File
@@ -0,0 +1,13 @@
package pages
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
templ Profile(c echo.Context) {
@blocks.Card("profile-view", blocks.SizeLarge) {
@blocks.ProfileCard()
@blocks.Tabs()
}
}
@@ -1,7 +1,7 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778
package views
package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -13,11 +13,7 @@ import (
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func ProfileView(c echo.Context) error {
return echoComponentResponse(c, renderProfileView())
}
func renderProfileView() templ.Component {
func Profile(c echo.Context) 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 {
+20
View File
@@ -0,0 +1,20 @@
package pages
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
"github.com/onsonr/sonr/pkg/nebula/islands"
)
templ Register(c echo.Context) {
@blocks.Card("register-view", blocks.SizeMedium) {
@blocks.H2("Account Registration")
@blocks.Spacer()
@blocks.Breadcrumbs()
@islands.BasicInfo(c, islands.InitialForm)
@blocks.Spacer()
@blocks.Button(blocks.GET("/", "#register-view")) {
@blocks.Text("Cancel")
}
}
}
@@ -1,7 +1,7 @@
// Code generated by templ - DO NOT EDIT.
// templ: version: v0.2.778
package views
package pages
//lint:file-ignore SA4006 This context is only used if a nested component is present.
@@ -14,11 +14,7 @@ import (
"github.com/onsonr/sonr/pkg/nebula/islands"
)
func RegisterView(c echo.Context) error {
return echoComponentResponse(c, renderRegisterView(c))
}
func renderRegisterView(c echo.Context) templ.Component {
func Register(c echo.Context) 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 {
+7 -6
View File
@@ -2,13 +2,14 @@ package nebula
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/views"
"github.com/onsonr/sonr/pkg/nebula/routes"
"github.com/onsonr/sonr/pkg/nebula/view"
)
func RouteViews(e *echo.Echo) {
e.GET("/home", views.HomeView)
e.GET("/login", views.LoginView)
e.GET("/register", views.RegisterView)
e.GET("/profile", views.ProfileView)
e.GET("/authorize", views.AuthorizeView)
e.GET("/home", view.Render(routes.HomeRoute))
e.GET("/login", view.Render(routes.LoginRoute))
e.GET("/register", view.Render(routes.RegisterRoute))
e.GET("/profile", view.Render(routes.ProfileRoute))
e.GET("/authorize", view.Render(routes.AuthorizeRoute))
}
+37
View File
@@ -0,0 +1,37 @@
package routes
import (
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/pages"
)
type Route string
const (
HomeRoute Route = "/home"
LoginRoute Route = "/login"
RegisterRoute Route = "/register"
ProfileRoute Route = "/profile"
AuthorizeRoute Route = "/authorize"
)
func (r Route) Route() string {
return string(r)
}
func (r Route) Component(c echo.Context) templ.Component {
switch r {
case HomeRoute:
return pages.Home(c)
case LoginRoute:
return pages.Login(c)
case RegisterRoute:
return pages.Register(c)
case ProfileRoute:
return pages.Profile(c)
case AuthorizeRoute:
return pages.Authorize(c)
}
return nil
}
+29
View File
@@ -0,0 +1,29 @@
package view
import (
"bytes"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/routes"
)
// render renders a templ.Component
func Render(r routes.Route) echo.HandlerFunc {
return func(c echo.Context) error {
// Create a buffer to store the rendered HTML
buf := bytes.NewBuffer(nil)
// Render the component to the buffer
err := r.Component(c).Render(c.Request().Context(), buf)
if err != nil {
return err
}
// Set the content type
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
// Write the buffered content to the response
_, err = c.Response().Write(buf.Bytes())
return err
}
}
-27
View File
@@ -1,27 +0,0 @@
package views
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func HomeView(c echo.Context) error {
return echoComponentResponse(c, renderHomeView())
}
templ renderHomeView() {
@blocks.Card("home-view", blocks.SizeLarge) {
@blocks.H1("Sonr.ID")
@blocks.Text("A Decentralized Web Node Client for the Sonr Network.")
@blocks.Spacer()
<div class="flex flex-col gap-3">
@blocks.Button(blocks.GET("/register", "#home-view"), blocks.PrimaryButtonStyle()) {
@blocks.Text("Get Started")
}
@blocks.Button(blocks.GET("/login", "#home-view")) {
@blocks.Text("Login")
}
</div>
@blocks.PoweredBySonr()
}
}
-24
View File
@@ -1,24 +0,0 @@
package views
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func LoginView(c echo.Context) error {
return echoComponentResponse(c, renderLoginView())
}
templ renderLoginView() {
@blocks.Card("login-view", blocks.SizeLarge) {
@blocks.H1("Sonr.ID")
@blocks.Text("Neo-tree is a file manager for NeoFS.")
@blocks.Spacer()
@blocks.RadioGroup()
@blocks.Spacer()
@blocks.Button(blocks.GET("/", "#login-view")) {
@blocks.Text("Cancel")
}
}
}
-18
View File
@@ -1,18 +0,0 @@
package views
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func AuthorizeView(c echo.Context) error {
return echoComponentResponse(c, renderAuthorizeView())
}
templ renderAuthorizeView() {
@blocks.Card("authorize-view", blocks.SizeMedium) {
@blocks.H1("Sonr.ID")
@blocks.Text("Neo-tree is a file manager for NeoFS.")
}
}
-18
View File
@@ -1,18 +0,0 @@
package views
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
)
func ProfileView(c echo.Context) error {
return echoComponentResponse(c, renderProfileView())
}
templ renderProfileView() {
@blocks.Card("profile-view", blocks.SizeLarge) {
@blocks.ProfileCard()
@blocks.Tabs()
}
}
-24
View File
@@ -1,24 +0,0 @@
package views
import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/blocks"
"github.com/onsonr/sonr/pkg/nebula/islands"
)
func RegisterView(c echo.Context) error {
return echoComponentResponse(c, renderRegisterView(c))
}
templ renderRegisterView(c echo.Context) {
@blocks.Card("register-view", blocks.SizeMedium) {
@blocks.H2("Account Registration")
@blocks.Spacer()
@blocks.Breadcrumbs()
@islands.BasicInfo(c, islands.InitialForm)
@blocks.Spacer()
@blocks.Button(blocks.GET("/", "#register-view")) {
@blocks.Text("Cancel")
}
}
}
-27
View File
@@ -1,27 +0,0 @@
package views
import (
"bytes"
"github.com/a-h/templ"
"github.com/labstack/echo/v4"
)
// render renders a templ.Component
func echoComponentResponse(c echo.Context, cmp templ.Component) error {
// Create a buffer to store the rendered HTML
buf := &bytes.Buffer{}
// Render the component to the buffer
err := cmp.Render(c.Request().Context(), buf)
if err != nil {
return err
}
// Set the content type
c.Response().Header().Set(echo.HeaderContentType, echo.MIMETextHTML)
// Write the buffered content to the response
_, err = c.Response().Write(buf.Bytes())
return err
}