Skip to content

Commit 42af986

Browse files
authored
Merge pull request #48 from anamiikajha/show-at-bottom
feat: show TopLoader bottom
2 parents 2e2abbf + 91d74de commit 42af986

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Next Js TopLoader
22

3-
- A Next.js Top Loading Bar component made using nprogress, works with Next.js 13.
3+
- A Next.js Top Loading Bar component made using nprogress, works with Next.js 14.
44

55
## Install
66

@@ -90,8 +90,9 @@ If no props are passed to `<NextTopLoader />`, below is the default configuratio
9090
- `crawl`: auto incrementing behavior for the TopLoader.
9191
- `showSpinner`: to show spinner or not.
9292
- `shadow`: a smooth shadow for the TopLoader. (set to `false` to disable it)
93-
- `template`: to include custom HTML attributes for the TopLoader.
93+
- `template`: to include custom HTML attributes for the TopLoader.
9494
- `zIndex`: defines zIndex for the TopLoader.
95+
- `showAtBottom`: To show the TopLoader at bottom. (increase height for the TopLoader to ensure it's visibility at the mobile devices)
9596

9697
---
9798

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-toploader",
3-
"version": "1.5.3",
3+
"version": "1.6.3",
44
"description": "A Next.js Top Loading Bar component made using nprogress, works with Next.js 13.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -18,6 +18,7 @@
1818
"Next",
1919
"Next TopLoader",
2020
"Next.js",
21+
"Next.js 14",
2122
"Next.js 13",
2223
"Nprogress",
2324
"React",

src/index.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ export type NextTopLoaderProps = {
6666
* <div class="spinner" role="spinner"><div class="spinner-icon"></div></div>"
6767
*/
6868
template?: string;
69-
/**
69+
/**
7070
* Defines zIndex for the TopLoader.
7171
* @default 1600
7272
*
7373
*/
7474
zIndex?: number;
75+
/**
76+
* To show the TopLoader at bottom.
77+
* @default false
78+
*
79+
*/
80+
showAtBottom?: boolean;
7581
};
7682

7783
const NextTopLoader = ({
@@ -86,6 +92,7 @@ const NextTopLoader = ({
8692
shadow,
8793
template,
8894
zIndex = 1600,
95+
showAtBottom = false,
8996
}: NextTopLoaderProps) => {
9097
const defaultColor = '#29d';
9198
const defaultHeight = 3;
@@ -101,9 +108,12 @@ const NextTopLoader = ({
101108
? `box-shadow:${shadow}`
102109
: `box-shadow:0 0 10px ${color},0 0 5px ${color}`;
103110

111+
// Check if to show at bottom
112+
const positionStyle = showAtBottom ? 'bottom: 0;' : 'top: 0;';
113+
104114
const styles = (
105115
<style>
106-
{`#nprogress{pointer-events:none}#nprogress .bar{background:${color};position:fixed;z-index:${zIndex};top:0;left:0;width:100%;height:${height}px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;${boxShadow};opacity:1;-webkit-transform:rotate(3deg) translate(0px,-4px);-ms-transform:rotate(3deg) translate(0px,-4px);transform:rotate(3deg) translate(0px,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:${zIndex};top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:${color};border-left-color:${color};border-radius:50%;-webkit-animation:nprogress-spinner 400ms linear infinite;animation:nprogress-spinner 400ms linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}`}
116+
{`#nprogress{pointer-events:none}#nprogress .bar{background:${color};position:fixed;z-index:${zIndex};${positionStyle}left:0;width:100%;height:${height}px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;${boxShadow};opacity:1;-webkit-transform:rotate(3deg) translate(0px,-4px);-ms-transform:rotate(3deg) translate(0px,-4px);transform:rotate(3deg) translate(0px,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:${zIndex};${positionStyle}right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:${color};border-left-color:${color};border-radius:50%;-webkit-animation:nprogress-spinner 400ms linear infinite;animation:nprogress-spinner 400ms linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}`}
107117
</style>
108118
);
109119

@@ -212,4 +222,5 @@ NextTopLoader.propTypes = {
212222
template: PropTypes.string,
213223
shadow: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
214224
zIndex: PropTypes.number,
225+
showAtBottom: PropTypes.bool,
215226
};

0 commit comments

Comments
 (0)