next.js icon indicating copy to clipboard operation
next.js copied to clipboard

UI to show that code is compiling in the browser window

Open rauchg opened this issue 8 years ago • 35 comments

Currently, the only way to know that hot code replacement is going to happen (and that the Next.js compiler toolchain is doing work) is to look at the developer console.

Many times, one is looking at the resulting rendering instead, but it's hard to get an idea of progress.

I'd like to make this an umbrella thread for gathering ideas and feedback on how to best signal to the developer that work is happening.

Some requirements:

  • The top priority is that it must be non-invasive. Some ideas along these lines
    • Favicon animation
      • The demo works great in Chrome, but not Firefox. I wonder if we can make it work?
    • window.title changes
    • onscreen animation with a shadow root / careful style isolation
  • It must be unique and identifiable
  • It must be very lightweight, even though it will be enabled only during development

Bonus points:

  • Like jest, we can keep data around about how long each unique path takes to compile, to provide statistically accurate estimates when animating of how long the process is going to take

rauchg avatar Jun 17 '18 18:06 rauchg

How about something along the lines of a filling triangle ? That way we can keep that brand identity and apply some fun to it.

https://dribbble.com/shots/1894246-Triangle-animation-GIF We could just use a black color fill.

I am sure @evilrabbit could patch something up. :D

stefanivic avatar Jun 17 '18 19:06 stefanivic

@shahzeb1 as I mentioned in the "bonus" portion, we'd have two forms:

  • One based in a fixed estimate (let's say 500ms), that slows down at the end if the deadline is not met. This similar to how nprogress works.
  • We can also collect data for better estimates

rauchg avatar Jun 17 '18 19:06 rauchg

@stefanivic that sounds nice but I also think having something unique to Next.js could be nice :)

rauchg avatar Jun 17 '18 19:06 rauchg

  1. I think that loading percentage in title is not bad, something like [10%] title.
  2. Probably it can be loading indicator in top of page.
  3. Also I was thinking about rotating X (make it like hourglass) in Next.js logo :)
images

loading done

teleginzhenya avatar Jun 17 '18 19:06 teleginzhenya

@rauchg Well another thing that comes to mind is the letter N in Next.js

https://i.imgur.com/o567qtv.png As you can see, the N sort of resembles the half of the triangle.

We can maybe create a transition from Zeit logo to N with some simplified animation of this: https://img-9gag-fun.9cache.com/photo/aWZRW82_460sv.mp4

Or just the letter N from scratch.

stefanivic avatar Jun 17 '18 19:06 stefanivic

Is this going to be only for development?

morajabi avatar Jun 18 '18 09:06 morajabi

@morajabi yep, as this is only to show webpack compilations going on.

timneutkens avatar Jun 18 '18 12:06 timneutkens

I did animation with zeit logo :)

2018-06-19 00 05 18 1

https://codepen.io/teleginzhenya/pen/PaEzPg

teleginzhenya avatar Jun 18 '18 18:06 teleginzhenya

How about using something like triangle from cli-spinners for the title?

bennygenel avatar Jun 18 '18 18:06 bennygenel

I like the way Github does it when you are on a PR site, waiting for the CI to finish (after adding a commit)... just three states: yellow dot for building, green checkmark for done, red x for failed. It's a very subtle design but helpful enough (however it doesn't update sometimes when the tab is inactive in Chrome). Ionic does something similar by changing the color of the favicon from blue (idle) to yellow (building) or red (failed).

image image

Another useful info might be a timestamp of the last successful build (or time since) in the title. But sometimes I pin the tab and only get to see the favicon. On my Macbook (no additional screens) I usually swipe from one desktop (editor) to the next (browser) while waiting for the build.

simonhaenisch avatar Jun 19 '18 01:06 simonhaenisch

@simonhaenisch 👍 Although, it's worth mentioning that we still need to show the user favicon after the compilation was done. Am I right?

morajabi avatar Jun 19 '18 09:06 morajabi

@morajabi I wouldn’t mind having a next-specific favicon during development, to know that i’m in dev mode on localhost and not in production on my live website. Or one could patch up the user’s favicon with the overlayed icons, but that’s not simple anymore.

Edit: Just saw this tweet by Wes Bos about using canvas to base64 to favicon (as data url). That would make it easy to patch an existing favicon (load it into the canvas, add the overlay icons). Same idea as the mentioned favicon loader.

simonhaenisch avatar Jun 19 '18 10:06 simonhaenisch

@simonhaenisch The overlying thing would be really cool 👍 ~if we can make it work at a reasonable cost.~ We can!

I wouldn’t mind having a next-specific favicon during development

Yeah, but I imagine myself wanting to test my own favicon before deploying.

My opinion would be to not completely override the user favicon. If we're going to change, we can change it only while it's compiling. That's easier to do that changing user icon (adding overlay) and it has a decent user experience.

@bennygenel's suggestion re: using ◢ ◣ ◤ ◥ animation before the page title is an option too!

Since we don't have a real estimate of % remaining to complete the build, prepending [24%] to the title doesn't feel right in my opinion (unless we can estimate just close)

morajabi avatar Jun 19 '18 11:06 morajabi

I just made a demo of patching an existing favicon: https://patch-favicon-vcxikxushz.now.sh. Works in Chrome and Firefox (Developer Edition) for me (macOS). The icons are not perfectly aligned (it's just some unicode characters rendered as text), but it's a proof that it's possible.

Edit: will try with octicons later (check, dot and x), and might just make it a package. Also found anybar-webpack and webpack-anybar, that's another nice way of doing it.

simonhaenisch avatar Jun 19 '18 13:06 simonhaenisch

@simonhaenisch Looks perfect 😍

morajabi avatar Jun 19 '18 17:06 morajabi

https://patch-favicon-pxazgxlqkl.now.sh? Should it just go back to normal like 5-10 seconds after a successful build?

simonhaenisch avatar Jun 21 '18 02:06 simonhaenisch

Favicon is not shown in Safari unless the address bar is focused which it never is

rdev avatar Jun 22 '18 09:06 rdev

Is doing a progress line on top like this a bad idea? It's not really intrusive, but the issue is that people might have the same progress bar in their actual app

rdev avatar Jun 22 '18 09:06 rdev

@rdev

Favicon is not shown in Safari unless the address bar is focused which it never is

Yeah, that's true, for now. Since the Safari coming with Mojave before the fall will show favicons. Also, not showing this loading on Safari, wouldn't break the experience of Next IMO, since we show the status in the CLI currently too.

Is doing a progress line on top like this a bad idea? It's not really intrusive, but the issue is that people might have the same progress bar in their actual app

React Native uses something like this to show the build is running too, so thanks for mentioning it. It might be a bit confusing as It's not uncommon to use NProgress (a top progress bar similar to this one) just how zeit.co is using it now in their app.

morajabi avatar Jun 22 '18 09:06 morajabi

@morajabi

Safari coming with Mojave before the fall will show favicons

Are you sure? Cause I'm running Mojave beta and there's no favicon screen shot 2018-06-22 at 17 48 59

rdev avatar Jun 22 '18 09:06 rdev