Skip to content

Commit d25d66d

Browse files
committed
Revert "fix: improve landing page code preview UI"
This reverts commit 7079fd0.
1 parent 7079fd0 commit d25d66d

File tree

3 files changed

+46
-48
lines changed

3 files changed

+46
-48
lines changed

docs/app/assets/css/main.css

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

9996
@media (min-width: 640px) {
@@ -109,13 +106,3 @@ pre, code {
109106
.hero-code .shiki {
110107
background: transparent !important;
111108
}
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: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<script setup lang="ts">
2-
import { useElementSize } from '@vueuse/core'
3-
import { motion, MotionConfig } from 'motion-v'
2+
import { useClipboard, useElementSize } from '@vueuse/core'
3+
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()
1011
1112
const tabs = hero.tabs as { name: string, code: string }[]
1213
@@ -132,10 +133,10 @@ function getCodeBlock(tab: { name: string, code: string }) {
132133
<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" />
133134

134135
<!-- Code Preview Card -->
135-
<MotionConfig :transition="{ duration: 0.15, type: 'spring', bounce: 0 }">
136+
<MotionConfig :transition="{ duration: 0.5, type: 'spring', bounce: 0 }">
136137
<motion.div
137138
:animate="{ height: height > 0 ? height : undefined }"
138-
class="code-preview relative overflow-hidden rounded-sm backdrop-blur-lg"
139+
class="code-preview relative overflow-hidden rounded-sm ring-1 ring-white/10 backdrop-blur-lg"
139140
>
140141
<div ref="contentRef">
141142
<div class="absolute -top-px left-0 right-0 h-px" />
@@ -167,24 +168,47 @@ function getCodeBlock(tab: { name: string, code: string }) {
167168
</div>
168169

169170
<!-- Code content area -->
170-
<div class="flex flex-col items-start px-1 text-sm mt-4">
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+
171186
<div class="w-full overflow-x-auto">
172-
<div class="relative flex items-start px-1 text-sm min-w-max">
173-
<!-- Line numbers gutter -->
174-
<div
175-
aria-hidden="true"
176-
class="text-slate-600 select-none pl-2 pr-4 font-mono text-xs sm:text-sm leading-6"
187+
<AnimatePresence mode="wait">
188+
<motion.div
189+
:key="currentTab"
190+
:initial="{ opacity: 0 }"
191+
:animate="{ opacity: 1 }"
192+
:exit="{ opacity: 0 }"
193+
:transition="{ duration: 0.5 }"
194+
class="relative flex items-start px-1 text-sm min-w-max"
177195
>
178-
<div v-for="i in lineCount" :key="i">
179-
{{ String(i).padStart(2, '0') }}
196+
<!-- Line numbers gutter -->
197+
<div
198+
aria-hidden="true"
199+
class="border-slate-300/5 text-slate-600 select-none border-r pr-4 font-mono"
200+
>
201+
<div v-for="i in lineCount" :key="i">
202+
{{ String(i).padStart(2, '0') }}
203+
</div>
180204
</div>
181-
</div>
182205

183-
<!-- Code via MDC -->
184-
<div class="hero-code">
185-
<MDC :value="getCodeBlock(tabs[currentTab]!)" tag="div" />
186-
</div>
187-
</div>
206+
<!-- Code via MDC -->
207+
<div class="hero-code pl-4">
208+
<MDC :value="getCodeBlock(tabs[currentTab]!)" tag="div" />
209+
</div>
210+
</motion.div>
211+
</AnimatePresence>
188212
</div>
189213

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

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ tabs:
1515
'/admin/**': { auth: 'admin' },
1616
},
1717
})
18-
- name: server/auth.config.ts
18+
- name: auth.config.ts
1919
code: |
2020
import { admin, twoFactor } from 'better-auth/plugins'
2121
@@ -26,20 +26,7 @@ tabs:
2626
},
2727
plugins: [admin(), twoFactor()],
2828
}))
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
29+
- name: login.vue
4330
code: |
4431
<script setup lang="ts">
4532
const { signIn } = useUserSession()

0 commit comments

Comments
 (0)