Skip to content

Commit a37df2c

Browse files
committed
fix(docs): preload hero tabs, hide scrollbar on animation
1 parent 5dc7329 commit a37df2c

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

docs/app/components/content/landing/LandingHero.vue

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { useElementSize } from '@vueuse/core'
3-
import { AnimatePresence, motion, MotionConfig } from 'motion-v'
3+
import { motion, MotionConfig } from 'motion-v'
44
// @ts-expect-error yaml is not typed
55
import hero from './hero.yml'
66
@@ -10,8 +10,7 @@ const { height } = useElementSize(contentRef)
1010
1111
const tabs = hero.tabs as { name: string, code: string }[]
1212
13-
const currentCode = computed(() => tabs[currentTab.value]?.code.trim() ?? '')
14-
const lineCount = computed(() => currentCode.value.split('\n').length)
13+
const lineCounts = computed(() => tabs.map(tab => tab.code.trim().split('\n').length))
1514
1615
function getLang(filename: string) {
1716
if (filename.endsWith('.ts'))
@@ -168,32 +167,31 @@ function getCodeBlock(tab: { name: string, code: string }) {
168167

169168
<!-- Code content area -->
170169
<div class="flex flex-col items-start px-1 text-sm mt-6">
171-
<div class="w-full overflow-x-auto">
172-
<AnimatePresence mode="wait">
173-
<motion.div
174-
:key="currentTab"
175-
:initial="{ opacity: 0, y: 4 }"
176-
:animate="{ opacity: 1, y: 0 }"
177-
:exit="{ opacity: 0, y: -4 }"
178-
:transition="{ duration: 0.25, ease: 'easeOut' }"
179-
class="relative flex items-start px-1 text-sm min-w-max"
170+
<div class="w-full overflow-hidden">
171+
<!-- All tabs rendered for SSR, animated with CSS -->
172+
<div class="relative">
173+
<div
174+
v-for="(tab, index) in tabs"
175+
:key="tab.name"
176+
class="flex items-start px-1 text-sm min-w-max transition-all duration-250 ease-out"
177+
:class="index === currentTab ? 'opacity-100 relative' : 'opacity-0 absolute inset-0 pointer-events-none'"
180178
>
181179
<!-- Line numbers gutter -->
182180
<div
183181
aria-hidden="true"
184182
class="text-slate-600 select-none pl-2 pr-4 font-mono text-xs sm:text-sm leading-6"
185183
>
186-
<div v-for="i in lineCount" :key="i">
184+
<div v-for="i in lineCounts[index]" :key="i">
187185
{{ String(i).padStart(2, '0') }}
188186
</div>
189187
</div>
190188

191-
<!-- Code via MDC -->
189+
<!-- Code via MDC - all rendered during SSR -->
192190
<div class="hero-code">
193-
<MDC :value="getCodeBlock(tabs[currentTab]!)" tag="div" />
191+
<MDC :value="getCodeBlock(tab)" tag="div" />
194192
</div>
195-
</motion.div>
196-
</AnimatePresence>
193+
</div>
194+
</div>
197195
</div>
198196

199197
<!-- Demo CTA (bottom-right) -->

docs/nuxt.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ export default defineNuxtConfig({
1515

1616
app: {
1717
head: {
18-
meta: [
19-
{ property: 'og:image', content: '/og.png' },
20-
{ name: 'twitter:card', content: 'summary_large_image' },
21-
],
18+
link: [{ rel: 'icon', type: 'image/svg+xml', href: '/favicon.svg' }],
19+
meta: [{ name: 'twitter:card', content: 'summary_large_image' }],
2220
},
2321
},
2422

0 commit comments

Comments
 (0)