cosmos-explorer/src/components/CardStatisticsVertical.vue

62 lines
1.6 KiB
Vue
Raw Normal View History

2023-04-03 09:08:02 +00:00
<script setup lang="ts">
2023-05-12 13:42:22 +00:00
import { Icon } from '@iconify/vue';
2023-06-08 02:02:47 +00:00
import { controlledComputed } from '@vueuse/core'
2023-05-12 13:42:22 +00:00
2023-04-03 09:08:02 +00:00
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-05-12 13:42:22 +00:00
<div class="bg-base-100 shadow rounded p-4">
2023-06-18 09:56:22 +00:00
<div class="flex items-center justify-center">
2023-05-12 13:42:22 +00:00
<div
2023-05-06 14:56:04 +00:00
v-if="props.icon"
2023-05-12 13:42:22 +00:00
class="relative w-9 h-9 rounded overflow-hidden flex items-center justify-center"
2023-05-06 14:56:04 +00:00
>
2023-05-12 13:42:22 +00:00
<Icon :class="[`text-${props?.color}`]" :icon="props.icon" size="32" />
<div
class="absolute top-0 left-0 bottom-0 right-0 opacity-20"
:class="[`bg-${props?.color}`]"
></div>
</div>
2023-04-03 09:08:02 +00:00
<div
v-if="props.change"
:class="isPositive ? 'text-success' : 'text-error'"
2023-05-12 13:42:22 +00:00
class="flex items-center text-sm font-semibold"
2023-04-03 09:08:02 +00:00
>
<span>{{ isPositive ? `+${props.change}` : props.change }}%</span>
2023-05-12 13:42:22 +00:00
<Icon :icon="isPositive ? 'mdi-chevron-up' : 'mdi-chevron-down'" />
2023-04-03 09:08:02 +00:00
</div>
2023-05-12 13:42:22 +00:00
</div>
2023-04-03 09:08:02 +00:00
2023-05-12 13:42:22 +00:00
<div class="">
2023-06-18 09:56:22 +00:00
<h6 class="text-lg text-center font-semibold mt-2 mb-1">
2023-05-27 15:53:19 +00:00
{{ props.stats || '-'}}
2023-04-03 09:08:02 +00:00
</h6>
2023-06-18 09:56:22 +00:00
<p class="text-sm text-center">
2023-04-03 09:08:02 +00:00
{{ props.title }}
</p>
2023-05-12 13:42:22 +00:00
<div v-if="props.subtitle" size="x-small" class="font-semibold">
2023-05-27 16:45:38 +00:00
<span class="truncate">{{ props.subtitle }}</span>
2023-05-12 13:42:22 +00:00
</div>
</div>
</div>
2023-04-03 09:08:02 +00:00
</template>