Skip to content

Commit

Permalink
chore: revert to non-react
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcru committed Dec 17, 2023
1 parent 245bdee commit 04d85b3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 46 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Also check out [Holy Time](https://github.com/badosz0/holy-time), yet another (t

- Easy to integrate with any React application.
- Highly customizable with sensible defaults.
- Utilizes NProgress for smooth, aesthetic progress indications.
- Utilizes a custom implementation for smooth, aesthetic progress indications.
- Supports dynamic configuration for color, height, speed, easing, and more.

## Installation
Expand Down Expand Up @@ -97,13 +97,11 @@ onClick={(e) => {

## API

Holy Loader accepts the following props for customization:
`<HolyLoader />` accepts the following props for customization:

- `color` (string): Specifies the color of the top-loading bar. Default: "#59a2ff" (a shade of blue).
- `initialPosition` (number): Sets the initial position of the top-loading bar as a percentage of the total width. Default: 0.08 (8% of the total width).
- `trickleSpeed` (number): Determines the delay speed for the incremental movement of the top-loading bar, in milliseconds. Default: 200 milliseconds.
- `height` (number | string): Defines the height of the top-loading bar in pixels or css unit. Default: 4 pixels.
- `trickle` (boolean): Enables or disables the automatic incremental movement of the top-loading bar. Default: true (enabled).
- `easing` (string): Specifies the easing function to use for the loading animation. Accepts any valid CSS easing string. Default: "ease".
- `speed` (number): Sets the animation speed of the top-loading bar in milliseconds. Default: 200 milliseconds.
- `zIndex` (number): Defines the z-index property of the top-loading bar, controlling its stacking order. Default: 2147483647.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "holy-loader",
"version": "2.1.0",
"version": "2.2.0",
"description": "Holy Loader is a lightweight, customizable top-loading progress bar component for React applications.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -27,7 +27,7 @@
"single-page-application"
],
"scripts": {
"build": "tsup && sed -i '' '1s/^/\"use client\";/' dist/index.js",
"build": "tsup",
"lint:fix": "eslint --ignore-path .eslintignore --fix --ext .js,.ts . && npm run format:fix",
"format:fix": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,tsx}\"",
"test": "vitest -c ./vitest.config.ts"
Expand Down
24 changes: 4 additions & 20 deletions src/HolyProgress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ type HolyProgressProps = {
*/
speed: number;

/**
* Specifies if the bar should increment automatically.
* Default: true
*/
trickle: boolean;

/**
* Specifies the speed of the automatic incrementation.
* Default: 200
*/
trickleSpeed: number;

/**
* Specifies the color of the progress bar.
* Default: '#59a2ff'
Expand Down Expand Up @@ -77,8 +65,6 @@ export class HolyProgress {
initialPosition: 0.08,
easing: 'linear',
speed: 200,
trickle: true,
trickleSpeed: 200,
color: '#59a2ff',
height: 4,
zIndex: 2147483647,
Expand Down Expand Up @@ -192,27 +178,25 @@ export class HolyProgress {
this.setTo(0);
}

if (this.settings.trickle) {
this.startTrickle();
}
this.startTrickle();

return this;
};

/**
* Performs automatic incrementation of the progress bar.
* This function is recursive and continues to increment the progress at intervals defined by `trickleSpeed`.
* This function is recursive and continues to increment the progress at intervals defined by `sppeed`.
* @private
*/
private readonly startTrickle = (): void => {
const run = (): void => {
if (this.status === null) return;

this.increment();
setTimeout(run, this.settings.trickleSpeed);
setTimeout(run, this.settings.speed);
};

setTimeout(run, this.settings.trickleSpeed);
setTimeout(run, this.settings.speed);
};

/**
Expand Down
2 changes: 0 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
export const DEFAULTS = {
color: '#59a2ff',
initialPosition: 0.08,
trickleSpeed: 200,
height: 4,
trickle: true,
easing: 'ease',
speed: 200,
zIndex: 2147483647,
Expand Down
18 changes: 2 additions & 16 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import * as React from 'react';
import { HolyProgress } from './HolyProgress';
import { DEFAULTS } from './constants';
Expand All @@ -15,24 +17,12 @@ export interface HolyLoaderProps {
*/
initialPosition?: number;

/**
* Determines the delay speed for the incremental movement of the top-loading bar, in milliseconds.
* Default: 200 milliseconds
*/
trickleSpeed?: number;

/**
* Specifies the height of the top-loading bar in either pixels (number) or css unit (string).
* Default: 4 pixels
*/
height?: number | string;

/**
* Enables or disables the automatic incremental movement of the top-loading bar.
* Default: true (enabled)
*/
trickle?: boolean;

/**
* Specifies the easing function to use for the loading animation. Accepts any valid CSS easing string.
* Default: "ease"
Expand Down Expand Up @@ -110,9 +100,7 @@ export const isSameHost = (currentUrl: string, newUrl: string): boolean => {
const HolyLoader = ({
color = DEFAULTS.color,
initialPosition = DEFAULTS.initialPosition,
trickleSpeed = DEFAULTS.trickleSpeed,
height = DEFAULTS.height,
trickle = DEFAULTS.trickle,
easing = DEFAULTS.easing,
speed = DEFAULTS.speed,
zIndex = DEFAULTS.zIndex,
Expand Down Expand Up @@ -181,8 +169,6 @@ const HolyLoader = ({
holyProgress = new HolyProgress({
color,
height,
trickleSpeed,
trickle,
initialPosition,
easing,
speed,
Expand Down

0 comments on commit 04d85b3

Please sign in to comment.