From 582409e7cb1598b65bee6d1023b77620bb3791af Mon Sep 17 00:00:00 2001
From: mat <github@matdoes.dev>
Date: Sun, 20 Feb 2022 02:16:09 -0600
Subject: add inventories

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

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

diff --git a/src/lib/sections/Inventories.svelte b/src/lib/sections/Inventories.svelte
new file mode 100644
index 0000000..49a00c2
--- /dev/null
+++ b/src/lib/sections/Inventories.svelte
@@ -0,0 +1,55 @@
+<script lang="ts">
+	import Inventory from '$lib/minecraft/Inventory.svelte'
+	import { fade } from 'svelte/transition'
+	import { cleanId } from '$lib/utils'
+
+	export let data
+	export let pack
+
+	let displayingInventories: string[] = []
+	for (const inventoryName in data.member.inventories)
+		if (inventoryName !== 'armor') displayingInventories.push(inventoryName)
+
+	let selectedInventoryName: string = displayingInventories[0]
+</script>
+
+<div id="inventory-tabs">
+	{#each displayingInventories as inventoryName}
+		<button
+			class="inventory-tab"
+			class:inventory-tab-active={inventoryName === selectedInventoryName}
+			on:click={() => (selectedInventoryName = inventoryName)}
+		>
+			{cleanId(inventoryName)}
+		</button>
+	{/each}
+</div>
+{#each displayingInventories as inventoryName}
+	{#if inventoryName === selectedInventoryName}
+		<div id={inventoryName} class="inventory-content">
+			<Inventory items={data.member.inventories[inventoryName]} {pack} />
+		</div>
+	{/if}
+{/each}
+
+<style>
+	#inventory-tabs {
+		margin-bottom: 1em;
+		overflow: hidden;
+		border-radius: 1em;
+		max-width: max-content;
+		width: min(40em, 100%);
+	}
+	.inventory-tab {
+		background-color: var(--theme-lighter-background);
+		color: var(--theme-main-text);
+		border: none;
+		padding: 1em;
+		cursor: pointer;
+		transition-duration: 200ms;
+	}
+	.inventory-tab:hover,
+	.inventory-tab-active {
+		background-color: var(--theme-lightest-background);
+	}
+</style>
-- 
cgit 

