GithubHelp home page GithubHelp logo

thesgj / nextjs-toploader Goto Github PK

View Code? Open in Web Editor NEW
487.0 487.0 38.0 1.32 MB

A Next.js Top Loading Bar component made using nprogress, works with Next.js 14 , Next.js 13 and React.

Home Page: https://www.npmjs.com/package/nextjs-toploader

License: MIT License

TypeScript 100.00%
next next13 next14 nextjs nextjs13 nextjs14 progressbar react toploader

nextjs-toploader's Introduction

  • Hi, Iโ€™m @TheSGJ
  • ๐Ÿ‘€ Iโ€™m interested in coding back-end code by using python and nodejs
  • ๐ŸŒฑ Iโ€™m currently learning Rust
  • ๐Ÿ“ซ You can reach me out on my Insta on @sgj.ig & or on my twitter on TheSGJyt

Profile View Counter


My GitHub Stats:

TheSGJ's github stats TheSGJ's top languages TheSGJ's github streak TheSGJ's github trophy

Sponsor me on GitHub

"Buy Me A Coffee"

UPI ID: thesgj@airtel

nextjs-toploader's People

Contributors

ahmedbaset avatar amandeeptherockstar avatar anamiikajha avatar davevanhoorn avatar dependabot[bot] avatar diiiazote avatar gbarnev avatar gwendall avatar harsh253 avatar hyoretsu avatar jlalmes avatar lferronato avatar lorikku avatar melanieseltzer avatar prochalu avatar snyk-bot avatar thesgj avatar vandat1995 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nextjs-toploader's Issues

Hydration error (app directory)

Adding the component into the root layout gives a hydration error.

app/layout.js:

import NextTopLoader from 'nextjs-toploader';

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

image

Putting <NextTopLoader /> into a client component and using that in the root layout gives the same error.

Don't trigger start animation when clicking on an button within anchor

Considering this case

<a href="/username">
    <button 
        onClick={(e) => {
            e.stopPropagation();
            follow();
        }}>
        Follow
    </button>
</a>

Issue: When the button is clicked, the progress bar triggered
Expected: When the button is clicked, the progress bar should not do anything. There should be a way to prevent the progress bar to not being triggered

Prop to disable loader for anchors scroll

Hi,

A prop for disabling the loader when we click an a link to scrolls to an anchor on the same would be nice.
Right now the loader starts and gets stuck after a little bit. You have to click the link a second time in order for it to disappear.

Thanks

Configuration not working for showSpinner

i set showSpinner to false and its not change anything, i mean the spinner still showing
i import this toploader in root layout.tsx, i use latest version of nextjs for now the version is "13.4.2"

here is my configuration
<NextTopLoader color="#F43F5E" showSpinner={false} />

Maybe more clarification in the documentation for prop color

At first I thought color only works with hex string,
then I figured out something like this also works.

const primaryRef = useRef('var(--primary)')

  return (
    <NextTopLoader
      color={`hsl(${primaryRef.current})`}
      showSpinner={showSpinner}
    />
  )

Please add a small video demonstration

It's hard to visualize how your package will look and investing time in adding it first to see how it looks is a huge barrier for entry for most people who hear about this project for the first time.

newUrl is undefined in some cases

Hey,
I was playing around again with this after the issue with the anchor.
This allowed me to find another issue.

