Skip to content

Commit

Permalink
fix: Improve Shopping cart skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroWave022 committed Sep 26, 2024
1 parent e5045af commit 4fe0e37
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 39 deletions.
26 changes: 6 additions & 20 deletions src/app/[locale]/(default)/storage/shopping-cart/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
import { ShoppingCartTableSkeleton } from '@/components/storage/ShoppingCartTableSkeleton';
import { Skeleton } from '@/components/ui/Skeleton';
import { useTranslations } from 'next-intl';

export default function ShoppingCartSkeleton() {
const t = useTranslations('storage.shoppingCart');
return (
<>
<div className='my-4'>
<Skeleton className='mx-auto h-14 w-1/2 rounded-full' />
<h1 className='mx-auto my-4 md:text-center'>{t('title')}</h1>
<ShoppingCartTableSkeleton />
<div className='my-6 space-y-4'>
<Skeleton className='mx-auto h-8 w-[250px]' />
<Skeleton className='h-1 w-full' />
<div className='grid grid-cols-3 gap-2'>
<div className='space-y-1'>
<Skeleton className='h-6 w-[100px]' />
<Skeleton className='h-12 w-full' />
</div>
<div className='space-y-1'>
<Skeleton className='h-6 w-[100px]' />
<Skeleton className='h-12 w-full' />
</div>
<div className='space-y-1'>
<Skeleton className='h-6 w-[100px]' />
<Skeleton className='h-12 w-full' />
</div>
</div>
<Skeleton className='mx-auto h-10 w-[300px]' />
<div className='relative my-4'>
<Skeleton className='mx-auto block h-10 w-[100px]' />
<Skeleton className='-translate-y-1/2 absolute top-1/2 right-3 h-10 w-[225px]' />
</div>
<Skeleton className='mx-auto h-10 w-[200px]' />
</div>
</>
);
Expand Down
2 changes: 0 additions & 2 deletions src/components/storage/ShoppingCartTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Input } from '@/components/ui/Input';
import {
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
Expand Down Expand Up @@ -63,7 +62,6 @@ function ShoppingCartTable({ t }: ShoppingCartTableProps) {

return (
<Table className='my-4'>
<TableCaption>{t.tableDescription}</TableCaption>
<TableHeader>
<TableRow>
<TableHead className='w-[80px]' />
Expand Down
65 changes: 48 additions & 17 deletions src/components/storage/ShoppingCartTableSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,57 @@
import { Skeleton } from '@/components/ui/Skeleton';
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from '@/components/ui/Table';
import { useTranslations } from 'next-intl';
import { useId } from 'react';

function ShoppingCartTableSkeleton() {
const t = useTranslations('storage.shoppingCart');
return (
<>
<div className='mt-4 grid grid-cols-10 gap-2'>
<Skeleton className='col-span-1 h-5 w-[100px]' key={useId()} />
<Skeleton className='col-span-3 h-5 w-[150px]' key={useId()} />
<Skeleton className='col-span-4 h-5 w-[150px]' key={useId()} />
<Skeleton className='col-span-2 h-5 w-[150px]' key={useId()} />
</div>
{Array.from({ length: 4 }).map(() => {
return (
<div key={useId()} className='my-4 grid grid-cols-10 gap-2'>
<Skeleton className='col-span-1 h-10' />
<Skeleton className='col-span-3 h-10' />
<Skeleton className='col-span-4 h-10' />
<Skeleton className='col-span-2 h-10' />
</div>
);
})}
<Skeleton className='mx-auto mt-2 h-5 w-[200px]' />
<Table className='my-4'>
<TableHeader>
<TableRow>
<TableHead className='w-[80px]'>
<Skeleton />
</TableHead>
<TableHead className='w-[150px]'>{t('productId')}</TableHead>
<TableHead>{t('productName')}</TableHead>
<TableHead>{t('location')}</TableHead>
<TableHead className='text-right'>{t('unitsAvailable')}</TableHead>
<TableHead className='w-[80px]' />
</TableRow>
</TableHeader>
<TableBody>
{Array.from({ length: 3 }).map(() => (
<TableRow key={useId()}>
<TableCell>
<Skeleton className='h-10 w-[80px]' />
</TableCell>
<TableCell>
<Skeleton className='h-4 w-[80px] rounded-lg' />
</TableCell>
<TableCell>
<Skeleton className='h-4 w-[80px] rounded-lg' />
</TableCell>
<TableCell>
<Skeleton className='h-4 w-[150px]' />
</TableCell>
<TableCell className='relative'>
<Skeleton className='ml-auto h-4 w-[30px]' />
</TableCell>
<TableCell>
<Skeleton className='h-8 w-8' />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</>
);
}
Expand Down

0 comments on commit 4fe0e37

Please sign in to comment.