-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(item): add dialog for item details
- Loading branch information
Showing
3 changed files
with
118 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,21 @@ | ||
<script lang="ts"> | ||
import Item from "$lib/components/Item.svelte"; | ||
import type { IsHover } from "$lib/hooks/is-hover.svelte"; | ||
import type { ProcessedSkyBlockItem } from "$types/stats"; | ||
import { Avatar, Collapsible } from "bits-ui"; | ||
import { getContext } from "svelte"; | ||
import { writable } from "svelte/store"; | ||
import { slide } from "svelte/transition"; | ||
import { Avatar } from "bits-ui"; | ||
export let wardrobeItems: ProcessedSkyBlockItem[]; | ||
let { wardrobeItems }: { wardrobeItems: ProcessedSkyBlockItem[] } = $props(); | ||
const highestItem = wardrobeItems.find((piece) => piece && piece.display_name); | ||
const pieces = ["helmet", "chestplate", "leggings", "boots"]; | ||
const isHover = getContext<IsHover>("isHover"); | ||
const expanded = writable<boolean>(false); | ||
if (!isHover.current) { | ||
expanded.set(true); | ||
} | ||
</script> | ||
|
||
<Collapsible.Root bind:open={$expanded} disabled={!isHover.current}> | ||
<Collapsible.Trigger asChild let:builder> | ||
<div use:builder.action {...builder} class="mt-2 flex flex-col gap-2"> | ||
{#if !$expanded} | ||
{#if highestItem} | ||
<Item piece={highestItem} /> | ||
{/if} | ||
{:else} | ||
<Collapsible.Content transition={slide} class="flex flex-col gap-2"> | ||
{#each wardrobeItems as piece, index} | ||
{#if piece && piece.display_name} | ||
<Item {piece} /> | ||
{:else} | ||
<Avatar.Root class="rounded-lg bg-background-lore p-2"> | ||
<Avatar.Image class="size-14" loading="eager" src={`/img/textures/item/empty_armor_slot_${pieces[index]}.png`} /> | ||
</Avatar.Root> | ||
{/if} | ||
{/each} | ||
</Collapsible.Content> | ||
{/if} | ||
</div> | ||
</Collapsible.Trigger> | ||
</Collapsible.Root> | ||
<div class="mt-2 flex flex-col gap-2"> | ||
{#each wardrobeItems as piece, index} | ||
{#if piece && piece.display_name} | ||
<Item {piece} /> | ||
{:else} | ||
<Avatar.Root class="rounded-lg bg-background-lore p-2"> | ||
<Avatar.Image class="size-14" loading="eager" src={`/img/textures/item/empty_armor_slot_${pieces[index]}.png`} /> | ||
</Avatar.Root> | ||
{/if} | ||
{/each} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters