jws-frontend/src/components/StatCardComponent.vue

117 lines
2.3 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import AppBox from 'components/app/AppBox.vue';
const props = withDefaults(
defineProps<{
branch: {
icon: string;
count: number;
label: string;
color: 'pink' | 'purple' | 'green' | 'orange';
}[];
dark?: boolean;
2024-04-23 14:43:00 +07:00
labelI18n?: boolean;
2024-07-03 09:21:53 +00:00
nowrap?: boolean;
}>(),
{
2024-04-23 14:43:00 +07:00
labelI18n: false,
},
);
</script>
<template>
<div
2024-07-04 11:00:03 +07:00
class="row"
style="gap: var(--size-4)"
2024-07-04 04:14:41 +00:00
:class="{ dark, 'no-wrap': nowrap }"
>
2024-04-10 20:43:58 +07:00
<AppBox
2024-04-23 14:20:08 +07:00
v-for="v in props.branch"
2024-07-04 11:00:03 +07:00
class="no-padding shadow-2"
2024-04-23 14:20:08 +07:00
:class="{ [`stat-card__${v.color}`]: true }"
2024-07-04 11:00:03 +07:00
:key="v.label"
>
2024-07-04 11:00:03 +07:00
<div class="stat-card__content row items-center q-px-md q-py-sm">
<div class="col-4 text-center">
<q-avatar
size="lg"
style="background-color: hsla(0 0% 100% /0.15)"
text-color="white"
:icon="v.icon"
/>
</div>
<div class="col-6 justify-center column">
<div class="col-6 ellipsis text-bold" style="width: 100%">
{{ labelI18n ? $t(v.label) : v.label }}
<q-tooltip
anchor="top middle"
self="bottom middle"
:offset="[10, 10]"
>
{{ labelI18n ? $t(v.label) : v.label }}
</q-tooltip>
</div>
<div class="col-6">{{ v.count }}</div>
</div>
</div>
2024-04-10 20:43:58 +07:00
</AppBox>
</div>
</template>
<style scoped>
2024-04-23 14:20:08 +07:00
.stat-card {
--_color: var(--gray-6);
2024-06-25 17:25:33 +07:00
display: grid;
grid-template-columns: repeat(2, 1fr);
}
@media screen and (min-width: 1024px) {
.stat-card {
display: flex;
}
}
@media screen and (min-width: 1920px) {
.stat-card {
display: flex;
}
2024-04-23 14:20:08 +07:00
}
.stat-card__content {
z-index: 2;
color: hsla(var(--gray-0-hsl) / 1);
background: hsla(var(--_color) / 1);
height: 100%;
2024-07-03 14:16:33 +07:00
min-width: 200px;
}
2024-04-23 14:20:08 +07:00
.stat-card__purple {
--_color: var(--violet-11-hsl);
}
2024-04-23 14:20:08 +07:00
.stat-card__pink {
--_color: var(--pink-6-hsl);
}
2024-04-11 09:43:09 +07:00
2024-04-23 14:20:08 +07:00
.stat-card__green {
--_color: var(--teal-10-hsl);
2024-04-23 13:03:12 +07:00
}
.stat-card__orange {
--_color: var(--orange-5-hsl);
}
2024-04-23 14:20:08 +07:00
.dark .stat-card__purple {
--_color: var(--violet-10-hsl);
2024-04-11 09:43:09 +07:00
}
2024-04-23 13:03:12 +07:00
2024-04-23 14:20:08 +07:00
.dark .stat-card__green {
--_color: var(--teal-8-hsl);
2024-04-23 13:03:12 +07:00
}
.dark .stat-card__orange {
--_color: var(--orange-8);
}
</style>