From 0a68ab682d65633e5cabd2a47b2ea328aa95c7f5 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Mon, 9 Dec 2024 21:45:52 -0500 Subject: [PATCH] feat: update create profile form placeholders and handle --- pkg/common/styles/forms/create_profile.templ | 6 +- .../styles/forms/create_profile_templ.go | 4 +- .../styles/forms/register_passkey.templ | 54 +++++ .../styles/forms/register_passkey_templ.go | 184 +++++++++++++++++- pkg/common/styles/forms/setup_wallet.templ | 46 ----- pkg/common/styles/forms/setup_wallet_templ.go | 87 --------- pkg/common/styles/layout/layout.templ | 2 +- pkg/common/styles/layout/layout_templ.go | 2 +- 8 files changed, 240 insertions(+), 145 deletions(-) delete mode 100644 pkg/common/styles/forms/setup_wallet.templ delete mode 100644 pkg/common/styles/forms/setup_wallet_templ.go diff --git a/pkg/common/styles/forms/create_profile.templ b/pkg/common/styles/forms/create_profile.templ index 8ff7e8b97..8320d4b55 100644 --- a/pkg/common/styles/forms/create_profile.templ +++ b/pkg/common/styles/forms/create_profile.templ @@ -25,11 +25,11 @@ templ CreateProfile(action string, method string, data CreateProfileData) { @layout.Rows() { - - + + } @layout.Spacer() - +
diff --git a/pkg/common/styles/forms/create_profile_templ.go b/pkg/common/styles/forms/create_profile_templ.go index 3e00e8f60..5a644dade 100644 --- a/pkg/common/styles/forms/create_profile_templ.go +++ b/pkg/common/styles/forms/create_profile_templ.go @@ -83,7 +83,7 @@ func CreateProfile(action string, method string, data CreateProfileData) templ.C }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -97,7 +97,7 @@ func CreateProfile(action string, method string, data CreateProfileData) templ.C if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/pkg/common/styles/forms/register_passkey.templ b/pkg/common/styles/forms/register_passkey.templ index b69b09e50..6550a7d35 100644 --- a/pkg/common/styles/forms/register_passkey.templ +++ b/pkg/common/styles/forms/register_passkey.templ @@ -17,6 +17,44 @@ templ RegisterPasskey(action, method string, data RegisterPasskeyData) { @sonrProfile(data.Address, data.Name, data.Handle, data.CreationBlock) + + @cryptoWalletOption("SNR", "Sonr", true) + @cryptoWalletOption("BTC", "Bitcoin", true) + @cryptoWalletOption("ETH", "Ethereum", true) + @cryptoWalletOption("SOL", "Solana", false) + @cryptoWalletOption("LTC", "Litecoin", false) + @cryptoWalletOption("DOGE", "Dogecoin", false) + @cryptoWalletOption("XRP", "Ripple", false) + @cryptoWalletOption("OSMO", "Osmosis", false) + @cryptoWalletOption("ATOM", "Cosmos", false) + @cryptoWalletOption("STARZ", "Stargaze", false) + @cryptoWalletOption("AKT", "Akash", false) + @cryptoWalletOption("EVMOS", "Evmos", false) + @cryptoWalletOption("FIL", "Filecoin", false) + @cryptoWalletOption("AXL", "Axelar", false) + +
@passkeyDropzone(data.Address, data.Handle, data.Challenge) @@ -155,6 +193,22 @@ templ sonrProfile(addr string, name string, handle string, creationBlock string)
} +templ cryptoWalletOption(ticker string, name string, isDefault bool) { + if isDefault { + + + { name } + + + } else { + + + { name } + + + } +} + // Helper function to shorten address func shortenAddress(address string) string { if len(address) <= 20 { diff --git a/pkg/common/styles/forms/register_passkey_templ.go b/pkg/common/styles/forms/register_passkey_templ.go index 6f2398dff..31ca66392 100644 --- a/pkg/common/styles/forms/register_passkey_templ.go +++ b/pkg/common/styles/forms/register_passkey_templ.go @@ -67,7 +67,67 @@ func RegisterPasskey(action, method string, data RegisterPasskeyData) templ.Comp if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("SNR", "Sonr", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("BTC", "Bitcoin", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("ETH", "Ethereum", true).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("SOL", "Solana", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("LTC", "Litecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("DOGE", "Dogecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("XRP", "Ripple", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("OSMO", "Osmosis", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("ATOM", "Cosmos", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("STARZ", "Stargaze", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("AKT", "Akash", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("EVMOS", "Evmos", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("FIL", "Filecoin", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cryptoWalletOption("AXL", "Axelar", false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -244,7 +304,7 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(handle) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 135, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 173, Col: 43} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -257,7 +317,7 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(shortenAddress(addr)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 142, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 180, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -270,7 +330,7 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(creationBlock) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 147, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 185, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -283,7 +343,7 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 151, Col: 32} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 189, Col: 32} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -297,6 +357,120 @@ func sonrProfile(addr string, name string, handle string, creationBlock string) }) } +func cryptoWalletOption(ticker string, name string, isDefault bool) 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) + if isDefault { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 200, Col: 9} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var17 string + templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/common/styles/forms/register_passkey.templ`, Line: 206, Col: 9} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + return templ_7745c5c3_Err + }) +} + // Helper function to shorten address func shortenAddress(address string) string { if len(address) <= 20 { diff --git a/pkg/common/styles/forms/setup_wallet.templ b/pkg/common/styles/forms/setup_wallet.templ deleted file mode 100644 index be5d4b274..000000000 --- a/pkg/common/styles/forms/setup_wallet.templ +++ /dev/null @@ -1,46 +0,0 @@ -package forms - -import "github.com/onsonr/sonr/pkg/common/styles/layout" - -type SetupWalletData struct { - TurnstileSiteKey string - FirstNumber int - LastNumber int -} - -// SetupWallet is a standard form styled like a card -templ SetupWallet(action string, method string, data CreateProfileData) { -
- -
-
- -
-
- @layout.Spacer() - -
- -
-
- @layout.Spacer() -
- - - Skip for now - - - Done - - -
- -
-
-} diff --git a/pkg/common/styles/forms/setup_wallet_templ.go b/pkg/common/styles/forms/setup_wallet_templ.go deleted file mode 100644 index 295ade535..000000000 --- a/pkg/common/styles/forms/setup_wallet_templ.go +++ /dev/null @@ -1,87 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.793 -package forms - -//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 "github.com/onsonr/sonr/pkg/common/styles/layout" - -type SetupWalletData struct { - TurnstileSiteKey string - FirstNumber int - LastNumber int -} - -// SetupWallet is a standard form styled like a card -func SetupWallet(action string, method string, data CreateProfileData) 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) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = layout.Spacer().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = layout.Spacer().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Skip for now Done
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/pkg/common/styles/layout/layout.templ b/pkg/common/styles/layout/layout.templ index f9b93f650..41a4213a6 100644 --- a/pkg/common/styles/layout/layout.templ +++ b/pkg/common/styles/layout/layout.templ @@ -27,7 +27,7 @@ var ( templ Root(title string) { - @Head(title, "0.0.10") + @Head(title, "0.0.11")
{ children... } diff --git a/pkg/common/styles/layout/layout_templ.go b/pkg/common/styles/layout/layout_templ.go index 58c09ca31..ba5bcc7de 100644 --- a/pkg/common/styles/layout/layout_templ.go +++ b/pkg/common/styles/layout/layout_templ.go @@ -57,7 +57,7 @@ func Root(title string) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = Head(title, "0.0.10").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = Head(title, "0.0.11").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }