-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
props breaking when <ClientOnly> and fallback in nuxt production. #155
Comments
Hi, @sandros94 I tried Anu demo repo in production and it's working as expected. Can you please share your repo? |
Just woke up, but in the demo repo I can see that none of the icons comes from CDN. I'll update my test repo in a bit. |
Ok I've prepared a reproduction in my test repo under Anu branch. Pull it, then The key factor is that I'm pulling the icons from a cdn instead of installing them as packages: |
Hey @sandros94 Can you please add lock file to your test repo? I'm getting errors due to missing lock file. Awaiting your response. |
Moreover, if possible can you please check if you are facing the same with unocss only (without anu)? |
Once I get back home I'll push that specific lockfile.
I didn't test unoccs only in that repo, but two notes about it:
|
Lock file pushed |
While fixing a small error (the clock icon was white on white for the light theme), it made me discover a thing. To solve #135 I decided to implement this: <template>
<ClientOnly>
<template #fallback>
<ASwitch v-model="off" off-icon="i-svg-spinners:clock"/>
</template>
<ASwitch v-model="switchTheme" off-icon="i-ph:sun" on-icon="i-ph:moon"/>
</ClientOnly>
</template>
<script setup>
const colorMode = useColorMode();
const off = ref(false)
const switchTheme = computed({
get: () => colorMode.value === 'dark',
set: (value) => {
if (colorMode.preference === 'system') {
// Set the opposite of the current system value
colorMode.preference = value ? 'dark' : 'light';
} else {
// Set the preference back to 'system'
colorMode.preference = 'system';
}
}
});
</script> and as described in the closing comment of that issue I had to use the built-in Here is my discoveryon <template>
<ASwitch v-model="off" off-icon="i-svg-spinners:clock"/>
</template> but once it gets loaded in a browser (and thus get the information of the current theme), it should become: <template>
<ASwitch v-model="switchTheme" off-icon="i-ph:sun" on-icon="i-ph:moon"/>
</template> <template>
<ASwitch v-model="switchTheme" off-icon="i-svg-spinners:clock"/>
</template> Basically when it switches from the Current considerationsLater I'll update the test page in demo-branch with all three switch combination and create a new reply in this issue, to better describe what they are and potentially close this issue (or at least update the title). Because now I have come to the conclusion that yes, Anu is indeed using the unocss-icons from CDN, but it gets broken along the way once you use them in the built-in |
Due to some issues, action wasn't able to make a edge release to test the latest release I said about. I will let you know once edge release will continue to work. |
I started a discussion in the Nuxt repo. |
Hey @sandros94 What's the status of this issue? Did you manage to resolve the issue? |
Unfortunately I haven't, and by the looks of it it seems that the nuxtlab team is busy with other developments. One thing I wanted to try was to add a |
EDIT:
Original title
Why it has been updated
Following the discoveries in the comments below (in particular this one and this one), Anu correctly fetches the the icons from the CDN configured inside
unocss.config.ts
, but more of a problem like:When using Anu components like ASwitch inside the nuxt's built-in component
<ClientOnly>
with a#fallback
template, some props likeoff-icon
andon-icon
don't get correctly updated when the component is fully loaded by the browser (look at the screenshots and descriptions of this event in the comments linked earlier).Original description
I was testing stuff for #154 (I'm using that stackblitz reproduction) and I've noticed that when I use unocss icons from CDNs they don't get applied to Anu's components while in production.
dev (
npm run dev
):production (
npm run build && npm run preview
):TBH I've still never tried Anu in production, so Idk if this was existing before v0.13.0
The text was updated successfully, but these errors were encountered: