Skip to content

Commit d64c0a9

Browse files
committed
fix: improve landing page code preview UI and animations
1 parent d25d66d commit d64c0a9

File tree

3 files changed

+40
-29
lines changed

3 files changed

+40
-29
lines changed

docs/app/assets/css/main.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ pre, code {
8888
/* Hero code block styling */
8989
.hero-code pre {
9090
background: transparent !important;
91-
padding: 0.5rem 1rem;
92-
margin: 0;
91+
border: none !important;
92+
padding: 0 !important;
93+
margin: 0 !important;
9394
font-size: 0.75rem;
95+
border-radius: 0 !important;
96+
line-height: 1.5rem !important;
9497
}
9598

9699
@media (min-width: 640px) {
@@ -106,3 +109,13 @@ pre, code {
106109
.hero-code .shiki {
107110
background: transparent !important;
108111
}
112+
113+
/* Hide MDC's copy button in hero */
114+
.hero-code .group > button {
115+
display: none !important;
116+
}
117+
118+
/* Remove wrapper margin */
119+
.hero-code > div > div {
120+
margin: 0 !important;
121+
}

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

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<script setup lang="ts">
2-
import { useClipboard, useElementSize } from '@vueuse/core'
2+
import { useElementSize } from '@vueuse/core'
33
import { AnimatePresence, motion, MotionConfig } from 'motion-v'
44
// @ts-expect-error yaml is not typed
55
import hero from './hero.yml'
66
77
const currentTab = ref(0)
88
const contentRef = ref<HTMLElement | null>(null)
99
const { height } = useElementSize(contentRef)
10-
const { copy, copied } = useClipboard()
1110
1211
const tabs = hero.tabs as { name: string, code: string }[]
1312
@@ -133,10 +132,10 @@ function getCodeBlock(tab: { name: string, code: string }) {
133132
<div class="from-stone-300 via-stone-300/70 to-blue-300 absolute inset-0 rounded-none bg-gradient-to-tr opacity-0 dark:opacity-5" />
134133

135134
<!-- Code Preview Card -->
136-
<MotionConfig :transition="{ duration: 0.5, type: 'spring', bounce: 0 }">
135+
<MotionConfig :transition="{ duration: 0.3, ease: 'easeInOut' }">
137136
<motion.div
138137
:animate="{ height: height > 0 ? height : undefined }"
139-
class="code-preview relative overflow-hidden rounded-sm ring-1 ring-white/10 backdrop-blur-lg"
138+
class="code-preview relative overflow-hidden rounded-sm backdrop-blur-lg"
140139
>
141140
<div ref="contentRef">
142141
<div class="absolute -top-px left-0 right-0 h-px" />
@@ -168,43 +167,29 @@ function getCodeBlock(tab: { name: string, code: string }) {
168167
</div>
169168

170169
<!-- Code content area -->
171-
<div class="flex flex-col items-start px-1 text-sm">
172-
<!-- Copy button (top-right) -->
173-
<div class="absolute top-2 right-4">
174-
<UButton
175-
variant="outline"
176-
size="xs"
177-
class="border-none bg-transparent size-5"
178-
:aria-label="copied ? 'Copied' : 'Copy code'"
179-
@click="copy(currentCode)"
180-
>
181-
<UIcon :name="copied ? 'i-lucide-check' : 'i-lucide-copy'" class="size-3" />
182-
<span class="sr-only">Copy code</span>
183-
</UButton>
184-
</div>
185-
170+
<div class="flex flex-col items-start px-1 text-sm mt-6">
186171
<div class="w-full overflow-x-auto">
187172
<AnimatePresence mode="wait">
188173
<motion.div
189174
:key="currentTab"
190-
:initial="{ opacity: 0 }"
191-
:animate="{ opacity: 1 }"
192-
:exit="{ opacity: 0 }"
193-
:transition="{ duration: 0.5 }"
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' }"
194179
class="relative flex items-start px-1 text-sm min-w-max"
195180
>
196181
<!-- Line numbers gutter -->
197182
<div
198183
aria-hidden="true"
199-
class="border-slate-300/5 text-slate-600 select-none border-r pr-4 font-mono"
184+
class="text-slate-600 select-none pl-2 pr-4 font-mono text-xs sm:text-sm leading-6"
200185
>
201186
<div v-for="i in lineCount" :key="i">
202187
{{ String(i).padStart(2, '0') }}
203188
</div>
204189
</div>
205190

206191
<!-- Code via MDC -->
207-
<div class="hero-code pl-4">
192+
<div class="hero-code">
208193
<MDC :value="getCodeBlock(tabs[currentTab]!)" tag="div" />
209194
</div>
210195
</motion.div>

docs/app/components/content/landing/hero.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tabs:
1515
'/admin/**': { auth: 'admin' },
1616
},
1717
})
18-
- name: auth.config.ts
18+
- name: server/auth.config.ts
1919
code: |
2020
import { admin, twoFactor } from 'better-auth/plugins'
2121
@@ -26,7 +26,20 @@ tabs:
2626
},
2727
plugins: [admin(), twoFactor()],
2828
}))
29-
- name: login.vue
29+
- name: app/auth.client.ts
30+
code: |
31+
import { adminClient, twoFactorClient } from 'better-auth/client/plugins'
32+
import { createAuthClient } from 'better-auth/vue'
33+
34+
export function createAppAuthClient(baseURL: string) {
35+
return createAuthClient({
36+
baseURL,
37+
plugins: [adminClient(), twoFactorClient()],
38+
})
39+
}
40+
41+
export type AppAuthClient = ReturnType<typeof createAppAuthClient>
42+
- name: app/pages/login.vue
3043
code: |
3144
<script setup lang="ts">
3245
const { signIn } = useUserSession()

0 commit comments

Comments
 (0)