Skip to content

Commit

Permalink
Improve loading states ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
wotschofsky committed Oct 21, 2023
1 parent b43b859 commit 9c7cf7b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
18 changes: 18 additions & 0 deletions app/lookup/[domain]/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type FC, Fragment } from 'react';

import { Skeleton } from '@/components/ui/skeleton';

const DomainError: FC = () => (
<div className="mt-12">
{Array.from({ length: 3 }).map((_, i) => (
<Fragment key={i}>
<Skeleton className="mb-4 mt-8 h-7 w-16 rounded-sm" />
{Array.from({ length: 3 }).map((_, i) => (
<Skeleton className="my-3 h-5 w-full rounded-sm" key={i} />
))}
</Fragment>
))}
</div>
);

export default DomainError;
9 changes: 6 additions & 3 deletions app/lookup/[domain]/whois/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Spinner } from '@/components/ui/spinner';
import { Skeleton } from '@/components/ui/skeleton';

const WhoisLoading = () => (
<div className="flex items-center justify-center">
<Spinner className="my-8" />
<div className="mt-12">
<Skeleton className="mb-4 mt-8 h-9 w-48 rounded-sm" />
{Array.from({ length: 10 }).map((_, i) => (
<Skeleton className="my-3 h-5 w-full rounded-sm" key={i} />
))}
</div>
);

Expand Down
15 changes: 15 additions & 0 deletions 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 };

1 comment on commit 9c7cf7b

@vercel
Copy link

@vercel vercel bot commented on 9c7cf7b Oct 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.