2022-10-25 21:41:46 -05:00
|
|
|
<script lang="ts">
|
2024-06-14 19:27:46 +02:00
|
|
|
import { ByteUnit } from '$lib/utils/byte-units';
|
2025-09-16 21:40:43 +02:00
|
|
|
import { Code, Icon, Text } from '@immich/ui';
|
2023-01-09 22:40:54 +02:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
icon: string;
|
|
|
|
|
title: string;
|
|
|
|
|
value: number;
|
|
|
|
|
unit?: ByteUnit | undefined;
|
|
|
|
|
}
|
2022-10-25 21:41:46 -05:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let { icon, title, value, unit = undefined }: Props = $props();
|
|
|
|
|
|
|
|
|
|
const zeros = $derived(() => {
|
2023-07-01 00:50:47 -04:00
|
|
|
const maxLength = 13;
|
|
|
|
|
const valueLength = value.toString().length;
|
|
|
|
|
const zeroLength = maxLength - valueLength;
|
2023-02-10 23:17:39 +01:00
|
|
|
|
2023-07-01 00:50:47 -04:00
|
|
|
return '0'.repeat(zeroLength);
|
2024-11-14 08:43:25 -06:00
|
|
|
});
|
2022-10-25 21:41:46 -05:00
|
|
|
</script>
|
|
|
|
|
|
2025-05-09 18:56:41 -04:00
|
|
|
<div class="flex h-[140px] w-full flex-col justify-between rounded-3xl bg-subtle text-primary p-5">
|
|
|
|
|
<div class="flex place-items-center gap-4">
|
2025-09-16 21:40:43 +02:00
|
|
|
<Icon {icon} size="40" />
|
2025-09-16 00:28:42 -03:00
|
|
|
<Text size="large" fontWeight="bold" class="uppercase">{title}</Text>
|
2023-07-01 00:50:47 -04:00
|
|
|
</div>
|
2022-10-25 21:41:46 -05:00
|
|
|
|
2025-05-09 18:56:41 -04:00
|
|
|
<div class="relative mx-auto font-mono text-2xl font-semibold">
|
|
|
|
|
<span class="text-gray-400 dark:text-gray-600">{zeros()}</span><span>{value}</span>
|
2023-07-01 00:50:47 -04:00
|
|
|
{#if unit}
|
2025-05-19 09:32:23 -05:00
|
|
|
<Code color="muted" class="absolute -top-5 end-1 font-light">{unit}</Code>
|
2023-07-01 00:50:47 -04:00
|
|
|
{/if}
|
|
|
|
|
</div>
|
2022-10-25 21:41:46 -05:00
|
|
|
</div>
|