From 13e5974114f759bae73f3bfd68c62ce9cfaf785e Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Sun, 20 Feb 2022 21:38:14 -0600
Subject: add more stuff to profile and fix bugs

---
 src/lib/sections/StatList.svelte | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 src/lib/sections/StatList.svelte

(limited to 'src/lib/sections/StatList.svelte')

diff --git a/src/lib/sections/StatList.svelte b/src/lib/sections/StatList.svelte
new file mode 100644
index 0000000..266ceb3
--- /dev/null
+++ b/src/lib/sections/StatList.svelte
@@ -0,0 +1,42 @@
+<!-- 
+	@component
+
+	A sorted list of a user's stats, with the total sometimes being at the top.
+-->
+<script lang="ts">
+	import { cleanId, millisecondsToTime } from '$lib/utils'
+	import type { StatItem } from '$lib/APITypes'
+
+	export let stats: StatItem[]
+</script>
+
+<ul>
+	{#each stats as stat}
+		<li class:total-stat={stat.categorizedName === 'total'}>
+			<span class="stat-name">{cleanId(stat.categorizedName)}</span>:
+			{#if stat.unit === 'time'}
+				{millisecondsToTime(stat.value)}
+			{:else}
+				{stat.value.toLocaleString()}
+			{/if}
+		</li>
+	{/each}
+</ul>
+
+<style>
+	.total-stat .stat-name {
+		font-weight: bold;
+	}
+
+	.total-stat {
+		font-size: 1.2em;
+		list-style-type: none;
+		position: relative;
+		right: 1em;
+		bottom: 0.2em;
+	}
+
+	ul {
+		margin-top: 0.5em;
+	}
+</style>
-- 
cgit 

