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)
@AuthFooterActions(req.Type)
}
templ AppIdentityHeader(app models.AppInfo) {
{ app.Name }
if app.Verified {
}
{ app.Domain }
}
templ RequestTypeTabs(req models.AuthRequest) {
Connect
Sign
Transaction
@ConnectPanel(req.Wallet)
@SignPanel(req.Wallet, req.Message, req.MessageHex)
@TransactionPanel(req.Wallet, req.Transaction)
@tabScripts()
}
templ ConnectPanel(wallet models.WalletInfo) {
@WalletSelector(wallet, false, "")
This app wants to:
@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")
This app cannot:
Spend your funds without asking you first.
}
templ SignPanel(wallet models.WalletInfo, message string, messageHex string) {
@WalletSelector(wallet, true, "Signing")
You're signing this message:
{ message }
Free to sign
No fees. This just proves you own this wallet.
if messageHex != "" {
}
}
templ TransactionPanel(wallet models.WalletInfo, tx *models.TxDetails) {
@WalletSelectorWithBalance(wallet)
if tx != nil {
@TransactionCard(tx)
@TransactionDetails(tx)
Large amount
Please review the details carefully before confirming.
Contract
{ tx.Contract }
Function
{ tx.Function }
{ tx.RawData }
}
}
templ WalletSelector(wallet models.WalletInfo, showBadge bool, badgeText string) {
{ wallet.Name }
{ wallet.Address }
if showBadge && badgeText != "" {
{ badgeText }
} else {
}
}
templ WalletSelectorWithBalance(wallet models.WalletInfo) {
{ wallet.Name }
{ wallet.Address }
Balance
{ wallet.Balance }
}
templ PermissionItem(icon string, variant string, title string, description string) {
{ title }
{ description }
}
templ TransactionCard(tx *models.TxDetails) {
{ tx.Type }
Waiting
{ tx.FromToken.Amount } { tx.FromToken.Symbol }
{ tx.FromToken.Symbol }
-{ tx.FromToken.USD }
~{ tx.ToToken.Amount } { tx.ToToken.Symbol }
{ tx.ToToken.Symbol }
+{ tx.ToToken.USD }
}
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
}
Protected by Sonr
}
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() {
}