package components // 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 templ ReceiveDrawer(tokens []TokenOption, walletAddress string) {
@drawerStyles() } // SendDrawer component for sending tokens templ SendDrawer(tokens []TokenOption) {
@drawerStyles() } // SwapDrawer component for swapping tokens templ SwapDrawer(tokens []TokenOption) {
@drawerStyles() @swapDirectionScript() } // Script to handle swap direction button script swapDirectionScript() { document.getElementById('swap-direction-btn')?.addEventListener('click', function() { this.style.transform = this.style.transform === 'rotate(180deg)' ? '' : 'rotate(180deg)'; }); } // Drawer-specific styles templ drawerStyles() { } // AllDrawers renders all three drawers together for convenience templ AllDrawers(tokens []TokenOption, walletAddress string) { @ReceiveDrawer(tokens, walletAddress) @SendDrawer(tokens) @SwapDrawer(tokens) } // DrawerTriggerScript provides the JavaScript to wire up drawer triggers script drawerTriggerScript() { // 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; }); }); } // DrawerTriggers component to initialize drawer triggers templ DrawerTriggers() { @drawerTriggerScript() }