feat: Integrate CurrencyDisplay component for wallet balance in Navbar
- Replace formatted balance display with CurrencyDisplay component in Navbar.vue, enhancing the visual representation of wallet balances. - Introduce CurrencyDisplay.vue to handle the display of various currency denominations, improving clarity for users regarding their wallet contents.
This commit is contained in:
parent
4cf2b769d6
commit
437da6ad72
2 changed files with 54 additions and 8 deletions
|
|
@ -10,8 +10,8 @@ import { Sun, Moon, Menu, X, User, LogOut, Ticket, Wallet } from 'lucide-vue-nex
|
||||||
import LanguageSwitcher from '@/components/LanguageSwitcher.vue'
|
import LanguageSwitcher from '@/components/LanguageSwitcher.vue'
|
||||||
import LoginDialog from '@/components/auth/LoginDialog.vue'
|
import LoginDialog from '@/components/auth/LoginDialog.vue'
|
||||||
import ProfileDialog from '@/components/auth/ProfileDialog.vue'
|
import ProfileDialog from '@/components/auth/ProfileDialog.vue'
|
||||||
|
import CurrencyDisplay from '@/components/ui/CurrencyDisplay.vue'
|
||||||
import { auth } from '@/composables/useAuth'
|
import { auth } from '@/composables/useAuth'
|
||||||
import { formatWalletBalance } from '@/lib/utils/currency'
|
|
||||||
|
|
||||||
interface NavigationItem {
|
interface NavigationItem {
|
||||||
name: string
|
name: string
|
||||||
|
|
@ -40,10 +40,6 @@ const totalBalance = computed(() => {
|
||||||
}, 0)
|
}, 0)
|
||||||
})
|
})
|
||||||
|
|
||||||
const formattedBalance = computed(() => {
|
|
||||||
return formatWalletBalance(totalBalance.value)
|
|
||||||
})
|
|
||||||
|
|
||||||
const toggleMenu = () => {
|
const toggleMenu = () => {
|
||||||
isOpen.value = !isOpen.value
|
isOpen.value = !isOpen.value
|
||||||
}
|
}
|
||||||
|
|
@ -100,7 +96,7 @@ const handleLogout = async () => {
|
||||||
<!-- Wallet Balance Display -->
|
<!-- Wallet Balance Display -->
|
||||||
<div v-if="auth.isAuthenticated.value" class="hidden sm:flex items-center gap-2 px-3 py-1 bg-muted/50 rounded-lg border">
|
<div v-if="auth.isAuthenticated.value" class="hidden sm:flex items-center gap-2 px-3 py-1 bg-muted/50 rounded-lg border">
|
||||||
<Wallet class="h-4 w-4 text-muted-foreground" />
|
<Wallet class="h-4 w-4 text-muted-foreground" />
|
||||||
<span class="text-sm font-mono font-medium">{{ formattedBalance }}</span>
|
<CurrencyDisplay :balance-msat="totalBalance" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Authentication Management -->
|
<!-- Authentication Management -->
|
||||||
|
|
@ -117,7 +113,7 @@ const handleLogout = async () => {
|
||||||
<!-- Wallet Balance in Dropdown -->
|
<!-- Wallet Balance in Dropdown -->
|
||||||
<div class="flex items-center gap-2 px-2 py-1.5 text-sm border-b">
|
<div class="flex items-center gap-2 px-2 py-1.5 text-sm border-b">
|
||||||
<Wallet class="h-4 w-4 text-muted-foreground" />
|
<Wallet class="h-4 w-4 text-muted-foreground" />
|
||||||
<span class="font-mono font-medium">{{ formattedBalance }}</span>
|
<CurrencyDisplay :balance-msat="totalBalance" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DropdownMenuItem @click="openProfileDialog" class="gap-2">
|
<DropdownMenuItem @click="openProfileDialog" class="gap-2">
|
||||||
|
|
@ -186,7 +182,7 @@ const handleLogout = async () => {
|
||||||
<!-- Mobile Wallet Balance -->
|
<!-- Mobile Wallet Balance -->
|
||||||
<div class="flex items-center gap-2 px-2 py-1 bg-muted/50 rounded-lg">
|
<div class="flex items-center gap-2 px-2 py-1 bg-muted/50 rounded-lg">
|
||||||
<Wallet class="h-4 w-4 text-muted-foreground" />
|
<Wallet class="h-4 w-4 text-muted-foreground" />
|
||||||
<span class="text-sm font-mono font-medium">{{ formattedBalance }}</span>
|
<CurrencyDisplay :balance-msat="totalBalance" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
|
|
|
||||||
50
src/components/ui/CurrencyDisplay.vue
Normal file
50
src/components/ui/CurrencyDisplay.vue
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
<template>
|
||||||
|
<div class="flex items-center gap-1 bg-muted/30 rounded-lg p-1 border">
|
||||||
|
<!-- Platinum -->
|
||||||
|
<div v-if="currency.platinum > 0" class="flex items-center gap-1 px-2 py-1 rounded bg-blue-900/50 border border-blue-700/30">
|
||||||
|
<div class="w-3 h-3 rounded-full bg-gradient-to-br from-slate-300 to-slate-500 border border-slate-400"></div>
|
||||||
|
<span class="text-xs font-mono font-bold text-blue-100">{{ currency.platinum }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Gold -->
|
||||||
|
<div v-if="currency.gold > 0" class="flex items-center gap-1 px-2 py-1 rounded bg-yellow-900/50 border border-yellow-700/30">
|
||||||
|
<div class="w-3 h-3 rounded-full bg-gradient-to-br from-yellow-300 to-yellow-500 border border-yellow-400"></div>
|
||||||
|
<span class="text-xs font-mono font-bold text-yellow-100">{{ currency.gold }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Silver -->
|
||||||
|
<div v-if="currency.silver > 0" class="flex items-center gap-1 px-2 py-1 rounded bg-gray-700/50 border border-gray-600/30">
|
||||||
|
<div class="w-3 h-3 rounded-full bg-gradient-to-br from-gray-300 to-gray-500 border border-gray-400"></div>
|
||||||
|
<span class="text-xs font-mono font-bold text-gray-100">{{ currency.silver }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Copper -->
|
||||||
|
<div v-if="currency.copper > 0" class="flex items-center gap-1 px-2 py-1 rounded bg-orange-900/50 border border-orange-700/30">
|
||||||
|
<div class="w-3 h-3 rounded-full bg-gradient-to-br from-orange-300 to-orange-500 border border-orange-400"></div>
|
||||||
|
<span class="text-xs font-mono font-bold text-orange-100">{{ currency.copper }}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Show 0c if no currency -->
|
||||||
|
<div v-if="currency.platinum === 0 && currency.gold === 0 && currency.silver === 0 && currency.copper === 0"
|
||||||
|
class="flex items-center gap-1 px-2 py-1 rounded bg-orange-900/50 border border-orange-700/30">
|
||||||
|
<div class="w-3 h-3 rounded-full bg-gradient-to-br from-orange-300 to-orange-500 border border-orange-400"></div>
|
||||||
|
<span class="text-xs font-mono font-bold text-orange-100">0</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { satoshisToEverQuest, type EverQuestCurrency } from '@/lib/utils/currency'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
balanceMsat: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>()
|
||||||
|
|
||||||
|
const currency = computed<EverQuestCurrency>(() => {
|
||||||
|
const satoshis = Math.floor(props.balanceMsat / 1000)
|
||||||
|
return satoshisToEverQuest(satoshis)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue