|
1 | 1 | <script setup lang="ts"> |
2 | | -import { useClipboard, useElementSize } from '@vueuse/core' |
| 2 | +import { useElementSize } from '@vueuse/core' |
3 | 3 | import { AnimatePresence, motion, MotionConfig } from 'motion-v' |
4 | 4 | // @ts-expect-error yaml is not typed |
5 | 5 | import hero from './hero.yml' |
6 | 6 |
|
7 | 7 | const currentTab = ref(0) |
8 | 8 | const contentRef = ref<HTMLElement | null>(null) |
9 | 9 | const { height } = useElementSize(contentRef) |
10 | | -const { copy, copied } = useClipboard() |
11 | 10 |
|
12 | 11 | const tabs = hero.tabs as { name: string, code: string }[] |
13 | 12 |
|
@@ -133,10 +132,10 @@ function getCodeBlock(tab: { name: string, code: string }) { |
133 | 132 | <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" /> |
134 | 133 |
|
135 | 134 | <!-- Code Preview Card --> |
136 | | - <MotionConfig :transition="{ duration: 0.5, type: 'spring', bounce: 0 }"> |
| 135 | + <MotionConfig :transition="{ duration: 0.3, ease: 'easeInOut' }"> |
137 | 136 | <motion.div |
138 | 137 | :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" |
140 | 139 | > |
141 | 140 | <div ref="contentRef"> |
142 | 141 | <div class="absolute -top-px left-0 right-0 h-px" /> |
@@ -168,43 +167,29 @@ function getCodeBlock(tab: { name: string, code: string }) { |
168 | 167 | </div> |
169 | 168 |
|
170 | 169 | <!-- 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"> |
186 | 171 | <div class="w-full overflow-x-auto"> |
187 | 172 | <AnimatePresence mode="wait"> |
188 | 173 | <motion.div |
189 | 174 | :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' }" |
194 | 179 | class="relative flex items-start px-1 text-sm min-w-max" |
195 | 180 | > |
196 | 181 | <!-- Line numbers gutter --> |
197 | 182 | <div |
198 | 183 | 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" |
200 | 185 | > |
201 | 186 | <div v-for="i in lineCount" :key="i"> |
202 | 187 | {{ String(i).padStart(2, '0') }} |
203 | 188 | </div> |
204 | 189 | </div> |
205 | 190 |
|
206 | 191 | <!-- Code via MDC --> |
207 | | - <div class="hero-code pl-4"> |
| 192 | + <div class="hero-code"> |
208 | 193 | <MDC :value="getCodeBlock(tabs[currentTab]!)" tag="div" /> |
209 | 194 | </div> |
210 | 195 | </motion.div> |
|
0 commit comments