Skip to content

Commit

Permalink
Add: Toploader component for better page-load UX (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmRiteshKoushik authored Aug 28, 2024
1 parent 035ddba commit a6b738f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"next": "14.2.5",
"next-auth": "^4.24.7",
"next-themes": "^0.3.0",
"nextjs-toploader": "^1.6.12",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.52.2",
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Providers from '@/providers/providers';
import type { Metadata } from 'next';
import { Inter as FontSans } from 'next/font/google';
import './globals.css';
import TopLoader from '@/components/Toploader';

const fontSans = FontSans({
subsets: ['latin'],
Expand All @@ -29,6 +30,7 @@ export default async function RootLayout({
fontSans.variable
)}
>
<TopLoader />
<Providers>
<Header />
<main className="grow grid">{children}</main>
Expand Down
19 changes: 19 additions & 0 deletions src/components/Toploader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import NextTopLoader from 'nextjs-toploader';

export default function TopLoader() {
return (
<>
<NextTopLoader
color="#2299DD"
initialPosition={0.08}
crawlSpeed={200}
height={3}
crawl={true}
showSpinner={true}
easing="ease"
speed={200}
shadow="0 0 10px $2299DD, 0 0 5px #2299DD"
/>
</>
);
}

0 comments on commit a6b738f

Please sign in to comment.