Skip to content

Commit 29a4d51

Browse files
committed
feat: add boxShadow prop
1 parent 94ffbec commit 29a4d51

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,6 @@ Holy Loader accepts the following props for customization:
109109
- `easing` (string): Specifies the easing function to use for the loading animation. Accepts any valid CSS easing string. Default: "ease".
110110
- `speed` (number): Sets the animation speed of the top-loading bar in milliseconds. Default: 200 milliseconds.
111111
- `zIndex` (number): Defines the z-index property of the top-loading bar, controlling its stacking order. Default: 2147483647.
112+
- `boxShadow` (string): Sets the box-shadow property of the top-loading bar. Default: "none".
112113

113114
Project inspired by [nextjs-toploader](https://github.com/TheSGJ/nextjs-toploader) & [nprogress](https://github.com/rstacruz/nprogress)

src/HolyProgress.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ type HolyProgressProps = {
4646
* Default: 2147483647
4747
*/
4848
zIndex: number;
49+
50+
/**
51+
* Specifies the shadow effect to be applied to the progress bar.
52+
* For example: "0 0 10px #59a2ff, 0 0 5px #59a2ff"
53+
*/
54+
boxShadow?: string;
4955
};
5056

5157
type TransformStrategy = 'translate3d' | 'translate' | 'margin';
@@ -76,6 +82,7 @@ export class HolyProgress {
7682
color: '#59a2ff',
7783
height: 4,
7884
zIndex: 2147483647,
85+
boxShadow: undefined,
7986
};
8087

8188
this.settings = { ...defaultSettings, ...customSettings };
@@ -320,6 +327,7 @@ export class HolyProgress {
320327
this.bar.style.left = '0';
321328
this.bar.style.transition = 'all 0 linear';
322329
this.bar.style.transform = 'translate3d(' + percentage + '%,0,0)';
330+
this.bar.style.boxShadow = this.settings.boxShadow ?? '';
323331

324332
document.body.appendChild(progress);
325333

src/index.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export interface HolyLoaderProps {
5050
* Default: 2147483647
5151
*/
5252
zIndex?: number;
53+
54+
/**
55+
* Specifies the shadow effect to be applied to the top-loading bar.
56+
* For example: "0 0 10px #59a2ff, 0 0 5px #59a2ff"
57+
*/
58+
boxShadow?: string;
5359
}
5460

5561
/**
@@ -110,6 +116,7 @@ const HolyLoader = ({
110116
easing = DEFAULTS.easing,
111117
speed = DEFAULTS.speed,
112118
zIndex = DEFAULTS.zIndex,
119+
boxShadow,
113120
}: HolyLoaderProps): JSX.Element => {
114121
React.useEffect(() => {
115122
let holyProgress: HolyProgress;
@@ -180,6 +187,7 @@ const HolyLoader = ({
180187
easing,
181188
speed,
182189
zIndex,
190+
boxShadow,
183191
});
184192

185193
document.addEventListener('click', handleClick);

0 commit comments

Comments
 (0)