Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove nuxt-loading div from DOM when not used #3891

Merged
merged 26 commits into from Oct 29, 2018

Conversation

pimlie
Copy link

@pimlie pimlie commented Sep 15, 2018

feat: split nuxt-loading.vue in js/css files
feat: use css classes instead of style props
feat: add loading.css property to fully ignore the default css

Types of changes

  • New feature (non-breaking change which adds functionality)

Description

Remove the nuxt-loading div from the DOM when its not used and fully use css-classes instead of style properties. Also add a loading.css boolean property so you can fully ignore the default nuxt css.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: feat: continuous loading description docs#924)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests passed.

Will add a docs PR if this gets approved.

feat: split nuxt-loading.vie in js/css files

feat: add css classes instead of style props

feat: add loader.css property
Copy link

@galvez galvez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pimlie take a look at the failing test -- LGTM otherwise

@pimlie
Copy link
Author

pimlie commented Sep 15, 2018

@galvez Yeah sorry, I wasnt sure whether I caused that issue and I didnt want to touch things I did not specifically change. But looking at it now I understand why ;)

@galvez
Copy link

galvez commented Sep 15, 2018

@pimlie Can you also add a test that determines it's not being included when not used?

@pimlie
Copy link
Author

pimlie commented Sep 15, 2018

Do you mean the div or the css? Or both ;)

@pimlie
Copy link
Author

pimlie commented Sep 15, 2018

I 'fixed' the tests on circleci by adding a Utils.waitFor(100) at the start of the new test. It works now, but this could possibly trigger intermittent errors when the circleci servers are busy. Its not a perfect solution but I guess the tests are quicker triggered then puppeteer / chrome can handle all DOM events and I cant think of another solution atm to wait for the DOM events to finish.

Let me know if anyone has a better solution, maybe otherwise just put this test in a separate test file?

pi0
pi0 previously requested changes Sep 15, 2018

<script>
import Vue from 'vue'
<% if (loading && loading.css) { %>import "./nuxt-loading.css"<% } %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this file to be SFC. We can still conditionally do the same for the <style>...</style> part. Splitting just makes maintenance harder.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revert this back :)

lib/app/App.js Outdated
@@ -1,5 +1,5 @@
import Vue from 'vue'
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.vue") %>'<% } %>
<% if (loading) { %>import NuxtLoading from '<%= (typeof loading === "string" ? loading : "./components/nuxt-loading.js") %>'<% } %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we hardcode .js here, the user can't override nuxt-loading component. Currently, he/she can do this by creating app/components/nuxt-loading component or use a module to change it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be ok with omitting the file extension in that case? I am not fully sure if that will always work, but in my experience omitting the file extensions resolves in either .vue or .js.


export default {
name: 'nuxt-loading',
render(h) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Render function instead of<template> seems a good idea for this 👍

@Atinux
Copy link
Member

Atinux commented Sep 18, 2018

I agree with @pi0 requested changes, looking forward to this PR :)

add nuxt-loading component tests with vue-server-renderer

revert flaky e2e progressbar test

add nuxt.options.loading.throttle option with defualt value 200
@pimlie
Copy link
Author

pimlie commented Sep 18, 2018

This PR is ready for review again. These last changes introduce one breaking change: before if you paused loading with $loading.pause() you could / needed to restart loading again by calling $loading.start(). This has now changed to $loading.resume(). If you call start() the loading will always start from 0 again. Hope you agree with me thats better as otherwise you also have the throttle timeout after resuming every pause :)

If you wish I can work on this tomorrow, but the e2e tests are probably not as they should be. E.g. the basic browser /noloading test actually errors out to a nuxt-error page which is not detected at all. We should add a listener for errors to fully make sure there are none.
Btw, the /noloading page errors out because this.$nuxt.$loading is not yet available when mounted() is called. It is only available after a nextTick(). Also think the start/finish calls are reversed. @galvez could you maybe confirm / have a look at this?

Not sure why the circleci:audit test failed, looks like a temporary CI issue? Yes it was, guess it was good this time I noticed a bug in one of the tests

add pause/resume test
@codecov-io
Copy link

Codecov Report

Merging #3891 into dev will decrease coverage by 0.08%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #3891      +/-   ##
==========================================
- Coverage   97.64%   97.56%   -0.09%     
==========================================
  Files          18       18              
  Lines        1231     1231              
  Branches      335      335              
==========================================
- Hits         1202     1201       -1     
- Misses         28       29       +1     
  Partials        1        1
Impacted Files Coverage Δ
lib/common/nuxt.config.js 100% <ø> (ø) ⬆️
lib/core/nuxt.js 94.16% <0%> (-0.84%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65432e6...0dd374b. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Sep 18, 2018

Codecov Report

Merging #3891 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #3891   +/-   ##
=======================================
  Coverage   87.83%   87.83%           
=======================================
  Files          43       43           
  Lines        1701     1701           
  Branches      435      435           
=======================================
  Hits         1494     1494           
  Misses        180      180           
  Partials       27       27
Impacted Files Coverage Δ
packages/config/src/config/index.js 0% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e49764c...1c9f0ff. Read the comment docs.

const { hook } = await page.nuxt.navigate('/noloading')
const loading = await page.nuxt.loadingData()
const { hook } = await page.nuxt.navigate('/noloading', false)
await Utils.waitFor(nuxt.options.loading.throttle + 100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maybe move this right into page.nuxt.navigate @pimlie ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or we could add a call to page.waitForFunction instead. But as mentioned I actually think the e2e tests need some more refactoring anyway as there doesnt seem to be enough protection against unexpected exceptions at the moment. Maybe we can change this with that refactoring?

galvez
galvez previously approved these changes Sep 20, 2018
feat: new config option 'continuous'
If true the progress bar keeps changing also after duration time has
passed. It switches from ltr growing to rtl shrinking, then ltr growing
again with ltr: false

fix: remove Math.random() for percent increase, it caused choppy
behaviour and more importantly when loading took exactly duration time
there was a 100% chance the progress bar was not yet at 100%

fix: add safeguards so percent can never be <0 or >100

fix: calculate _cut correctly for duration < 1000

fix: remove automatically finishing when >95% is reached. This behaviour was
counter-intuitive, when duration time had almost passed duration the
progress bar always finished, regardless whether it was truly finished or
not. Now the progress bar stays at 100% until loading really finishes
(with continuous = false)

feat: add nuxt-progess-notransition class to disable transitions when we
are switching from grow to shrink
@pimlie
Copy link
Author

pimlie commented Sep 24, 2018

Please see the message of commit e7bddc9 for all the details.

pi0
pi0 previously approved these changes Oct 27, 2018
@@ -194,7 +194,9 @@ export default {
height: '2px',
throttle: 200,
duration: 5000,
rtl: false
continuous: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs should be updated to add continuous too

@pimlie
Copy link
Author

pimlie commented Oct 28, 2018

I have added a PR for the missing docs (you can also check that PR for a gif of the continuous loading)

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pi0 pi0 merged commit 72961ac into nuxt:dev Oct 29, 2018
@pimlie pimlie deleted the feat-render-loading branch October 29, 2018 17:10
@lock
Copy link

lock bot commented Nov 28, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 28, 2018
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants