Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/HolyProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ type HolyProgressProps = {
* Default: false
*/
showSpinner?: boolean;

/**
* Specifies the class attribute value.
* Default: undefined
*/
className?: string;
};

type TransformStrategy = 'translate3d' | 'translate' | 'margin';
Expand Down Expand Up @@ -78,6 +84,7 @@ export class HolyProgress {
zIndex: 2147483647,
boxShadow: undefined,
showSpinner: false,
className: undefined,
};

this.settings = { ...defaultSettings, ...customSettings };
Expand Down Expand Up @@ -320,6 +327,11 @@ export class HolyProgress {
this.bar.style.transform = 'translate3d(' + percentage + '%,0,0)';
this.bar.style.boxShadow = this.settings.boxShadow ?? '';

if (this.settings.className) {
this.bar.className = this.settings.className;
this.bar.style.removeProperty('background');
}

document.body.appendChild(progress);

return progress;
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export const DEFAULTS = {
speed: 200,
zIndex: 2147483647,
showSpinner: false,
className: undefined,
};
8 changes: 8 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export interface HolyLoaderProps {
* Default: false
*/
showSpinner?: boolean;

/**
* Specifies the class attribute value.
* Default: undefined
*/
className?: string;
}

/**
Expand Down Expand Up @@ -112,6 +118,7 @@ const HolyLoader = ({
zIndex = DEFAULTS.zIndex,
boxShadow,
showSpinner = DEFAULTS.showSpinner,
className = DEFAULTS.className,
}: HolyLoaderProps): null => {
React.useEffect(() => {
let holyProgress: HolyProgress;
Expand Down Expand Up @@ -189,6 +196,7 @@ const HolyLoader = ({
zIndex,
boxShadow,
showSpinner,
className,
});

document.addEventListener('click', handleClick);
Expand Down