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
Conversation
feat: split nuxt-loading.vie in js/css files feat: add css classes instead of style props feat: add loader.css property
There was a problem hiding this 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
@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 ;) |
@pimlie Can you also add a test that determines it's not being included when not used? |
Do you mean the div or the css? Or both ;) |
I 'fixed' the tests on circleci by adding a Let me know if anyone has a better solution, maybe otherwise just put this test in a separate test file? |
lib/app/components/nuxt-loading.js
Outdated
|
||
<script> | ||
import Vue from 'vue' | ||
<% if (loading && loading.css) { %>import "./nuxt-loading.css"<% } %> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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") %>'<% } %> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
.
lib/app/components/nuxt-loading.js
Outdated
|
||
export default { | ||
name: 'nuxt-loading', | ||
render(h) { |
There was a problem hiding this comment.
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 👍
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
This PR is ready for review again. These last changes introduce one breaking change: before if you paused loading with 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
|
add pause/resume test
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
test/e2e/basic.browser.test.js
Outdated
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) |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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?
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
Please see the message of commit e7bddc9 for all the details. |
i just like to do things more difficult :s
fix: add yarn.lock after vue-jest install
packages/common/src/nuxt.config.js
Outdated
@@ -194,7 +194,9 @@ export default { | |||
height: '2px', | |||
throttle: 200, | |||
duration: 5000, | |||
rtl: false | |||
continuous: false, |
There was a problem hiding this comment.
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
I have added a PR for the missing docs (you can also check that PR for a gif of the continuous loading) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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. |
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
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:
Will add a docs PR if this gets approved.