mirror of
https://github.com/immich-app/immich.git
synced 2026-03-22 14:59:26 +03:00
43 lines
1.1 KiB
Svelte
43 lines
1.1 KiB
Svelte
<script lang="ts">
|
|
import { ByteUnit } from '$lib/utils/byte-units';
|
|
import { Icon, LoadingSpinner, Text } from '@immich/ui';
|
|
|
|
interface Props {
|
|
icon: string;
|
|
title: string;
|
|
value?: number;
|
|
unit?: ByteUnit | undefined;
|
|
}
|
|
|
|
let { icon, title, value = undefined, unit = undefined }: Props = $props();
|
|
|
|
const zeros = $derived(() => {
|
|
if (value === undefined) {
|
|
return '';
|
|
}
|
|
const maxLength = 13;
|
|
const valueLength = value.toString().length;
|
|
const zeroLength = maxLength - valueLength;
|
|
|
|
return '0'.repeat(zeroLength);
|
|
});
|
|
</script>
|
|
|
|
<div class="flex h-35 w-full flex-col justify-between rounded-3xl bg-subtle text-primary p-5">
|
|
<div class="flex place-items-center gap-4">
|
|
<Icon {icon} size="40" />
|
|
<Text size="giant" fontWeight="medium">{title}</Text>
|
|
</div>
|
|
|
|
<div class="mx-auto font-mono text-2xl font-medium">
|
|
{#if value === undefined}
|
|
<LoadingSpinner />
|
|
{:else}
|
|
<span class="text-gray-300 dark:text-gray-600">{zeros()}</span><span>{value}</span>
|
|
{#if unit}
|
|
<code class="font-mono text-base font-normal">{unit}</code>
|
|
{/if}
|
|
{/if}
|
|
</div>
|
|
</div>
|