Skip to content

Commit c26ef05

Browse files
committed
fix: hydration issue + added scale-in animation
1 parent d2f2a2f commit c26ef05

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

app/pages/index.vue

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,27 @@ defineOgImageComponent('Default', {
2525
description: 'a fast, modern browser for the **npm registry**',
2626
})
2727
28-
const route = useRoute()
29-
const isKawaii = computed(() => route.query.kawaii === 'true')
28+
// const route = useRoute()
29+
// const isKawaii = computed(() => route.query.kawaii === 'true')
30+
onPrehydrate(el => {
31+
const isKawaii = window.location.search.includes('kawaii=true')
32+
const normal = el.querySelector('#npmx-index-h1-logo-normal') as HTMLElement
33+
const kawaii = el.querySelector('#npmx-index-h1-logo-kawaii') as HTMLElement
34+
const env = el.querySelector('#npmx-index-h1-logo-env') as HTMLElement
35+
const tagline = el.querySelector('#npmx-index-tagline') as HTMLElement
36+
if (!normal || !kawaii || !env || !tagline) return
37+
if (isKawaii) {
38+
normal.style.display = 'none'
39+
kawaii.style.display = 'block'
40+
env.style.display = 'none'
41+
tagline.style.display = 'none'
42+
} else {
43+
normal.style.display = 'block'
44+
kawaii.style.display = 'none'
45+
env.style.display = 'block'
46+
tagline.style.display = 'block'
47+
}
48+
})
3049
</script>
3150

3251
<template>
@@ -40,15 +59,18 @@ const isKawaii = computed(() => route.query.kawaii === 'true')
4059
class="relative flex items-center justify-center gap-2 header-logo font-mono text-5xl sm:text-7xl md:text-8xl font-medium tracking-tight mb-6 motion-safe:animate-fade-in motion-safe:animate-fill-both"
4160
>
4261
<img
43-
v-if="isKawaii === true"
62+
id="npmx-index-h1-logo-kawaii"
4463
width="400"
45-
class="pb-8 motion-safe:animate-fade-in motion-safe:hover:scale-105 motion-safe:transition"
64+
class="hidden pb-8 motion-safe:animate-fade-in motion-safe:animate-scale-in motion-safe:hover:scale-105 motion-safe:transition w-80 sm:w-100"
4665
src="/extra/npmx-cute.svg"
4766
alt="npmx kawaii logo"
4867
/>
49-
<AppLogo v-if="isKawaii !== true" class="w-42 h-auto sm:w-58 md:w-70" />
68+
<AppLogo
69+
id="npmx-index-h1-logo-normal"
70+
class="w-42 h-auto sm:w-58 md:w-70"
71+
/>
5072
<span
51-
v-if="isKawaii !== true"
73+
id="npmx-index-h1-logo-env"
5274
aria-hidden="true"
5375
class="text-sm sm:text-base md:text-lg transform-origin-br font-mono tracking-widest text-accent absolute -bottom-4 -inset-ie-1.5"
5476
>
@@ -57,7 +79,7 @@ const isKawaii = computed(() => route.query.kawaii === 'true')
5779
</h1>
5880

5981
<p
60-
v-if="isKawaii !== true"
82+
id="npmx-index-tagline"
6183
class="text-fg-muted text-lg sm:text-xl max-w-xl mb-12 lg:mb-14 motion-safe:animate-slide-up motion-safe:animate-fill-both"
6284
style="animation-delay: 0.1s"
6385
>

0 commit comments

Comments
 (0)