diff options
author | Wolfgang Müller | 2025-01-19 18:30:28 +0100 |
---|---|---|
committer | Wolfgang Müller | 2025-01-19 23:36:36 +0100 |
commit | 91cfd5d306aedb4bdcc1c4045611bee7d2270462 (patch) | |
tree | 1e88be6e7757169a9cae7651bc7c4d558e7f7604 /frontend/src/lib/statistics | |
parent | 261ceaa057742fc70c52885021221d7a89c28af7 (diff) | |
download | hircine-91cfd5d306aedb4bdcc1c4045611bee7d2270462.tar.gz |
frontend: Add basic statistics page
Diffstat (limited to 'frontend/src/lib/statistics')
-rw-r--r-- | frontend/src/lib/statistics/Stat.svelte | 27 | ||||
-rw-r--r-- | frontend/src/lib/statistics/StatGroup.svelte | 12 |
2 files changed, 39 insertions, 0 deletions
diff --git a/frontend/src/lib/statistics/Stat.svelte b/frontend/src/lib/statistics/Stat.svelte new file mode 100644 index 0000000..c657526 --- /dev/null +++ b/frontend/src/lib/statistics/Stat.svelte @@ -0,0 +1,27 @@ +<script lang="ts"> + export let title: string; + export let value: number; + export let precision = 0; + export let unit = ''; + + function format(value: number) { + if (Number.isNaN(value) || !Number.isFinite(value)) { + return 0; + } + + if (Number.isInteger(value)) { + return value; + } else { + return value.toFixed(precision); + } + } +</script> + +<div class="flex flex-col"> + <h2 class="text-lg font-medium"> + {title} + </h2> + <span class="text-base font-medium"> + {format(value)}{unit} + </span> +</div> diff --git a/frontend/src/lib/statistics/StatGroup.svelte b/frontend/src/lib/statistics/StatGroup.svelte new file mode 100644 index 0000000..e1b97da --- /dev/null +++ b/frontend/src/lib/statistics/StatGroup.svelte @@ -0,0 +1,12 @@ +<script lang="ts"> + export let title; +</script> + +<section + class="flex flex-col gap-2 rounded bg-slate-900 p-2 font-medium shadow-md shadow-slate-950/30" +> + <h2 class="text-2xl">{title}</h2> + <div class="flex flex-row flex-wrap gap-10"> + <slot /> + </div> +</section> |