Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(sidenav): added skeleton loader (#1357)

Corentin Thomassetbad01b7fa216
diff --git a/.changeset/odd-chairs-begin.md b/.changeset/odd-chairs-begin.md
new file mode 100644
index 00000000..0ae55986
--- /dev/null
+++ b/.changeset/odd-chairs-begin.md
@@ -0,0 +1,5 @@
+---
+'@papra/app': patch
+---
+
+Added a skeleton loader in the sidenav organization picker when fetching organizations
diff --git a/apps/papra-client/src/modules/ui/components/skeleton.tsx b/apps/papra-client/src/modules/ui/components/skeleton.tsx
index 99c88ca2..4d50cc27 100644
--- a/apps/papra-client/src/modules/ui/components/skeleton.tsx
+++ b/apps/papra-client/src/modules/ui/components/skeleton.tsx
@@ -5,5 +5,5 @@ import { cn } from '@/modules/shared/style/cn';
export function Skeleton(props: ComponentProps<'div'>) {
const [local, rest] = splitProps(props, ['class']);
- return <div class={cn('animate-pulse rounded-md bg-primary/10', local.class)} {...rest} />;
+ return <div class={cn('animate-pulse rounded-md bg-muted', local.class)} {...rest} />;
}
diff --git a/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx b/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
index b0eecb60..30106eb3 100644
--- a/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
+++ b/apps/papra-client/src/modules/ui/layouts/organization.layout.tsx
@@ -22,6 +22,7 @@ import { UpgradeDialog } from '@/modules/subscriptions/components/upgrade-dialog
import { fetchOrganizationSubscription } from '@/modules/subscriptions/subscriptions.services';
import { SideNav } from '@/modules/ui/components/sidenav';
import { Button } from '../components/button';
+import { Skeleton } from '../components/skeleton';
import {
Select,
SelectContent,
@@ -204,62 +205,77 @@ const OrganizationLayoutSideNav: Component = () => {
footer={() => <UpgradeCTAFooter organizationId={params.organizationId} />}
header={() => (
<div class="p-4 pb-0 min-w-0 max-w-full">
- <Select
- class="w-full"
- options={[...(organizationsQuery.data?.organizations ?? []), { id: 'create' }]}
- optionValue="id"
- optionTextValue="name"
- value={organizationsQuery.data?.organizations.find(
- (organization) => organization.id === params.organizationId,
- )}
- onChange={(value) => {
- if (!value || value.id === params.organizationId) {
- return;
- }
-
- return (
- value &&
- (value.id === 'create'
- ? navigate('/organizations/create')
- : navigate(`/organizations/${value.id}`))
- );
- }}
- itemComponent={(props) =>
- props.item.rawValue.id === 'create' ? (
- <SelectItem class="cursor-pointer" item={props.item}>
- <div class="flex items-center gap-2 text-muted-foreground">
- <div class="i-tabler-plus size-4" />
- <div>{t('organizations.switcher.create')}</div>
- </div>
- </SelectItem>
- ) : (
- <SelectItem class="cursor-pointer" item={props.item}>
- {props.item.rawValue.name}
- </SelectItem>
- )
+ <Show
+ when={organizationsQuery.data}
+ fallback={
+ <div class="flex items-center gap-2 min-w-0 p-2 border rounded-lg">
+ <span class="p-1.5 rounded text-lg font-bold flex items-center bg-muted light:border dark:bg-primary/10 text-primary flex-shrink-0">
+ <div class="i-tabler-file-text size-5.5" />
+ </span>
+
+ <Skeleton class="h-4 flex-1" />
+ </div>
}
>
- <SelectTrigger
- class="hover:bg-accent/50 transition rounded-lg h-auto pl-2"
- caretIcon={<div class="i-tabler-chevron-down size-4 opacity-50 ml-2 flex-shrink-0" />}
+ <Select
+ class="w-full"
+ options={[...(organizationsQuery.data?.organizations ?? []), { id: 'create' }]}
+ optionValue="id"
+ optionTextValue="name"
+ value={organizationsQuery.data?.organizations.find(
+ (organization) => organization.id === params.organizationId,
+ )}
+ onChange={(value) => {
+ if (!value || value.id === params.organizationId) {
+ return;
+ }
+
+ return (
+ value &&
+ (value.id === 'create'
+ ? navigate('/organizations/create')
+ : navigate(`/organizations/${value.id}`))
+ );
+ }}
+ itemComponent={(props) =>
+ props.item.rawValue.id === 'create' ? (
+ <SelectItem class="cursor-pointer" item={props.item}>
+ <div class="flex items-center gap-2 text-muted-foreground">
+ <div class="i-tabler-plus size-4" />
+ <div>{t('organizations.switcher.create')}</div>
+ </div>
+ </SelectItem>
+ ) : (
+ <SelectItem class="cursor-pointer" item={props.item}>
+ {props.item.rawValue.name}
+ </SelectItem>
+ )
+ }
>
- <SelectValue<Organization | undefined> class="flex items-center gap-2 min-w-0">
- {(state) => (
- <>
- <span class="p-1.5 rounded text-lg font-bold flex items-center bg-muted light:border dark:bg-primary/10 text-primary transition flex-shrink-0">
- <div class="i-tabler-file-text size-5.5" />
- </span>
-
- <span class="truncate text-base font-medium">
- {state.selectedOption()?.name}
- </span>
- </>
- )}
- </SelectValue>
- </SelectTrigger>
-
- <SelectContent />
- </Select>
+ <SelectTrigger
+ class="hover:bg-accent/50 transition rounded-lg h-auto pl-2"
+ caretIcon={
+ <div class="i-tabler-chevron-down size-4 opacity-50 ml-2 flex-shrink-0" />
+ }
+ >
+ <SelectValue<Organization | undefined> class="flex items-center gap-2 min-w-0">
+ {(state) => (
+ <>
+ <span class="p-1.5 rounded text-lg font-bold flex items-center bg-muted light:border dark:bg-primary/10 text-primary transition flex-shrink-0">
+ <div class="i-tabler-file-text size-5.5" />
+ </span>
+
+ <span class="truncate text-base font-medium">
+ {state.selectedOption()?.name}
+ </span>
+ </>
+ )}
+ </SelectValue>
+ </SelectTrigger>
+
+ <SelectContent />
+ </Select>
+ </Show>
</div>
)}
/>