package views import ( "nebula/layouts" "nebula/models" ) templ AuthorizePage(req models.AuthRequest) { @layouts.CenteredCard("Authorize - Sonr") {
@AuthorizeContent(req)
} } templ AuthorizeContent(req models.AuthRequest) { @authorizeStyles() @AppIdentityHeader(req.App) @RequestTypeTabs(req) } templ AppIdentityHeader(app models.AppInfo) {
if app.Verified { }
} templ RequestTypeTabs(req models.AuthRequest) { @ConnectPanel(req.Wallet) @SignPanel(req.Wallet, req.Message, req.MessageHex) @TransactionPanel(req.Wallet, req.Transaction) @tabScripts() } templ ConnectPanel(wallet models.WalletInfo) {
@WalletSelector(wallet, false, "")
@PermissionItem("eye", "read", "See your wallet address", "Your public address only") @PermissionItem("coins", "read", "See your balances", "Token amounts in your wallet") @PermissionItem("bell", "write", "Ask to send transactions", "You'll approve each one separately")
} templ SignPanel(wallet models.WalletInfo, message string, messageHex string) {
@WalletSelector(wallet, true, "Signing")
{ message }
if messageHex != "" {
{ messageHex }
}
} templ TransactionPanel(wallet models.WalletInfo, tx *models.TxDetails) {
@WalletSelectorWithBalance(wallet) if tx != nil { @TransactionCard(tx) @TransactionDetails(tx)
}
} templ WalletSelector(wallet models.WalletInfo, showBadge bool, badgeText string) {
if showBadge && badgeText != "" { { badgeText } } else { }
} templ WalletSelectorWithBalance(wallet models.WalletInfo) {
} templ PermissionItem(icon string, variant string, title string, description string) {
} templ TransactionCard(tx *models.TxDetails) {
} templ TransactionDetails(tx *models.TxDetails) {
Network { tx.Network }
Network fee { tx.NetworkFee }
Max fee { tx.MaxFee }
Price change limit { tx.Slippage }
} templ AuthFooterActions(requestType string) {
Cancel if requestType == "sign" { Sign } else if requestType == "transaction" { Confirm } else { Allow }
} templ AuthResultSuccess(actionType string) { @authorizeStyles()
if actionType == "sign" { Signed } else if actionType == "transaction" { Sent } else { Connected } if actionType == "transaction" { Transaction ID: 0x8f4a2b1c... } else { You can close this window. } Close
} templ AuthResultDenied() { @authorizeStyles()
Cancelled No access was granted. Close
} templ tabScripts() { } templ authorizeStyles() { }