Coder Social home page Coder Social logo

lorikku / holy-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tomcru/holy-loader

0.0 0.0 0.0 606 KB

Holy Loader is a lightweight, customizable top-loader / top loading progress bar component for React / Next.js 13 & Next.js 14

Home Page: https://www.npmjs.com/package/holy-loader

License: MIT License

JavaScript 1.92% TypeScript 98.08%

holy-loader's Introduction

Holy Loader

Holy Loader



Holy Loader is a lightweight and customizable top-loading progress bar component, specifically designed for React applications and optimized for Next.js with app router.

Want to see it in use? Visit: GameGator.

Also check out Holy Time, yet another (type-safe) date time library.

Features

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

Installation

To install Holy Loader, run the following command in your project directory:

npm install holy-loader

OR

yarn add holy-loader

Usage

To use Holy Loader in your Next.js application using the app router:

import HolyLoader from "holy-loader";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <HolyLoader />
      {children}
    </html>
  );
}

To use Holy Loader in your Next.js application using the pages router:

import HolyLoader from "holy-loader";

export default function App({ Component, pageProps }) {
  return (
    <>
      <HolyLoader />
      <Component {...pageProps} />;
    </>
  );
}

Custom Configuration

import HolyLoader from "holy-loader";

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <HolyLoader
        color="#ff4500"
        height="1rem"
        speed={250}
        easing="linear"
        showSpinner
      />
      {children}
    </html>
  );
}

Common issues

Prevent triggering the loader when clicking a Button within a Next link:

onClick={(e) => {
  e.preventDefault();
  e.nativeEvent.stopImmediatePropagation();
}}

API

<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).
  • height (number | string): Defines the height of the top-loading bar in pixels or css unit. Default: 4 pixels.
  • 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.
  • boxShadow (string): Sets the box-shadow property of the top-loading bar. Turned off by default.
  • showSpinner (boolean): Determines whether to accompany the loading bar with a spinner. Turned off by default.

Project inspired by nextjs-toploader & nprogress

holy-loader's People

Contributors

tomcru avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.