feat: Dual-Preis-Anzeige (XMR/Fiat) und Kurs im Footer via CoinGecko

This commit is contained in:
2026-02-04 10:47:50 +01:00
parent 46c9195010
commit 28ac3e03e0
3 changed files with 53 additions and 23 deletions

View File

@@ -1,8 +1,33 @@
import { t } from '../i18n.js'
import { getXmrRates, formatFiat } from '../services/currency.js'
class AppFooter extends HTMLElement {
connectedCallback() {
constructor() {
super()
this.xmrRate = null
}
async connectedCallback() {
this.render()
await this.loadXmrRate()
}
async loadXmrRate() {
try {
const rates = await getXmrRates()
this.xmrRate = rates.EUR
this.updateRateDisplay()
} catch (e) {
console.error('Failed to load XMR rate:', e)
}
}
updateRateDisplay() {
const rateEl = this.querySelector('.xmr-rate')
if (rateEl && this.xmrRate) {
rateEl.textContent = `1 XMR ≈ ${formatFiat(this.xmrRate, 'EUR')}`
rateEl.classList.add('loaded')
}
}
render() {
@@ -13,6 +38,7 @@ class AppFooter extends HTMLElement {
<p class="footer-copyright">
&copy; ${year} dgray.io - <span data-i18n="footer.rights">${t('footer.rights')}</span>
</p>
<span class="xmr-rate" title="CoinGecko">1 XMR ≈ ...</span>
<nav class="footer-links">
<a href="#/about" data-i18n="footer.about">${t('footer.about')}</a>
<a href="#/privacy" data-i18n="footer.privacy">${t('footer.privacy')}</a>
@@ -25,6 +51,7 @@ class AppFooter extends HTMLElement {
updateTranslations() {
this.render()
if (this.xmrRate) this.updateRateDisplay()
}
}