-
-
Notifications
You must be signed in to change notification settings - Fork 560
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 #1599 from abhijithmuthyala/ssg
- Loading branch information
Showing
7 changed files
with
66 additions
and
45 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,23 +1,38 @@ | ||
import useLoader from 'hooks/useLoader' | ||
import { useEffect, useState } from 'react' | ||
import { Spinner } from './Spinner' | ||
|
||
const LOADER_TIMEOUT = 2000 | ||
|
||
export const Preloader = ({ | ||
backgroundColor, | ||
children, | ||
...rest | ||
...spinnerProps | ||
}: { | ||
children: JSX.Element | ||
backgroundColor: string | ||
color: string | ||
size: number | ||
}): JSX.Element => { | ||
const { loader } = useLoader() | ||
if (!loader) return children | ||
const [showLoader, setShowLoader] = useState(true) | ||
|
||
useEffect(() => { | ||
const timerId = setTimeout(() => { | ||
setShowLoader(false) | ||
}, LOADER_TIMEOUT) | ||
|
||
return () => {clearTimeout(timerId)} | ||
}, []) | ||
|
||
return ( | ||
<div | ||
className={`loader ${backgroundColor} fixed top-0 left-0 w-full h-screen flex justify-center items-center`} | ||
> | ||
<Spinner {...rest} /> | ||
</div> | ||
<> | ||
{children} | ||
{showLoader && ( | ||
<div | ||
className={`loader ${backgroundColor} fixed z-30 top-0 left-0 w-full h-screen flex justify-center items-center`} | ||
> | ||
<Spinner {...spinnerProps} /> | ||
</div> | ||
)} | ||
</> | ||
) | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
349e748
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
linkshub – ./
linkshub-rupali-codes.vercel.app
linkshub.vercel.app
linkshub-git-main-rupali-codes.vercel.app
www.linkshub.dev
linkshub.dev