Hey all!
This week I started working on the final session for Advanced Frontend Testing in Vue.
These exercises are focused on e2e testing and best practices, and are the last pieces of material for the course.
After that, I'm working on getting all of this testing material ready and polished so I can get it out to you!
I've also got two conferences in November — Nuxt Nation and VueConf Toronto — and I'm looking forward to both!
I'm also in the early processes of figuring out the update for Mastering Nuxt. But since Nuxt 4 isn't even out yet, I'm not sure what the timeline will be on that.
Anyone who has bought Mastering Nuxt 3 will get it as a free update, so you can scoop it up on a good Black Friday sale and still get the new stuff!
As always, I've got some tips and articles for you.
I've also got a great podcast episode with my friend Eduardo San Martin Morote (author of Vue Router and Pinia).
Have a great October!
— Michael
Scoped CSS is fantastic for keeping things tidy and not accidentally bleeding styles into other parts of your app.
But sometimes, you need to override the styles of a child component and break out of that scope.
Vue has a :deep
selector just for this:
<style scoped>/* Override CSS of a child componentwhile keeping styles scoped */.my-component :deep(.child-component) {font-size: 24px;}</style>
In Vue 2 this has a slightly different syntax depending on which CSS pre-processor you're using:
<style scoped>/* When using SASS */.my-component ::v-deep .child-component {font-size: 24px;}/* Everything else */.my-component >>> .child-component {font-size: 24px;}</style>
Yes, I have previously covered why you shouldn't do this, but overriding styles can be the best solution (we don't believe in "best practices" here).
When building a UI, there are many different states that you need to consider:
200ms
before showing a spinner. If the data loads before that, it feels faster than if you quickly flash the loading spinner on and then off again.You can detect a mouse hover in Vue just by listening to the right events:
<template><div@mouseover="hover = true"@mouseleave="hover = false"/></template>
Then you can use this state to change how the background is rendered, update computed props, or anything else you want.
Depending on your use case, you may want to check out the mouseout and mouseenter events as well. There are some subtleties with how they bubble and interact with child elements.
Michael is joined by VueRouter and Pinia author Eduardo San Martin Morote aka posva.
Together, they go deep into questions around the de-facto standard state management tool and why people should use Pinia, but also discuss what Data Loaders and Pinia Colada are (not the drink friends!).
Further, the two content creators discuss how Mastering Pinia came together and what challenges are to expect when going from a "live workshop" to recorded videos.
And of course, we can't forget upcoming conferences and meetups - with a sneak peek of what Eduardo might present đź‘€
Watch on YouTube or listen on your favorite podcast platform.
Chapters:
In case you missed them:
I wasted thousands of dollars hiring someone to format and layout a previous book, but it was a painful process.
Then I built an easy-to-use tool that lets me use just HTML, CSS, and Markdown to create beautiful ebooks and PDFs.
In this article, I share exactly how I do it.
Check it out here: Create Beautiful PDFs with HTML, CSS, and Markdown
You may have heard about server components, but there are some really interesting things you can do with them.
In this article I explore a few really cool things we can do with server components.
Check it out here: Exploring Server Components in Nuxt
Here are some upcoming events you might be interested in. Let me know if I've missed any!
The biggest Nuxt conference in the world! A free two-day event online. I will speaking on Nuxt Server Components!
My favourite Vue conference, in my own backyard! A three-day event with workshops, speakers from around the world, and socializing. I will be speaking on Nuxt Layers!
The biggest Vue conference in the world! A two-day event with workshops, speakers from around the world, and socializing.
"Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday’s code." — Christopher Thompson or Dan Salomon
The best way to commit something to long-term memory is to periodically review it, gradually increasing the time between reviews 👨‍🔬
Actually remembering these tips is much more useful than just a quick distraction, so here's a tip from a couple weeks ago to jog your memory.
When you register a component globally, you can use it in any template without importing it a second time:
// Vue 3import { createApp } from 'vue';import GlobalComponent from './GlobalComponent.vue';const app = createApp({})app.component('GlobalComponent', GlobalComponent);
In Vue 2 you can register global components like this:
// Vue 2import Vue from 'vue';import GlobalComponent from './GlobalComponent.vue';Vue.component('GlobalComponent', GlobalComponent);
Now you can use GlobalComponent
in your templates without any extra work!
Of course, globally registered components have the same pros and cons as global variables. So use this sparingly.
Michael Hoffman curates a fantastic weekly newsletter with the best Vue and Nuxt links.
p.s. I also have four products/courses: Clean Components Toolkit, Vue Tips Collection 2, Mastering Nuxt 3, and Reusable Components