After you configure NProgress inside your navLink.addEventListener('click', ....

let currentUrl = window.location.href;
let newUrl = event.target.href;

If you refresh the page, and click on a link, the newUrl comes back as undefined. I have no idea why is that though.

Add console.log(currentUrl, newUrl) after you assign them to see it.

I was able to find this because the new function I added for anchors does new URL(newUrl) which fails because newUrl is undefined

Allow passing arbitrary props to `NextTopLoader` component

First of all, thank you for your amazing work on this library.

I have a suggestion that I believe would enhance the functionality of the NextTopLoader component. Currently, it provides several props for customization, which is great. However, I would like to propose adding a new feature that allows users to pass arbitrary props to the NextTopLoader component.

The inspiration for this feature comes from the template option in the nprogress package. With the ability to pass custom props, users like myself, for example, could add attributes such as data-test-id, which can significantly help in testing scenarios. Having the ability to set a data-test-id would allow us to easily check if the component has completed its loading process during testing.

I believe this addition would make the NextTopLoader even more versatile and further improve its usability. I hope this suggestion resonates with you.

Thank you once again for your hard work and consideration of this proposal.

NextTopLoader stopped working on Nextjs 14.0.3

Hello, just to report that on a project with the last Nextjs 14.0.3, the toploader keeps loading and never finish or completes.

But there aren't errors on console server/client.

As a workaround to get it working install 14.0.2

No Progress on Server Actions

Thank you for this awesome library. I started using nextjs server actions.
Currently, the toploader does not appear when a server action is in progress. It would be awesome if that would work too.

Server.Actions.Loading.Indicator.1.mp4

How to apply zIndex for progress bar and circular progress

Hello, I need help to apply zIndex for underlying nprogress css properties.
I am using material UI(MUI), so I am applying the css using theme and inside CssBaseline component with #nprogress as selector.
Do you know working example for applying styling?

Prop to show TopLoader at bottom

It would be very cool to see TopLoader at the bottom. Could be done like passing a boolean whether to show it at bottom or not.

Hide side spinner

I want to hide the small semi-circle rotating in top-right corner. How can I do that ?
The reason to hide that is that it is not in best position and it just looks ugly

Animation continues indefinitely when replacing the current route

Nextjs - 13.4.6
nextjs-toploader - 1.6.4

Current behaviour -
When using with nextjs' Link component , it works fine in a regular navigation but when I provide "replace" prop to Link component to replace the current route with a new route, the progress bar animation continues indefinitely even after the route has been replaced and the page is completely rendered.

Expected behaviour -
The progress bar should complete the animation on successful navigation and stop the animation

Special URL schemes make the progress stuck

The following URL schemes make the progress bar stuck, even after successfully 'opening the link'

  • Telephone numbers with tel: URLs
  • Email addresses with mailto: URLs
  • SMS text messages with sms: URLs

href="#" also makes it stuck, but your website shouldn't have an anchor with just # anyway so this does not need fixing.

Otherwise an amazing library, good job!

Unexpected symbol "?" on Safari 12.1

It throws an error on Safari 12.1, in both development and production. I also have a React lib that when transpiled used the ||= operator, which turns out was only supported in Safari 14.

It's probably the nullish coalescing you're using that isn't being polyfilled by tsup, since it's only supported by Safari 13.4 onwards.

So how is this supposed to work?

A Next.js Top Loading Bar component made using nprogress, works with Next.js 14.

The readme describes what this (a loading bar), what's it build on top of (nprogress), and that it also works with Nextjs. It also explains various config options, although some of them would imho need some more details (e.g. crawlSpeed?)

Yet is doesn't explain how it is supposed to work. When does loading start? When should it stop?

My experience is that I installed this in my project, I see the progress bar starting when I click to navigate to a new page yet the page loads but the progress bar is still only halfway done. I also checked the network tab, no requests are happening in the background, yet the loading bar is still there -> this is weird.

So then I can't help but think: is this indented? is it not? do I need to change some setting? I don't know, the readme doesn't get into these details.

If I knew this info, I wouldn't mind making a PR where this kind of info is mentioned. Sadly I don't.

TopLoader stopped showing after upgrade to Next v14.

I have updated my proejct ot Next 14 and I can not able to see toploader.

In app/layout.tsx

import { Toaster } from "@/components/ui/toaster";
import "@/styles/globals.css";
import type { Metadata } from "next";
import NextTopLoader from "nextjs-toploader";



export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en" suppressHydrationWarning>
      <NextTopLoader height={500} zIndex={9999} color="black" />
      <body>
        {children}
        <Toaster />
      </body>
    </html>
  );
}

I have tried to make layout.tsx to a client component, it still not working.

e.preventDefault() does not prevent animation

Hi,

In a nested button inside a Link, if you call preventDefault, it does not prevent the animation.

<Link href={"/somewhere"}>
    <button onClick={(e) => e.preventDefault()}>Hey</button>
</Link>

Regards

Progress Stuck if I Click Link with the same route

The progress works well, but there is problem:

The progress bar will get stuck if I click link with the same route, for example:

If I'm in /contact , and I click again the Link with href="/contact", the progress bar showing again but get stuck

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.