Skip to content

Commit

Permalink
ui: refactor investment cards
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardomerlin authored and marcelorodrigo committed Oct 11, 2024
1 parent 7671f0f commit 4c11709
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 22 deletions.
68 changes: 48 additions & 20 deletions components/InvestmentResult.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
<template>
<v-card elevation='2' class='mb-2'>
<v-card elevation='2' class='mb-2' max-width='400px'>
<v-card-title>{{ name }}</v-card-title>
<v-card-text>
<div v-if="hasAmount">Valor Investido: {{ amountDisplay }}</div>
<div v-if='!!interestAmount'>
Rendimento Bruto: {{ interestAmountDisplay }}
</div>
<div v-if='!!iofAmount'>IOF: {{ iofAmountDisplay }}</div>
<div v-if='!!taxAmount'>
Imposto de Renda: {{ taxAmountDisplay }}
<v-badge
inline
v-if='!!taxPercentage'
:content='taxPercentageDisplay'
color='red lighten-2'
/>
</div>
<div>Valor Total Líquido: {{ totalAmountDisplay }}</div>
<v-progress-linear v-model='totalProfitPercentage' :color='color' height='25'>
{{ totalProfitPercentageDisplay }}
</v-progress-linear>
<v-table density="compact">
<tbody>
<tr v-if="hasAmount">
<td class="border-0">Valor Investido</td>
<td class="border-0 text-right">
<code>{{ amountDisplay }}</code>
</td>
</tr>
<tr v-if='!!interestAmount'>
<td class="border-0">Rendimento Bruto</td>
<td class="border-0 text-right">
<code>{{ interestAmountDisplay }}</code>
</td>
</tr>
<tr v-if='!!iofAmount'>
<td class="border-0">IOF</td>
<td class="border-0 text-right">
<code>{{ iofAmountDisplay }}</code>
</td>
</tr>
<tr>
<td class="border-0">Imposto de Renda <v-badge
inline
v-if='!!taxPercentage'
:content='taxPercentageDisplay'
color='red lighten-2'
/></td>
<td class="border-0 text-right">
<code>{{ taxAmountDisplay }}</code>
</td>
</tr>
<tr>
<td class="border-0 border-t-sm">Valor Total Líquido</td>
<td class="border-0 border-t-sm text-right">
<code>{{ totalAmountDisplay }}</code>
</td>
</tr>
<tr>
<td colspan="2">
<v-progress-linear v-model='totalProfitPercentage' :color='color' height='25'>
{{ totalProfitPercentageDisplay }}
</v-progress-linear>
</td>
</tr>
</tbody>
</v-table>
</v-card-text>
</v-card>
</template>
Expand Down Expand Up @@ -90,7 +118,7 @@ const totalAmount = computed(() => props.amount + totalProfit.value)
const totalProfitPercentage = computed(() => (totalProfit.value / props.amount) * 100)
const taxPercentageDisplay = computed(() => filters.percent(props.taxPercentage))
const taxAmountDisplay = computed(() => filters.currency(props.taxAmount))
const taxAmountDisplay = computed(() => filters.currency((props.taxAmount ? props.taxAmount * -1 : 0)))
const amountDisplay = computed(() => filters.currency(props.amount))
const iofAmountDisplay = computed(() => filters.currency(props.iofAmount))
const totalAmountDisplay = computed(() => filters.currency(totalAmount.value))
Expand Down
3 changes: 1 addition & 2 deletions plugins/vuetify.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// import this after install `@mdi/font` package
import '@mdi/font/css/materialdesignicons.css'

import 'vuetify/styles'
import '../src/styles/custom.css'
import { createVuetify } from 'vuetify'

export default defineNuxtPlugin((app) => {
Expand Down
11 changes: 11 additions & 0 deletions src/styles/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:root .v-table {
line-height: 1.6;
}

:root .v-table--density-compact {
--v-table-row-height: 1rem;
}

:root .v-table > .v-table__wrapper > table > tbody > tr > td {
padding: 0;
}

0 comments on commit 4c11709

Please sign in to comment.