cosmos-explorer/src/components/CardStatisticsVertical.vue

53 lines
1.3 KiB
Vue
Raw Normal View History

2023-04-03 09:08:02 +00:00
<script setup lang="ts">
interface Props {
title: string;
color?: string;
icon: string;
stats: string;
change?: number;
subtitle?: string;
2023-04-03 09:08:02 +00:00
}
const props = withDefaults(defineProps<Props>(), {
color: 'primary',
});
2023-04-03 09:08:02 +00:00
const isPositive = controlledComputed(
() => props.change,
() => Math.sign(props.change || 0) === 1
);
2023-04-03 09:08:02 +00:00
</script>
<template>
2023-04-25 10:27:46 +00:00
<VCard class="h-full flex-col content-between">
<VCardText class="d-flex align-center justify-between">
<VAvatar v-if="props.icon" rounded size="38" variant="tonal" :color="props.color">
<VIcon :icon="props.icon" size="24" />
2023-04-03 09:08:02 +00:00
</VAvatar>
<div
v-if="props.change"
:class="isPositive ? 'text-success' : 'text-error'"
class="d-flex align-center text-sm font-weight-medium mt-n4"
>
<span>{{ isPositive ? `+${props.change}` : props.change }}%</span>
<VIcon :icon="isPositive ? 'mdi-chevron-up' : 'mdi-chevron-down'" />
</div>
</VCardText>
2023-04-25 10:27:46 +00:00
<VCardText class="d-flex flex-col">
2023-04-03 09:08:02 +00:00
<h6 class="text-h6 me-2 mt-2 mb-1">
{{ props.stats }}
</h6>
<p class="text-sm">
{{ props.title }}
</p>
<VChip v-if="props.subtitle" size="x-small" class="font-weight-medium">
2023-04-03 09:08:02 +00:00
<span class="text-truncate">{{ props.subtitle }}</span>
</VChip>
</VCardText>
</VCard>
</template>