From 91cfd5d306aedb4bdcc1c4045611bee7d2270462 Mon Sep 17 00:00:00 2001
From: Wolfgang Müller
Date: Sun, 19 Jan 2025 18:30:28 +0100
Subject: frontend: Add basic statistics page

---
 frontend/src/lib/statistics/Stat.svelte | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 frontend/src/lib/statistics/Stat.svelte

(limited to 'frontend/src/lib/statistics/Stat.svelte')

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>
-- 
cgit v1.2.3-2-gb3c3

