Files
nebula/components/drawers_templ.go

565 lines
33 KiB
Go

// Code generated by templ - DO NOT EDIT.
// templ: version: v0.3.977
package components
//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"
// TokenOption represents a token choice in dropdowns
type TokenOption struct {
Symbol string
Name string
Balance string
Color string
Initials string
}
// DefaultTokenOptions returns the standard token options for drawers
func DefaultTokenOptions() []TokenOption {
return []TokenOption{
{Symbol: "SNR", Name: "Sonr", Balance: "8,432.50", Color: "linear-gradient(135deg, #17c2ff, #0090ff)", Initials: "S"},
{Symbol: "ETH", Name: "Ethereum", Balance: "2.847", Color: "#627eea", Initials: "E"},
{Symbol: "USDC", Name: "USD Coin", Balance: "1,250.00", Color: "#2775ca", Initials: "U"},
{Symbol: "AVAX", Name: "Avalanche", Balance: "24.83", Color: "#e84142", Initials: "A"},
}
}
// ReceiveDrawer component for receiving tokens
func ReceiveDrawer(tokens []TokenOption, walletAddress string) 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 = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<wa-drawer label=\"Receive\" placement=\"end\" class=\"drawer-receive\" style=\"--size: 400px;\" id=\"receive-drawer\"><div class=\"drawer-form\"><div class=\"drawer-form-content\"><div class=\"wa-stack wa-gap-l\"><wa-select label=\"Select Token\" value=\"snr\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, token := range tokens {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<wa-option value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(token.Symbol)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 30, Col: 38}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"><wa-avatar slot=\"prefix\" initials=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(token.Initials)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 31, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" style=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues("--size: 24px; background: " + token.Color + ";")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 31, Col: 117}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\"></wa-avatar> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var5 string
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(token.Symbol)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 32, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " - ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(token.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 32, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</wa-option>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</wa-select><div class=\"qr-container\"><wa-qr-code value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(walletAddress)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 37, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "\" size=\"180\" radius=\"0.5\"></wa-qr-code> <span class=\"wa-caption-s\" style=\"margin-top: var(--wa-space-m); color: var(--wa-color-neutral-500);\">Scan to receive tokens</span></div><div class=\"wa-stack wa-gap-xs\"><span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">Your Wallet Address</span><div class=\"address-display\"><span style=\"flex: 1;\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(walletAddress)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 43, Col: 45}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</span> <wa-copy-button value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(walletAddress)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 44, Col: 44}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\"></wa-copy-button></div></div><wa-callout variant=\"neutral\"><wa-icon slot=\"icon\" name=\"circle-info\"></wa-icon> Only send <strong>SNR</strong> tokens to this address. Sending other assets may result in permanent loss.</wa-callout></div></div><div class=\"wa-cluster wa-gap-s\" style=\"justify-content: flex-end;\"><wa-button variant=\"neutral\" appearance=\"outlined\" onclick=\"document.getElementById('receive-drawer').open = false\">Close</wa-button> <wa-button variant=\"brand\"><wa-icon slot=\"start\" name=\"share-nodes\"></wa-icon> Share Address</wa-button></div></div></wa-drawer>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = drawerStyles().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// SendDrawer component for sending tokens
func SendDrawer(tokens []TokenOption) 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_Var10 := templ.GetChildren(ctx)
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<wa-drawer label=\"Send\" placement=\"end\" class=\"drawer-send\" style=\"--size: 420px;\" id=\"send-drawer\"><div class=\"drawer-form\"><div class=\"drawer-form-content\"><div class=\"wa-stack wa-gap-l\"><wa-select label=\"From Token\" value=\"snr\" id=\"send-token-select\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, token := range tokens {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<wa-option value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 string
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(token.Symbol)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 73, Col: 38}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\"><wa-avatar slot=\"prefix\" initials=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(token.Initials)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 74, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\" style=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues("--size: 24px; background: " + token.Color + ";")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 74, Col: 117}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\"></wa-avatar> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(token.Symbol)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 75, Col: 22}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " - ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(token.Balance)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 75, Col: 42}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " available</wa-option>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</wa-select> <wa-input label=\"Recipient Address\" placeholder=\"sonr1... or ENS name\" clearable><wa-icon slot=\"prefix\" name=\"wallet\"></wa-icon> <wa-tooltip slot=\"suffix\" content=\"Paste from clipboard\"><wa-icon-button name=\"paste\" label=\"Paste\"></wa-icon-button></wa-tooltip></wa-input><div class=\"wa-stack wa-gap-xs\"><wa-input label=\"Amount\" type=\"number\" placeholder=\"0.00\" id=\"send-amount\"><span slot=\"suffix\" style=\"color: var(--wa-color-neutral-500);\">SNR</span></wa-input><div class=\"wa-flank\"><span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">≈ $0.00 USD</span> <wa-button size=\"small\" appearance=\"plain\" style=\"font-size: var(--wa-font-size-xs);\">MAX</wa-button></div></div><wa-textarea label=\"Memo (Optional)\" placeholder=\"Add a note to this transaction\" rows=\"2\"></wa-textarea> <wa-details summary=\"Gas Settings\"><div class=\"gas-settings\"><wa-radio-group label=\"Transaction Speed\" value=\"standard\" orientation=\"horizontal\"><wa-radio appearance=\"button\" value=\"slow\">Slow</wa-radio> <wa-radio appearance=\"button\" value=\"standard\">Standard</wa-radio> <wa-radio appearance=\"button\" value=\"fast\">Fast</wa-radio></wa-radio-group><div class=\"preview-row\" style=\"margin-top: var(--wa-space-m);\"><span class=\"label\">Estimated Gas</span> <span>~0.001 SNR ($0.05)</span></div></div></wa-details> <wa-divider></wa-divider><div class=\"wa-stack wa-gap-xs\"><div class=\"preview-row\"><span class=\"label\">Amount</span> <span>0.00 SNR</span></div><div class=\"preview-row\"><span class=\"label\">Network Fee</span> <span>~0.001 SNR</span></div><div class=\"preview-row\"><span class=\"label\" style=\"font-weight: 500;\">Total</span> <span style=\"font-weight: 500;\">0.001 SNR</span></div></div></div></div><div class=\"wa-cluster wa-gap-s\" style=\"justify-content: flex-end;\"><wa-button variant=\"neutral\" appearance=\"outlined\" onclick=\"document.getElementById('send-drawer').open = false\">Cancel</wa-button> <wa-button variant=\"brand\" id=\"send-confirm-btn\"><wa-icon slot=\"start\" name=\"paper-plane\"></wa-icon> Review Send</wa-button></div></div></wa-drawer>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = drawerStyles().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// SwapDrawer component for swapping tokens
func SwapDrawer(tokens []TokenOption) 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_Var16 := templ.GetChildren(ctx)
if templ_7745c5c3_Var16 == nil {
templ_7745c5c3_Var16 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<wa-drawer label=\"Swap Tokens\" placement=\"end\" class=\"drawer-swap\" style=\"--size: 440px;\" id=\"swap-drawer\"><div class=\"drawer-form\"><div class=\"drawer-form-content\"><div class=\"wa-stack wa-gap-m\"><!-- From Token Box --><div class=\"swap-token-box\"><div class=\"wa-flank\" style=\"margin-bottom: var(--wa-space-s);\"><span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">You Pay</span> <span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">Balance: 2.847 ETH</span></div><div class=\"wa-flank wa-gap-m\"><wa-input type=\"number\" placeholder=\"0.00\" style=\"flex: 1; --wa-input-border-color: transparent; --wa-input-background-color: transparent;\" id=\"swap-from-amount\"></wa-input> <wa-dropdown><wa-button slot=\"trigger\" appearance=\"outlined\" size=\"small\" with-caret><wa-avatar slot=\"prefix\" initials=\"E\" style=\"--size: 20px; background: #627eea;\"></wa-avatar> ETH</wa-button> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, token := range tokens {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<wa-dropdown-item><wa-avatar slot=\"icon\" initials=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var17 string
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(token.Initials)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 158, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\" style=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var18 string
templ_7745c5c3_Var18, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues("--size: 20px; background: " + token.Color + ";")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 158, Col: 117}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\"></wa-avatar> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var19 string
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(token.Symbol)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 159, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</wa-dropdown-item>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</wa-dropdown></div><div class=\"wa-flank\" style=\"margin-top: var(--wa-space-xs);\"><span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">≈ $0.00</span><div class=\"wa-cluster wa-gap-xs\"><wa-button size=\"small\" appearance=\"plain\" style=\"font-size: var(--wa-font-size-xs);\">25%</wa-button> <wa-button size=\"small\" appearance=\"plain\" style=\"font-size: var(--wa-font-size-xs);\">50%</wa-button> <wa-button size=\"small\" appearance=\"plain\" style=\"font-size: var(--wa-font-size-xs);\">MAX</wa-button></div></div></div><!-- Swap Direction Button --><div class=\"swap-arrow\"><wa-icon-button name=\"arrow-down\" label=\"Swap direction\" id=\"swap-direction-btn\"></wa-icon-button></div><!-- To Token Box --><div class=\"swap-token-box\"><div class=\"wa-flank\" style=\"margin-bottom: var(--wa-space-s);\"><span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">You Receive</span> <span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500);\">Balance: 1,250.00 USDC</span></div><div class=\"wa-flank wa-gap-m\"><wa-input type=\"number\" placeholder=\"0.00\" style=\"flex: 1; --wa-input-border-color: transparent; --wa-input-background-color: transparent;\" id=\"swap-to-amount\" readonly></wa-input> <wa-dropdown><wa-button slot=\"trigger\" appearance=\"outlined\" size=\"small\" with-caret><wa-avatar slot=\"prefix\" initials=\"U\" style=\"--size: 20px; background: #2775ca;\"></wa-avatar> USDC</wa-button> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, token := range tokens {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<wa-dropdown-item><wa-avatar slot=\"icon\" initials=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var20 string
templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(token.Initials)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 192, Col: 58}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "\" style=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var21 string
templ_7745c5c3_Var21, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues("--size: 20px; background: " + token.Color + ";")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 192, Col: 117}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\"></wa-avatar> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var22 string
templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(token.Symbol)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `components/drawers.templ`, Line: 193, Col: 24}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</wa-dropdown-item>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</wa-dropdown></div><span class=\"wa-caption-s\" style=\"color: var(--wa-color-neutral-500); margin-top: var(--wa-space-xs); display: block;\">≈ $0.00</span></div><!-- Swap Settings --><wa-details summary=\"Swap Settings\"><div class=\"wa-stack wa-gap-m\" style=\"padding-top: var(--wa-space-s);\"><div class=\"wa-stack wa-gap-xs\"><span class=\"wa-caption-s\">Slippage Tolerance</span> <wa-radio-group value=\"0.5\" orientation=\"horizontal\"><wa-radio appearance=\"button\" value=\"0.1\">0.1%</wa-radio> <wa-radio appearance=\"button\" value=\"0.5\">0.5%</wa-radio> <wa-radio appearance=\"button\" value=\"1\">1%</wa-radio> <wa-radio appearance=\"button\" value=\"custom\">Custom</wa-radio></wa-radio-group></div><wa-input label=\"Transaction Deadline\" type=\"number\" value=\"30\" size=\"small\"><span slot=\"suffix\">minutes</span></wa-input></div></wa-details><!-- Swap Preview --><wa-card style=\"background: var(--wa-color-surface-alt);\"><div class=\"wa-stack wa-gap-xs\"><div class=\"preview-row\"><span class=\"label\">Rate</span> <span>1 ETH = 2,345.00 USDC</span></div><div class=\"preview-row\"><span class=\"label\">Price Impact</span> <span style=\"color: var(--wa-color-success);\">&lt; 0.01%</span></div><div class=\"preview-row\"><span class=\"label\">Minimum Received</span> <span>0.00 USDC</span></div><div class=\"preview-row\"><span class=\"label\">Network Fee</span> <span>~$2.50</span></div><div class=\"preview-row\"><span class=\"label\">Route</span> <span class=\"wa-cluster wa-gap-2xs\">ETH <wa-icon name=\"arrow-right\" style=\"font-size: 10px;\"></wa-icon> USDC</span></div></div></wa-card> <wa-callout variant=\"warning\" style=\"--padding: var(--wa-space-s);\"><wa-icon slot=\"icon\" name=\"triangle-alert\"></wa-icon> <span class=\"wa-caption-s\">Price updates in real-time. Review carefully before confirming.</span></wa-callout></div></div><div class=\"wa-cluster wa-gap-s\" style=\"justify-content: flex-end;\"><wa-button variant=\"neutral\" appearance=\"outlined\" onclick=\"document.getElementById('swap-drawer').open = false\">Cancel</wa-button> <wa-button variant=\"brand\" id=\"swap-confirm-btn\"><wa-icon slot=\"start\" name=\"arrow-right-arrow-left\"></wa-icon> Review Swap</wa-button></div></div></wa-drawer>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = drawerStyles().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = swapDirectionScript().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// Script to handle swap direction button
func swapDirectionScript() templ.ComponentScript {
return templ.ComponentScript{
Name: `__templ_swapDirectionScript_d885`,
Function: `function __templ_swapDirectionScript_d885(){document.getElementById('swap-direction-btn')?.addEventListener('click', function() {
this.style.transform = this.style.transform === 'rotate(180deg)' ? '' : 'rotate(180deg)';
});
}`,
Call: templ.SafeScript(`__templ_swapDirectionScript_d885`),
CallInline: templ.SafeScriptInline(`__templ_swapDirectionScript_d885`),
}
}
// Drawer-specific styles
func drawerStyles() 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_Var23 := templ.GetChildren(ctx)
if templ_7745c5c3_Var23 == nil {
templ_7745c5c3_Var23 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "<style>\n\t\t.drawer-form {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\tgap: var(--wa-space-l);\n\t\t\theight: 100%;\n\t\t}\n\t\t.drawer-form-content {\n\t\t\tflex: 1;\n\t\t\toverflow-y: auto;\n\t\t}\n\t\t.qr-container {\n\t\t\tdisplay: flex;\n\t\t\tflex-direction: column;\n\t\t\talign-items: center;\n\t\t\tpadding: var(--wa-space-xl);\n\t\t\tbackground: var(--wa-color-surface-alt);\n\t\t\tborder-radius: var(--wa-radius-l);\n\t\t}\n\t\t.address-display {\n\t\t\tdisplay: flex;\n\t\t\talign-items: center;\n\t\t\tgap: var(--wa-space-s);\n\t\t\tpadding: var(--wa-space-m);\n\t\t\tbackground: var(--wa-color-surface-alt);\n\t\t\tborder-radius: var(--wa-radius-m);\n\t\t\tfont-family: var(--wa-font-mono);\n\t\t\tfont-size: var(--wa-font-size-s);\n\t\t\tword-break: break-all;\n\t\t}\n\t\t.swap-token-box {\n\t\t\tpadding: var(--wa-space-m);\n\t\t\tbackground: var(--wa-color-surface-alt);\n\t\t\tborder-radius: var(--wa-radius-m);\n\t\t\tborder: 1px solid var(--wa-color-neutral-200);\n\t\t}\n\t\t.swap-arrow {\n\t\t\tdisplay: flex;\n\t\t\tjustify-content: center;\n\t\t\tmargin: calc(var(--wa-space-s) * -1) 0;\n\t\t\tposition: relative;\n\t\t\tz-index: 1;\n\t\t}\n\t\t.swap-arrow wa-icon-button {\n\t\t\tbackground: var(--wa-color-surface);\n\t\t\tborder: 1px solid var(--wa-color-neutral-200);\n\t\t\tborder-radius: 50%;\n\t\t\ttransition: transform 0.2s;\n\t\t}\n\t\t.gas-settings {\n\t\t\tpadding: var(--wa-space-m);\n\t\t\tbackground: var(--wa-color-surface-alt);\n\t\t\tborder-radius: var(--wa-radius-m);\n\t\t}\n\t\t.preview-row {\n\t\t\tdisplay: flex;\n\t\t\tjustify-content: space-between;\n\t\t\tpadding: var(--wa-space-xs) 0;\n\t\t\tfont-size: var(--wa-font-size-s);\n\t\t}\n\t\t.preview-row .label {\n\t\t\tcolor: var(--wa-color-neutral-500);\n\t\t}\n\t</style>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// AllDrawers renders all three drawers together for convenience
func AllDrawers(tokens []TokenOption, walletAddress string) 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_Var24 := templ.GetChildren(ctx)
if templ_7745c5c3_Var24 == nil {
templ_7745c5c3_Var24 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = ReceiveDrawer(tokens, walletAddress).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = SendDrawer(tokens).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = SwapDrawer(tokens).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
// DrawerTriggerScript provides the JavaScript to wire up drawer triggers
func drawerTriggerScript() templ.ComponentScript {
return templ.ComponentScript{
Name: `__templ_drawerTriggerScript_084e`,
Function: `function __templ_drawerTriggerScript_084e(){// Open receive drawer
document.querySelectorAll('[data-drawer-open="receive"]').forEach(el => {
el.addEventListener('click', () => {
document.getElementById('receive-drawer').open = true;
});
});
// Open send drawer
document.querySelectorAll('[data-drawer-open="send"]').forEach(el => {
el.addEventListener('click', () => {
document.getElementById('send-drawer').open = true;
});
});
// Open swap drawer
document.querySelectorAll('[data-drawer-open="swap"]').forEach(el => {
el.addEventListener('click', () => {
document.getElementById('swap-drawer').open = true;
});
});
}`,
Call: templ.SafeScript(`__templ_drawerTriggerScript_084e`),
CallInline: templ.SafeScriptInline(`__templ_drawerTriggerScript_084e`),
}
}
// DrawerTriggers component to initialize drawer triggers
func DrawerTriggers() 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_Var25 := templ.GetChildren(ctx)
if templ_7745c5c3_Var25 == nil {
templ_7745c5c3_Var25 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Err = drawerTriggerScript().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate