-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* A utility module for managing the page loader state. | ||
* | ||
* @return {showLoader, hideLoader} | ||
* @example | ||
* const pageLoader = usePageLoader(); | ||
* pageLoader.showLoader(); // Display the page loader | ||
* pageLoader.hideLoader(); // Hide the page loader | ||
*/ | ||
const usePageLoader = () => { | ||
const body = document.body; | ||
const ACTIVE_CLASS = 'page-loader-active'; | ||
|
||
/** | ||
* Show the page loader. | ||
* | ||
* @method showLoader | ||
* @returns {void} | ||
*/ | ||
const showLoader = () => { | ||
body.classList.add(ACTIVE_CLASS); | ||
}; | ||
|
||
/** | ||
* Hide the page loader. | ||
* | ||
* @method hideLoader | ||
* @returns {void} | ||
*/ | ||
const hideLoader = () => { | ||
body.classList.remove(ACTIVE_CLASS); | ||
}; | ||
|
||
return { | ||
showLoader, | ||
hideLoader, | ||
}; | ||
}; | ||
|
||
export default usePageLoader; |
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