deetstrab
deetstrab
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
npx nuxi upgrade -f
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
you can do a nuxi upgrade with the force param to HARD UPGRADE 🙂 - give that a shot
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
I really appreciate your help and conversation 🙂 thank you, my friend
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
no, I was (formerly) just using a ternary eval
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
I need to get a better understanding of why this only works within an anonymous function
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
well of course and I see it as that simple too, fwiw - I've just been taught that it's an antipattern. I didn't consider it for that reason, but you're absolutely right - it's a simple solution that works perfectly!
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
I just wanted to force myself to do it the Vue/Nuxt way
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
That's exactly how I do it in vanilla/es
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
Yes but isn't targeting the DOM nodes like this an anti-pattern in Vue/Nuxt?
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
It's possible a wrapper div would have worked too - this is a pattern I've used in many mobile navs that I've built over the years, though.
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
As I see it, yes. I needed to disable scrolling of the website while my mobile nav is open.
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
Thank you all for your helpfulness and thoughtful replies
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
I need to understand why this needs to be a function to work? What would be a good resource to read to better grasp this concept? Thanks in advance! 🙂
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
useHead({
bodyAttrs: {
// class: displayMobileNav.value ? 'navOpen' : '' // Didn't work
class: () => displayMobileNav.value ? 'navOpen' : '' // Works like a charm inside the anonymous function
}
})
useHead({
bodyAttrs: {
// class: displayMobileNav.value ? 'navOpen' : '' // Didn't work
class: () => displayMobileNav.value ? 'navOpen' : '' // Works like a charm inside the anonymous function
}
})
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
This is exactly what I'm doing and have tried all variants of this that I know to.
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
No description
45 replies
NNuxt
Created by deetstrab on 6/30/2024 in #❓・help
Reactively add/remove a class name to <body>, from within a component...
useHead works to set the initial value of title, bodyAttrs.class, etc -- but none of these properties appear to be reactive.
45 replies