Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add collections #27

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/layouts/stats/Main.svelte
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import Accessories from "$lib/sections/stats/Accessories.svelte";
import Armor from "$lib/sections/stats/Armor.svelte";
import Bestiary from "$lib/sections/stats/Bestiary.svelte";
import Collections from "$lib/sections/stats/Collections.svelte";
import Dungeons from "$lib/sections/stats/Dungeons.svelte";
import Inventory from "$lib/sections/stats/Inventory.svelte";
import Minions from "$lib/sections/stats/Minions.svelte";
@@ -36,6 +37,7 @@
<Slayer />
<Minions />
<Bestiary />
<Collections />
</main>

<svg xmlns="http://www.w3.org/2000/svg" height="0" width="0" style="position: fixed;">
62 changes: 62 additions & 0 deletions src/lib/sections/stats/Collections.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<script lang="ts">
import AdditionStat from "$lib/components/AdditionStat.svelte";
import Chip from "$lib/components/Chip.svelte";
import Items from "$lib/layouts/stats/Items.svelte";
import { cn } from "$lib/utils";
import type { Stats as StatsType } from "$types/stats";
import { format } from "numerable";
import { getContext } from "svelte";

const profile = getContext<StatsType>("profile");

const collections = profile.collections;
</script>

<Items title="Collections" class="flex-col">
<div slot="text">
<AdditionStat text="Maxed Collections" data="{collections.maxedCollections} / {collections.totalCollections}" />
</div>
{#each Object.entries(collections.categories) as [_, data]}
<div class="flex items-center gap-1 text-base font-semibold uppercase">
<h3 class="text-xl">{data.name}</h3>
{#if data.maxTiers === data.totalTiers}
<span class="text-gold">Max!</span>
{:else}
<span class="text-text/80">({data.maxTiers} / {data.totalTiers} max)</span>
{/if}
</div>

<div class="flex flex-wrap gap-4">
{#each data.items as item}
{@const hasUnlocked = item.amount}
{@const hasMaxed = item.tier === item.maxTier}
<Chip image={{ src: item.texture }} class={cn("h-fit w-fit", { "opacity-50": !hasUnlocked })} variant="tooltip">
<div class={cn("flex flex-col")}>
<div class="font-bold">
<span class={cn(hasMaxed ? "text-maxed" : "opacity-60")}>{item.name}</span>
<span class={cn({ "text-gold": hasMaxed })}>{item.tier}</span>
<div class="text-sm">
<span class="opacity-60">Amount:</span>
<span class="text-text">{format(item.amount)}</span>
</div>
</div>
</div>
<div slot="tooltip" class="text-sm font-bold">
<div class="mb-4">
{#each item.amounts as user}
<span class="opacity-85">
{user.username}:
</span>
<span class="text-text">{format(user.amount)}</span>
{/each}
</div>
<div>
<span class="opacity-85"> Total: </span>
<span class="text-text opacity-100">{format(item.amount)}</span>
</div>
</div>
</Chip>
{/each}
</div>
{/each}
</Items>