forked from rishipurwar1/FrontendPro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rishipurwar1#246 from rishipurwar1/development
Add top-loader
- Loading branch information
Showing
6 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useState, useEffect, useCallback } from "react" | ||
import Router from "next/router" | ||
|
||
const Loader = () => { | ||
const [loading, setLoading] = useState(false) | ||
const [width, setWidth] = useState(0) | ||
|
||
const handleRouteChangeStart = useCallback(() => setLoading(true), []) | ||
const handleRouteChangeEnd = useCallback(() => { | ||
setLoading(false) | ||
setWidth(100) | ||
}, []) | ||
|
||
useEffect(() => { | ||
Router.events.on("routeChangeStart", handleRouteChangeStart) | ||
Router.events.on("routeChangeComplete", handleRouteChangeEnd) | ||
Router.events.on("routeChangeError", handleRouteChangeEnd) | ||
|
||
return () => { | ||
Router.events.off("routeChangeStart", handleRouteChangeStart) | ||
Router.events.off("routeChangeComplete", handleRouteChangeEnd) | ||
Router.events.off("routeChangeError", handleRouteChangeEnd) | ||
} | ||
}, [handleRouteChangeStart, handleRouteChangeEnd]) | ||
|
||
useEffect(() => { | ||
if (loading) { | ||
const timer = setInterval(() => { | ||
setWidth((oldWidth) => { | ||
const newWidth = oldWidth + Math.round(Math.random() * 10) | ||
return Math.min(newWidth, 90) | ||
}) | ||
}, 100) | ||
return () => clearInterval(timer) | ||
} | ||
}, [loading]) | ||
|
||
useEffect(() => { | ||
if (!loading && width === 100) { | ||
const timer = setTimeout(() => { | ||
setWidth(0) | ||
}, 100) | ||
return () => clearTimeout(timer) | ||
} | ||
}, [loading, width]) | ||
|
||
return ( | ||
<div | ||
className={`absolute top-0 left-0 h-0.5 bg-gradient-to-r from-pink-500 via-red-500 to-yellow-500 rounded-sm transition-width duration-100 ease-in-out ${ | ||
loading ? "w-1/2" : "w-full" | ||
}`} | ||
style={{ width: `${width}%` }} | ||
/> | ||
) | ||
} | ||
|
||
export default Loader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import Image from "next/image" | ||
import james from ".././../assets/images/james.png" | ||
import Icons from "../SvgIcons/Icons" | ||
|
||
const Testimonial = () => { | ||
return ( | ||
<div className="relative rounded-lg bg-gray-800 border border-gray-700 p-8 mt-32 overflow-hidden"> | ||
<Icons.Quote | ||
className="rotate-180 absolute -top-12 -left-6 z-0 text-gray-600" | ||
size={160} | ||
/> | ||
<div className="flex flex-col items-center md:items-start md:flex-row space-y-12 md:space-x-12 md:space-y-0"> | ||
<div className="flex-shrink-0 z-50"> | ||
<Image | ||
src={james} | ||
width={120} | ||
height={120} | ||
className="rounded-full" | ||
alt="James Q Quick" | ||
/> | ||
</div> | ||
<div className="z-50"> | ||
<p className="text-white sm:text-xl sm:leading-relaxed mb-4"> | ||
"Building projects is by far the best way to get better at programming, | ||
but most people don't know what to build. FrontendPro is a great resource | ||
for developers looking for new and exciting challenges to take their frontend | ||
development skills to the next level!" | ||
</p> | ||
<p className="text-white sm:text-xl sm:leading-relaxed"> | ||
<a | ||
href="https://twitter.com/jamesqquick" | ||
target="_blank" | ||
rel="noreferrer" | ||
className="font-bold hover:underline underline-offset-2" | ||
> | ||
James Q Quick | ||
</a> | ||
<span className="font-normal text-base text-gray-200"> | ||
, Software Developer & Youtuber with 178K+ subscribers | ||
</span> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Testimonial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters