feat: Dual-Preis-Anzeige (XMR/Fiat) und Kurs im Footer via CoinGecko
This commit is contained in:
@@ -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">
|
||||
© ${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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user