Skip to content

Commit

Permalink
Added Skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
fishylunar committed Nov 25, 2024
1 parent 6a94f7f commit 93b8f22
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/components/OdinEventsTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { OdinEvent, OdinEvents } from '@/logic/Odin';
import { Table, TableBody, TableRow, TableCell, TableHeader } from "@/components/ui/table";
import { Skeleton } from "@/components/ui/skeleton";

interface OdinEventsTableProps {
events: OdinEvents | null;
Expand All @@ -18,14 +19,35 @@ export function OdinEventsTable({ events }: OdinEventsTableProps) {
</TableRow>
</TableHeader>
<TableBody>
{events && events.map((odinEvent: OdinEvent) => (
<TableRow key={odinEvent.timestamp}>
<TableCell>{odinEvent.responder}</TableCell>
<TableCell>{odinEvent.station}</TableCell>
<TableCell>{odinEvent.message}</TableCell>
<TableCell>{odinEvent.timestamp}</TableCell>
</TableRow>
))}
{events ? (
events.map((odinEvent: OdinEvent) => (
<TableRow key={odinEvent.timestamp}>
<TableCell>{odinEvent.responder}</TableCell>
<TableCell>{odinEvent.station}</TableCell>
<TableCell>{odinEvent.timestamp}</TableCell>
<TableCell>{odinEvent.message}</TableCell>
</TableRow>
))
) : (
Array(20)
.fill(null)
.map((_, index) => (
<TableRow key={index}>
<TableCell>
<Skeleton className="w-20 h-4" />
</TableCell>
<TableCell>
<Skeleton className="w-20 h-4" />
</TableCell>
<TableCell>
<Skeleton className="w-20 h-4" />
</TableCell>
<TableCell>
<Skeleton className="w-40 h-4" />
</TableCell>
</TableRow>
))
)}
</TableBody>
</Table>
</>
Expand Down
15 changes: 15 additions & 0 deletions src/components/ui/skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { cn } from "@/lib/utils"

function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn("animate-pulse rounded-md bg-muted", className)}
{...props}
/>
)
}

export { Skeleton }

0 comments on commit 93b8f22

Please sign in to comment.