Skip to content

A self-hosted media server and file management system

feat: skeleton ui for folder view

aminnausinee492e396943
diff --git a/resources/js/components/folders/FolderHeader.vue b/resources/js/components/folders/FolderHeader.vue
index cc3436c3..ad0dec34 100644
--- a/resources/js/components/folders/FolderHeader.vue
+++ b/resources/js/components/folders/FolderHeader.vue
@@ -1,33 +1,43 @@
<script setup lang="ts">
-import type { FolderResource } from '@/contracts/media';
-
import { handleStorageURL, toTimeSpan } from '@/service/util';
-import { inject } from 'vue';
+import { useContentStore } from '@/stores/ContentStore';
+import { storeToRefs } from 'pinia';
+import ProIconsPhotoOff from '@/components/icons/ProIconsPhotoOff.vue';
import FolderTab from '@/components/folders/FolderTab.vue';
import LazyImage from '@/components/lazy/LazyImage.vue';
-const data = inject<FolderResource>('data');
+const { stateFolder, isLoadingContent } = storeToRefs(useContentStore());
</script>
<template>
<FolderTab class="h-fit w-full gap-0 p-0">
<div
- class="ring-r-default/5 flex h-52 items-end overflow-clip rounded-t-xl bg-cover text-white ring-1 lg:h-64"
+ class="ring-r-default/5 flex min-h-52 items-end overflow-clip rounded-t-xl bg-cover text-white ring-1 lg:h-64"
:style="{
- 'background-image': `url(${data?.series?.banner_image?.path ?? 'https://s4.anilist.co/file/anilistcdn/user/banner/b6792701-mBLPRvzr3xPL.jpg'})`,
+ 'background-image': `url(${stateFolder.series?.banner_image?.path ?? 'https://s4.anilist.co/file/anilistcdn/user/banner/b6792701-mBLPRvzr3xPL.jpg'})`,
}"
>
- <div class="flex w-full flex-wrap items-end gap-4 bg-linear-to-b from-transparent to-neutral-950/40 p-3 text-center">
+ <div v-if="!isLoadingContent && stateFolder.id" class="flex w-full flex-wrap items-end gap-4 bg-linear-to-b from-transparent to-neutral-950/40 p-3 text-center">
<LazyImage
:wrapper-class="'relative h-fit w-fit'"
class="aspect-2-3 mx-auto w-24 min-w-24 rounded-md object-cover"
- :src="data?.series?.poster_image?.path ?? handleStorageURL(data?.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'"
+ :src="stateFolder?.series?.poster_image?.path ?? handleStorageURL(stateFolder?.series?.thumbnail_url) ?? '/storage/thumbnails/default.webp'"
alt="profile"
/>
<div class="text-centre flex flex-1 flex-wrap items-end justify-center gap-1 sm:pb-2">
- <h2 class="w-full text-2xl text-balance capitalize sm:flex-1 sm:text-left">{{ data?.title }}</h2>
- <p class="text-sm">Created: {{ toTimeSpan(data?.created_at || '', '') }}</p>
+ <h2 class="w-full text-2xl text-balance capitalize sm:flex-1 sm:text-left">{{ stateFolder?.title }}</h2>
+ <p class="text-sm">Created: {{ toTimeSpan(stateFolder?.created_at || '', '') }}</p>
+ </div>
+ </div>
+ <div v-else class="flex w-full flex-wrap items-end gap-4 bg-linear-to-b from-transparent to-neutral-950/40 p-3 text-center">
+ <div class="aspect-2-3 bg-surface-3 mx-auto flex w-24 min-w-24 items-center justify-center rounded-md">
+ <ProIconsPhotoOff class="text-foreground-1 dark:text-foreground-0 size-6 animate-pulse" />
+ </div>
+
+ <div class="text-centre flex flex-1 animate-pulse flex-wrap items-end justify-center gap-1 sm:justify-between sm:pb-2">
+ <div class="xs:mx-10 h-8 w-full rounded bg-white/80 text-2xl text-balance capitalize sm:mx-0 sm:max-w-1/3 sm:flex-1 sm:text-left"></div>
+ <div class="h-5 w-20 rounded bg-neutral-200/80 sm:w-12"></div>
</div>
</div>
</div>
diff --git a/resources/js/components/folders/FolderTabSkeleton.vue b/resources/js/components/folders/FolderTabSkeleton.vue
new file mode 100644
index 00000000..b342f9e4
--- /dev/null
+++ b/resources/js/components/folders/FolderTabSkeleton.vue
@@ -0,0 +1,51 @@
+<script setup lang="ts">
+import FolderTab from '@/components/folders/FolderTab.vue';
+import TableSkeleton from '../skeleton/composites/TableSkeleton.vue';
+</script>
+<template>
+ <FolderTab class="animate-pulse">
+ <div class="flex flex-col gap-1">
+ <div class="flex flex-wrap justify-between gap-x-2 gap-y-1">
+ <div class="flex flex-1 flex-col gap-2">
+ <div class="bg-foreground-1/20 h-7 w-48 rounded"></div>
+ <div class="bg-foreground-1/10 h-4 w-32 rounded"></div>
+ </div>
+ <div class="flex flex-col items-end gap-2">
+ <div class="bg-foreground-1/20 h-7 w-16 rounded"></div>
+ <div class="bg-foreground-1/10 h-4 w-28 rounded"></div>
+ </div>
+ </div>
+
+ <div class="mt-1 flex flex-wrap gap-1">
+ <div class="bg-foreground-1/10 h-5 w-16 rounded-xl"></div>
+ <div class="bg-foreground-1/10 h-5 w-14 rounded-xl"></div>
+ <div class="bg-foreground-1/10 h-5 w-20 rounded-xl"></div>
+ </div>
+ </div>
+
+ <div class="mt-1 flex flex-col gap-1.5">
+ <div class="bg-foreground-1/10 h-3 w-full rounded"></div>
+ <div class="bg-foreground-1/10 h-3 w-full rounded"></div>
+ <div class="bg-foreground-1/10 h-3 w-full rounded"></div>
+ <div class="bg-foreground-1/10 h-3 w-3/4 rounded"></div>
+ </div>
+
+ <div class="mt-2 grid grid-cols-2 gap-2 @sm:grid-cols-4">
+ <div v-for="i in 4" :key="i" class="bg-surface-3 flex flex-col items-center gap-1.5 rounded-lg p-3">
+ <div class="bg-foreground-1/20 h-5 w-12 rounded"></div>
+ <div class="bg-foreground-1/10 h-3 w-16 rounded"></div>
+ </div>
+ </div>
+ </FolderTab>
+ <div class="flex flex-1 animate-pulse flex-col gap-3 @[40rem]:flex-row">
+ <FolderTab class="w-full @[40rem]:max-w-40">
+ <div v-for="i in 5" :key="i" class="mt-1 flex flex-wrap gap-1">
+ <div class="bg-foreground-1/20 h-4 w-14 rounded-xl"></div>
+ <div class="bg-foreground-1/10 h-3 w-20 rounded-xl"></div>
+ </div>
+ </FolderTab>
+ <FolderTab class="flex-1 gap-2">
+ <TableSkeleton class="*:*:min-h-0! *:animate-none" :table-length="4" />
+ </FolderTab>
+ </div>
+</template>
diff --git a/resources/js/components/skeleton/composites/TableSkeleton.vue b/resources/js/components/skeleton/composites/TableSkeleton.vue
index 506751dd..e6298df9 100644
--- a/resources/js/components/skeleton/composites/TableSkeleton.vue
+++ b/resources/js/components/skeleton/composites/TableSkeleton.vue
@@ -1,9 +1,13 @@
<script setup lang="ts">
+import { cn } from '@aminnausin/cedar-ui';
+
import SkeletonCard from '@/components/skeleton/cards/SkeletonCard.vue';
+
+withDefaults(defineProps<{ tableLength?: number }>(), { tableLength: 12 });
</script>
<template>
- <div class="contents">
- <SkeletonCard v-for="i in 12" :key="i" />
+ <div :class="cn('contents', $attrs.class)">
+ <SkeletonCard v-for="i in tableLength" :key="i" />
</div>
</template>