From cd982e64595ab47a5fa71a40f8249893dbf867df Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Wed, 16 Feb 2022 22:13:11 +0000
Subject: add

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

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

diff --git a/src/lib/sections/Skills.svelte b/src/lib/sections/Skills.svelte
new file mode 100644
index 0000000..790da6d
--- /dev/null
+++ b/src/lib/sections/Skills.svelte
@@ -0,0 +1,64 @@
+<script lang="ts">
+	import Tooltip from '$lib/Tooltip.svelte'
+	import { cleanId, formatNumber } from '$lib/utils'
+
+	const skillImages = {
+		runecrafting: 'https://cdn.matdoes.dev/images/runescape/runecrafting.webp',
+		alchemy: 'https://cdn.matdoes.dev/images/runescape/herblore.webp',
+		combat: 'https://cdn.matdoes.dev/images/runescape/attack.webp',
+		enchanting: 'https://cdn.matdoes.dev/images/runescape/magic.webp',
+		foraging: 'https://cdn.matdoes.dev/images/runescape/woodcutting.webp',
+		mining: 'https://cdn.matdoes.dev/images/runescape/mining.webp',
+		taming: 'https://cdn.matdoes.dev/images/runescape/hunter.webp',
+		farming: 'https://cdn.matdoes.dev/images/runescape/farming.webp',
+		fishing: 'https://cdn.matdoes.dev/images/runescape/fishing.webp',
+		carpentry: 'https://cdn.matdoes.dev/images/runescape/construction.webp',
+	}
+
+	export let data
+</script>
+
+<ul>
+	{#each data.member.skills as skill}
+		<li
+			class="list-item-with-icon"
+			style="background: url({skillImages[skill.name]}) 0 0/1em no-repeat"
+		>
+			<Tooltip>
+				<span slot="tooltip">
+					{#if skill.levelXpRequired !== null}
+						{Math.round((skill.levelXp / skill.levelXpRequired) * 100)}% to next level, {Math.round(
+							skill.levelXp
+						).toLocaleString()}/{formatNumber(skill.levelXpRequired, 3)} xp
+					{:else}
+						{Math.round(skill.levelXp).toLocaleString()} extra xp
+					{/if}
+				</span>
+				<span>
+					{cleanId(skill.name)}
+					<span class="skill-level" class:skill-maxed={skill.level === skill.maxLevel}>
+						{skill.level}
+					</span>
+				</span>
+			</Tooltip>
+		</li>
+	{/each}
+</ul>
+
+<style>
+	.skill-level {
+		opacity: 0.9;
+	}
+	.skill-maxed {
+		color: #0e0;
+		opacity: 1;
+	}
+	.list-item-with-icon {
+		list-style: none;
+		padding-left: 1.2em;
+		position: relative;
+		right: 1.2em;
+		image-rendering: crisp-edges;
+		image-rendering: pixelated;
+	}
+</style>
-- 
cgit 

