fix: adjust grid layout in StatCard component for better responsiveness and update RupiahText component to support short format
This commit is contained in:
parent
ed2cb2e53d
commit
b7f8bf7e0f
@ -31,7 +31,7 @@ withDefaults(defineProps<Props>(), {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<div class="space-y-3">
|
<div class="space-y-3">
|
||||||
<div>
|
<div class="text-left">
|
||||||
<p v-if="mainLabel" class="text-xs text-muted-foreground">
|
<p v-if="mainLabel" class="text-xs text-muted-foreground">
|
||||||
{{ mainLabel }}
|
{{ mainLabel }}
|
||||||
</p>
|
</p>
|
||||||
@ -40,8 +40,8 @@ withDefaults(defineProps<Props>(), {
|
|||||||
{{ subLabel }}
|
{{ subLabel }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="border-t pt-2 text-center"
|
<div class="border-t pt-2 text-left"
|
||||||
:class="cols === 2 ? 'grid grid-cols-2 gap-2' : 'grid grid-cols-3 gap-2'">
|
:class="cols === 2 ? 'grid grid-cols-1 sm:grid-cols-2 gap-2' : 'grid grid-cols-1 sm:grid-cols-3 gap-2'">
|
||||||
<div v-for="item in items" :key="item.label">
|
<div v-for="item in items" :key="item.label">
|
||||||
<p class="text-xs text-muted-foreground">{{ item.label }}</p>
|
<p class="text-xs text-muted-foreground">{{ item.label }}</p>
|
||||||
<p class="text-sm font-semibold" :class="item.color ?? ''">
|
<p class="text-sm font-semibold" :class="item.color ?? ''">
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { formatRupiah } from '@/lib/rupiah';
|
import { formatRupiah, formatRupiahShort } from '@/lib/rupiah';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
amount: number | string;
|
amount: number | string;
|
||||||
formatted?: string | null;
|
formatted?: string | null;
|
||||||
|
short?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const display = computed(() => {
|
const display = computed(() => {
|
||||||
@ -16,7 +17,13 @@ const display = computed(() => {
|
|||||||
? Number.parseInt(props.amount, 10)
|
? Number.parseInt(props.amount, 10)
|
||||||
: props.amount;
|
: props.amount;
|
||||||
|
|
||||||
return `Rp ${formatRupiah(Number.isFinite(numericAmount) ? numericAmount : 0)}`;
|
const safeAmount = Number.isFinite(numericAmount) ? numericAmount : 0;
|
||||||
|
|
||||||
|
if (props.short) {
|
||||||
|
return `Rp ${formatRupiahShort(safeAmount)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `Rp ${formatRupiah(safeAmount)}`;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user