Skip to content

Commit e4096b4

Browse files
Marcos-Nacimentomarcodmc
authored andcommitted
Add new feature and creating LoadingSkeleton (SOS-RS#115)
* Add new feature and creating LoadingSkeleton
1 parent 3a8271e commit e4096b4

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
type LoadingSkeletonProps = {
2+
amountItems: number
3+
}
4+
5+
const LoadingSkeleton = ({ amountItems }: LoadingSkeletonProps) => {
6+
return (
7+
<div className="w-full">
8+
<ul className="grid grid-cols-1 gap-5 mt-4">
9+
{Array.from({length: amountItems,}).map((_, index) => (
10+
<li key={index} className="p-4 w-full border-2 border-border rounded-md space-y-3">
11+
<div className="flex justify-between items-center space-x-2">
12+
<div className="animate-pulse h-10 bg-[#ccc] rounded-md w-full max-w-sm" />
13+
<div className="animate-pulse h-10 bg-[#ccc] rounded-md w-10" />
14+
</div>
15+
16+
<div className="animate-pulse h-10 bg-[#ccc] rounded-md w-full max-w-xs" />
17+
18+
<div className="border-b border-[#ccc] opacity-25"/>
19+
20+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 md:grid-cols-4 gap-4 mt-5">
21+
{Array.from({length: 7}).map((_, index) => (
22+
<div
23+
key={index}
24+
className="animate-pulse h-8 bg-[#ccc] rounded-full w-full"
25+
/>
26+
))}
27+
</div>
28+
29+
<div className="border-b border-[#ccc] opacity-25"/>
30+
31+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 md:grid-cols-4 gap-4 mt-5">
32+
{Array.from({length: 7}).map((_, index) => (
33+
<div
34+
key={index}
35+
className="animate-pulse h-8 bg-[#ccc] rounded-full w-full"
36+
/>
37+
))}
38+
</div>
39+
</li>
40+
))}
41+
</ul>
42+
</div>
43+
)
44+
}
45+
46+
export { LoadingSkeleton }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { LoadingSkeleton } from "./LoadingSkeleton";
2+
3+
export { LoadingSkeleton }

src/pages/Home/components/ShelterListView/ShelterListView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Fragment } from 'react';
2-
import { CircleAlert, ListFilter, Loader } from 'lucide-react';
2+
import { CircleAlert, ListFilter } from 'lucide-react';
33

44
import {
55
Alert,
@@ -11,6 +11,7 @@ import { Button } from '@/components/ui/button';
1111
import { cn } from '@/lib/utils';
1212
import { IShelterListViewProps } from './types';
1313
import { useSearchParams } from 'react-router-dom';
14+
import { LoadingSkeleton } from '@/components/LoadingSkeleton';
1415

1516
const ShelterListView = React.forwardRef<HTMLDivElement, IShelterListViewProps>(
1617
(props, ref) => {
@@ -73,7 +74,7 @@ const ShelterListView = React.forwardRef<HTMLDivElement, IShelterListViewProps>(
7374
</div>
7475
<main ref={ref} className="flex flex-col gap-4" {...rest}>
7576
{loading ? (
76-
<Loader className="justify-self-center self-center w-5 h-5 animate-spin" />
77+
<LoadingSkeleton amountItems={4}/>
7778
) : data.length === 0 ? (
7879
<NoFoundSearch />
7980
) : (

0 commit comments

Comments
 (0)