Alina Beck f6de44b337 place donation info in separate component
compute title and label according to selected locale and donation values
2019-11-11 13:09:51 +03:00

51 lines
1.2 KiB
Vue

<template>
<div class="donation-info">
<progress-bar :title="title" :label="label" :goal="goal" :progress="progress" />
<a href="https://human-connection.org/spenden/">
<ds-button primary>{{ $t('donations.donate-now') }}</ds-button>
</a>
</div>
</template>
<script>
import ProgressBar from '~/components/ProgressBar/ProgressBar.vue'
export default {
components: {
ProgressBar,
},
// TODO: get values from state / database? --> should not be props and not have defaults
props: {
goal: {
type: Number,
default: 15000,
},
progress: {
type: Number,
default: 500,
},
},
computed: {
title() {
const today = new Date()
const month = today.toLocaleString(this.$i18n.locale(), { month: 'long' })
return `${this.$t('donations.donations-for')} ${month}`
},
label() {
return this.$t('donations.amount-of-total', {
amount: this.progress.toLocaleString(this.$i18n.locale()),
total: this.goal.toLocaleString(this.$i18n.locale()),
})
},
},
}
</script>
<style lang="scss">
.donation-info {
display: flex;
align-items: flex-end;
height: 100%;
}
</style>