diff --git a/src/lib/components/atoms/RowVirtualizer.svelte b/src/lib/components/atoms/RowVirtualizer.svelte new file mode 100644 index 0000000..e821c5f --- /dev/null +++ b/src/lib/components/atoms/RowVirtualizer.svelte @@ -0,0 +1,46 @@ + + +
+
+ {#each $virtualizer.getVirtualItems() as virtualItem (virtualItem.key)} +
+ {@render item(virtualItem.index)} +
+ {/each} +
+ {#if placeholder && $virtualizer.getVirtualItems().length === 0} + {@render placeholder()} + {/if} +
diff --git a/src/lib/components/atoms/index.ts b/src/lib/components/atoms/index.ts index 14b0849..61a0238 100644 --- a/src/lib/components/atoms/index.ts +++ b/src/lib/components/atoms/index.ts @@ -3,3 +3,4 @@ export * from "./buttons"; export * from "./divs"; export * from "./inputs"; export { default as Modal } from "./Modal.svelte"; +export { default as RowVirtualizer } from "./RowVirtualizer.svelte"; diff --git a/src/lib/components/organisms/Category/Category.svelte b/src/lib/components/organisms/Category/Category.svelte index ce3abcd..0d62b25 100644 --- a/src/lib/components/organisms/Category/Category.svelte +++ b/src/lib/components/organisms/Category/Category.svelte @@ -1,7 +1,7 @@ -
-
- {#each $virtualizer.getVirtualItems() as virtualRow (virtualRow.key)} - {@const row = rows[virtualRow.index]!} -
- {#if row.type === "header"} -

{row.label}

- {:else} -
- {#each row.items as { info }} - - {/each} -
- {/if} + + rows[index]!.type === "header" + ? 32 + : Math.ceil(rows[index]!.items.length / 4) * 181 + + (Math.ceil(rows[index]!.items.length / 4) - 1) * 4 + + 16} + class="flex flex-grow flex-col" +> + {#snippet item(index)} + {@const row = rows[index]!} + {#if row.type === "header"} +

{row.label}

+ {:else} +
+ {#each row.items as { info }} + + {/each}
- {/each} -
- {#if $virtualizer.getVirtualItems().length === 0} + {/if} + {/snippet} + {#snippet placeholder()}

{#if files.length === 0} @@ -144,5 +130,5 @@ {/if}

- {/if} -
+ {/snippet} + diff --git a/src/routes/(main)/directory/[[id]]/DirectoryEntries/DirectoryEntries.svelte b/src/routes/(main)/directory/[[id]]/DirectoryEntries/DirectoryEntries.svelte index a3e975e..f7ced96 100644 --- a/src/routes/(main)/directory/[[id]]/DirectoryEntries/DirectoryEntries.svelte +++ b/src/routes/(main)/directory/[[id]]/DirectoryEntries/DirectoryEntries.svelte @@ -1,7 +1,7 @@