package views import ( "nebula/components" "nebula/layouts" "nebula/models" ) templ DashboardPage(data models.DashboardData, activeTab string) { @layouts.DashboardLayout("Dashboard - Sonr", layouts.WalletUser{Name: "Sonr Wallet", Address: "sonr1x9f...7k2m"}, activeTab) { @dashboardStyles() @DashboardContent(data, activeTab) @components.AllDrawers(components.DefaultTokenOptions(), "sonr1x9f4h2k8m3n5p7q2r4s6t8v0w3x5y7z9a1b3c5d7k2m") @components.DrawerTriggers() } } templ DashboardContent(data models.DashboardData, activeTab string) {
if activeTab == "" || activeTab == "overview" { @OverviewPanel(data) } else if activeTab == "transactions" { @TransactionsPanel(data.Transactions) } else if activeTab == "tokens" { @TokensPanel(data.Tokens) } else if activeTab == "nfts" { @NFTsPanel(data.NFTs) } else if activeTab == "activity" { @ActivityPanel() }
} templ OverviewPanel(data models.DashboardData) {
Receive Send Swap
1D 1W 1M 1Y
@components.StackedAreaChart("portfolio-chart", data.PortfolioChart)
for _, token := range data.Tokens { @TokenRow(token) } for _, tx := range data.Transactions { @TransactionTableRow(tx) }
Type Asset Amount Date
@ConnectedAccountsCard() } templ TokenRow(token models.Token) {
Send Receive Swap
} templ TransactionTableRow(tx models.Transaction) { if tx.Type == "receive" { Receive } else if tx.Type == "send" { Send } else { Swap } { tx.Asset }
{ tx.Amount } { tx.USD }
{ tx.Date } { tx.Time }
} func txAmountStyle(positive bool) string { if positive { return "color: var(--wa-color-success);" } return "color: var(--wa-color-danger);" } templ ConnectedAccountsCard() {
Create
@AccountCard("M", "Main Wallet", "sonr1x9f...7k2m", "var(--wa-color-primary)", true) @AccountCard("T", "Trading", "sonr1k4m...9p3q", "var(--wa-color-neutral-400)", false) @AccountCard("S", "Savings", "sonr1r7t...2w8x", "var(--wa-color-neutral-400)", false)
} templ AccountCard(initials string, name string, address string, color string, active bool) {
if active { Active } else { }
} templ TransactionsPanel(transactions []models.Transaction) { @components.TxStyles()
Export
@components.TxStatsGrid(components.DefaultTxStats()) @components.TxFilterBar(components.DefaultTxFilter()) for _, group := range components.DefaultTxGroups() { @components.TxDateGroupComponent(group) } @components.TxPagination(1, 82, 10) } templ StatCard(label string, value string, subtitle string, variant string) {
{ value }
} templ TokensPanel(tokens []models.Token) {
for _, token := range tokens { @TokenTableRow(token) }
Asset Network 24h Change Holdings Value
} templ TokenTableRow(token models.Token) {
{ token.Network } if token.Positive { } else { } { token.Change } { token.Balance } { token.Symbol }
{ token.Value }
Swap
} templ NFTsPanel(nfts []models.NFT) {
@StatCard("Total NFTs", "12", "across 5 collections", "neutral") @StatCard("Estimated Value", "$8,420.50", "+12.4% this week", "success") @StatCard("Floor Value", "4.2 ETH", "$9,851.40", "neutral")
Bored Ape Yacht Club Sonr Genesis Recently Added Value: High to Low Value: Low to High
for _, nft := range nfts { @NFTCard(nft) }
} templ NFTCard(nft models.NFT) {
{ if nft.Badge != "" {
{ nft.Badge }
}
if nft.Verified { } { nft.Collection }
{ nft.Name }
Floor: { nft.Floor } { nft.Value }
} func nftBadgeVariant(badge string) string { if badge == "Listed" { return "success" } if badge == "Rare" { return "brand" } return "neutral" } templ ActivityPanel() { @ActivityPanelWithData(models.DefaultMarketCapBubbleData()) } templ ActivityPanelWithData(marketCapData []models.BubbleData) {
Refresh
@ActivityStatCard("desktop", "Active Sessions", "3", "var(--wa-color-primary)") @ActivityStatCard("plug", "Connected Apps", "5", "var(--wa-color-success)") @ActivityStatCard("bell", "Pending", "4", "var(--wa-color-warning)") @ActivityStatCard("clock-rotate-left", "Last Active", "Just now", "var(--wa-color-neutral-600)")
@PendingActionsCard()
@ActiveSessionsCard() @ConnectedAppsCard()
@components.BubbleChart("market-cap-bubble", marketCapData)
} templ ActivityStatCard(icon string, label string, value string, color string) {
} templ PendingActionsCard() {
Clear All
@PendingAction("shield-halved", "var(--wa-color-warning)", "Security Review Required", "New device signed in from San Francisco, CA", "Review", "Dismiss") @PendingAction("signature", "var(--wa-color-primary)", "Signature Request", "DeFi Protocol wants to verify wallet ownership", "Sign", "Reject")
} templ PendingAction(icon string, color string, title string, desc string, primaryAction string, secondaryAction string) {
{ primaryAction } { secondaryAction }
} templ ActiveSessionsCard() {
Sign Out All
@SessionRow("desktop", "var(--wa-color-primary)", "MacBook Pro", "Chrome 120 · San Francisco, CA", "Active now", true) @SessionRow("mobile", "var(--wa-color-success)", "iPhone 15 Pro", "Safari · San Francisco, CA", "2 hours ago", false) @SessionRow("tablet", "var(--wa-color-warning)", "iPad Air", "Safari · New York, NY", "12 hours ago", false)
} templ SessionRow(icon string, color string, device string, details string, time string, current bool) {
if !current { Revoke }
} func sessionTimeStyle(current bool) string { if current { return "color: var(--wa-color-success);" } return "color: var(--wa-color-neutral-500);" } templ ConnectedAppsCard() {
Manage
@ConnectedAppRow("D", "linear-gradient(135deg, #6366f1, #8b5cf6)", "DeFi Protocol", "defi.example.com", "") @ConnectedAppRow("N", "linear-gradient(135deg, #10b981, #059669)", "NFT Marketplace", "nft.marketplace.io", "transact") @ConnectedAppRow("S", "linear-gradient(135deg, #f59e0b, #d97706)", "Staking Dashboard", "stake.sonr.io", "")
} templ ConnectedAppRow(initials string, bg string, name string, domain string, badge string) {
View Permissions Disconnect
} templ dashboardStyles() { }