|
1 | 1 | <script lang="ts"> |
2 | 2 | import { getPreferences } from "$ctx"; |
3 | | - import { SectionBoundary } from "$lib/components/sections"; |
4 | 3 | import { type ModelsStrippedItem } from "$lib/shared/api/orval-generated"; |
5 | | - import { getInventorySection } from "$lib/shared/api/skycrypt-api.remote"; |
6 | 4 | import { shouldShine } from "$lib/shared/helper"; |
7 | 5 | import type { Snippet } from "svelte"; |
8 | 6 |
|
9 | 7 | const preferences = getPreferences(); |
10 | 8 |
|
11 | | - let { uuid, profileId, inventoryId, gap, itemSnippet }: { uuid: string; profileId: string; inventoryId: string; gap: number; itemSnippet: Snippet<[ModelsStrippedItem]> } = $props(); |
| 9 | + let { inventoryId, gap, itemSnippet, items = [] }: { inventoryId: string; gap: number; itemSnippet: Snippet<[ModelsStrippedItem]>; items?: ModelsStrippedItem[] } = $props(); |
12 | 10 | </script> |
13 | 11 |
|
14 | | -<SectionBoundary promise={getInventorySection({ uuid, profileId, inventoryId })}> |
15 | | - {#snippet children(items)} |
16 | | - {#if items?.length ?? 0 > 0} |
17 | | - <div class="grid grid-cols-[repeat(9,minmax(1.875rem,4.875rem))] place-content-center gap-1 pt-5 @md:gap-1.5 @xl:gap-2"> |
18 | | - {#each items as item, index (index)} |
19 | | - {#if index > 0} |
20 | | - {#if index % gap === 0} |
21 | | - <hr class="col-span-full h-4 border-0" /> |
22 | | - {/if} |
| 12 | +{#snippet content(items: ModelsStrippedItem[] | undefined)} |
| 13 | + {#if items?.length ?? 0 > 0} |
| 14 | + <div class="grid grid-cols-[repeat(9,minmax(1.875rem,4.875rem))] place-content-center gap-1 pt-5 @md:gap-1.5 @xl:gap-2"> |
| 15 | + {#each items as item, index (index)} |
| 16 | + {#if index > 0} |
| 17 | + {#if index % gap === 0} |
| 18 | + <hr class="col-span-full h-4 border-0" /> |
23 | 19 | {/if} |
24 | | - {#if item.texture_path} |
25 | | - <div class="relative flex aspect-square items-center justify-center rounded-sm bg-text/4 data-[shine=true]:shine" data-shine={!preferences.performanceMode && shouldShine(item)}> |
26 | | - {@render itemSnippet(inventoryId === "inventory" ? ({ ...item, rarity: item.rarity ?? "uncommon" } as ModelsStrippedItem) : item)} |
27 | | - </div> |
28 | | - {:else} |
29 | | - <div class="aspect-square rounded-sm bg-text/4"></div> |
30 | | - {/if} |
31 | | - {/each} |
32 | | - </div> |
33 | | - {:else} |
34 | | - <p class="mt-2 space-x-0.5 text-center leading-6"> |
35 | | - No items found in the {inventoryId.replaceAll("_", " ")}. |
36 | | - </p> |
37 | | - {/if} |
38 | | - {/snippet} |
39 | | -</SectionBoundary> |
| 20 | + {/if} |
| 21 | + {#if item.texture_path} |
| 22 | + <div class="relative flex aspect-square items-center justify-center rounded-sm bg-text/4 data-[shine=true]:shine" data-shine={!preferences.performanceMode && shouldShine(item)}> |
| 23 | + {@render itemSnippet(inventoryId === "inventory" ? ({ ...item, rarity: item.rarity ?? "uncommon" } as ModelsStrippedItem) : item)} |
| 24 | + </div> |
| 25 | + {:else} |
| 26 | + <div class="aspect-square rounded-sm bg-text/4"></div> |
| 27 | + {/if} |
| 28 | + {/each} |
| 29 | + </div> |
| 30 | + {:else} |
| 31 | + <p class="mt-2 space-x-0.5 text-center leading-6"> |
| 32 | + No items found in the {inventoryId.replaceAll("_", " ")}. |
| 33 | + </p> |
| 34 | + {/if} |
| 35 | +{/snippet} |
| 36 | + |
| 37 | +{@render content(items)} |
0 commit comments