@@ -62,7 +62,9 @@ export const BlockPreview: React.FC<BlockPreviewProps> = ({ code, preview, title
62
62
return (
63
63
< section className = "group mb-16 border-b [--color-border:color-mix(in_oklab,var(--color-zinc-200)_75%,transparent)] dark:[--color-border:color-mix(in_oklab,var(--color-zinc-800)_60%,transparent)]" >
64
64
< div className = "relative border-y" >
65
- < div aria-hidden className = "absolute inset-x-4 -top-14 bottom-0 mx-auto max-w-7xl lg:inset-x-0" >
65
+ < div
66
+ aria-hidden
67
+ className = "absolute inset-x-4 -top-14 bottom-0 mx-auto max-w-7xl lg:inset-x-0" >
66
68
< div className = "to-(--color-border) absolute bottom-0 left-0 top-0 w-px bg-gradient-to-b from-transparent to-75%" > </ div >
67
69
< div className = "to-(--color-border) absolute bottom-0 right-0 top-0 w-px bg-gradient-to-b from-transparent to-75%" > </ div >
68
70
</ div >
@@ -72,50 +74,95 @@ export const BlockPreview: React.FC<BlockPreviewProps> = ({ code, preview, title
72
74
{ code && (
73
75
< >
74
76
< RadioGroup . Root className = "flex gap-0.5" >
75
- < RadioGroup . Item onClick = { ( ) => setMode ( 'preview' ) } aria-label = "Block preview" value = "100" checked = { mode == 'preview' } className = { radioItem } >
77
+ < RadioGroup . Item
78
+ onClick = { ( ) => setMode ( 'preview' ) }
79
+ aria-label = "Block preview"
80
+ value = "100"
81
+ checked = { mode == 'preview' }
82
+ className = { radioItem } >
76
83
< Eye className = "size-3.5 sm:opacity-50" />
77
84
< span className = "hidden text-[13px] sm:block" > Preview</ span >
78
85
</ RadioGroup . Item >
79
86
80
- < RadioGroup . Item onClick = { ( ) => setMode ( 'code' ) } aria-label = "Code" value = "0" checked = { mode == 'code' } className = { radioItem } >
87
+ < RadioGroup . Item
88
+ onClick = { ( ) => setMode ( 'code' ) }
89
+ aria-label = "Code"
90
+ value = "0"
91
+ checked = { mode == 'code' }
92
+ className = { radioItem } >
81
93
< Code2 className = "size-3.5 sm:opacity-50" />
82
94
< span className = "hidden text-[13px] sm:block" > Code</ span >
83
95
</ RadioGroup . Item >
84
96
</ RadioGroup . Root >
85
97
86
- < Separator orientation = "vertical" className = "hidden !h-4 lg:block" />
98
+ < Separator
99
+ orientation = "vertical"
100
+ className = "hidden !h-4 lg:block"
101
+ />
87
102
</ >
88
103
) }
89
104
{ previewOnly && (
90
105
< >
91
106
{ ' ' }
92
107
< span className = "ml-2 text-sm capitalize" > { title } </ span >
93
- < Separator orientation = "vertical" className = "!h-4" /> { ' ' }
108
+ < Separator
109
+ orientation = "vertical"
110
+ className = "!h-4"
111
+ /> { ' ' }
94
112
</ >
95
113
) }
96
- < Button asChild variant = "ghost" size = "sm" className = "size-8" >
97
- < Link href = { preview } passHref target = "_blank" >
114
+ < Button
115
+ asChild
116
+ variant = "ghost"
117
+ size = "sm"
118
+ className = "size-8" >
119
+ < Link
120
+ href = { preview }
121
+ passHref
122
+ target = "_blank" >
98
123
< Maximize className = "size-4" />
99
124
</ Link >
100
125
</ Button >
101
- < Separator orientation = "vertical" className = "hidden !h-4 lg:block" />
126
+ < Separator
127
+ orientation = "vertical"
128
+ className = "hidden !h-4 lg:block"
129
+ />
102
130
< span className = "text-muted-foreground hidden text-sm lg:block" > { width < MDSIZE ? 'Mobile' : width < LGSIZE ? 'Tablet' : 'Desktop' } </ span > { ' ' }
103
131
</ div >
104
132
105
133
< div className = "flex items-center gap-2" >
106
134
{ code && (
107
135
< >
108
- < Button onClick = { cliCopy } size = "sm" className = "size-8 shadow-none md:w-fit" variant = "outline" aria-label = "copy code" >
136
+ < Button
137
+ onClick = { cliCopy }
138
+ size = "sm"
139
+ className = "size-8 shadow-none md:w-fit"
140
+ variant = "outline"
141
+ aria-label = "copy code" >
109
142
{ cliCopied ? < Check className = "size-4" /> : < Terminal className = "!size-3.5" /> }
110
143
< span className = "hidden font-mono text-xs md:block" >
111
144
pnpm dlx shadcn@canary add { category } -{ titleToNumber ( title ) }
112
145
</ span >
113
146
</ Button >
114
- < Separator className = "!h-4" orientation = "vertical" />
115
- < OpenInV0Button { ...{ title, category } } block = { `${ category } -${ titleToNumber ( title ) } ` } />
116
- < Separator className = "!h-4" orientation = "vertical" />
117
-
118
- < Button onClick = { copy } size = "sm" variant = "ghost" aria-label = "copy code" className = "size-8" >
147
+ < Separator
148
+ className = "!h-4"
149
+ orientation = "vertical"
150
+ />
151
+ < OpenInV0Button
152
+ { ...{ title, category } }
153
+ block = { `${ category } -${ titleToNumber ( title ) } ` }
154
+ />
155
+ < Separator
156
+ className = "!h-4"
157
+ orientation = "vertical"
158
+ />
159
+
160
+ < Button
161
+ onClick = { copy }
162
+ size = "sm"
163
+ variant = "ghost"
164
+ aria-label = "copy code"
165
+ className = "size-8" >
119
166
{ copied ? < Check className = "size-4" /> : < Copy className = "!size-3.5" /> }
120
167
</ Button >
121
168
</ >
@@ -125,14 +172,19 @@ export const BlockPreview: React.FC<BlockPreviewProps> = ({ code, preview, title
125
172
</ div >
126
173
127
174
< div className = "relative" >
128
- < div aria-hidden className = "absolute inset-x-4 -bottom-14 mx-auto h-14 max-w-7xl lg:inset-x-0" >
175
+ < div
176
+ aria-hidden
177
+ className = "absolute inset-x-4 -bottom-14 mx-auto h-14 max-w-7xl lg:inset-x-0" >
129
178
< div className = "from-(--color-border) absolute bottom-0 left-0 top-0 w-px bg-gradient-to-b" > </ div >
130
179
< div className = "from-(--color-border) absolute bottom-0 right-0 top-0 w-px bg-gradient-to-b" > </ div >
131
180
</ div >
132
181
133
182
< div className = "relative z-10 mx-auto max-w-7xl px-4 lg:border-r lg:px-0" >
134
183
< div className = { cn ( 'bg-white dark:bg-transparent' , mode == 'code' && 'hidden' ) } >
135
- < PanelGroup direction = "horizontal" tagName = "div" ref = { ref } >
184
+ < PanelGroup
185
+ direction = "horizontal"
186
+ tagName = "div"
187
+ ref = { ref } >
136
188
< Panel
137
189
id = { `block-${ title } ` }
138
190
order = { 1 }
@@ -142,7 +194,20 @@ export const BlockPreview: React.FC<BlockPreviewProps> = ({ code, preview, title
142
194
defaultSize = { DEFAULTSIZE }
143
195
minSize = { SMSIZE }
144
196
className = "h-fit border-x" >
145
- < iframe loading = "lazy" allowFullScreen ref = { iframeRef } title = { title } height = { iframeHeight } className = "h-(--iframe-height) @starting:opacity-0 @starting:blur-xl block min-h-56 w-full duration-200 will-change-auto" src = { preview } id = { `block-${ title } ` } style = { { '--iframe-height' : `${ iframeHeight } px` } as React . CSSProperties } />
197
+ < iframe
198
+ key = { `${ category } -${ title } -iframe` }
199
+ loading = "lazy"
200
+ allowFullScreen
201
+ ref = { iframeRef }
202
+ title = { title }
203
+ height = { iframeHeight }
204
+ className = "h-(--iframe-height) @starting:opacity-0 @starting:blur-xl block min-h-56 w-full duration-200 will-change-auto"
205
+ src = { preview }
206
+ id = { `block-${ title } ` }
207
+ style = { { '--iframe-height' : `${ iframeHeight } px` } as React . CSSProperties }
208
+ { ...{ fetchpriority : 'low' } }
209
+ />
210
+
146
211
{ isLoading && (
147
212
< div className = "bg-background absolute inset-0 right-2 flex items-center justify-center border-x" >
148
213
< div className = "border-primary size-6 animate-spin rounded-full border-2 border-t-transparent" />
@@ -153,13 +218,25 @@ export const BlockPreview: React.FC<BlockPreviewProps> = ({ code, preview, title
153
218
{ isLarge && (
154
219
< >
155
220
< PanelResizeHandle className = "relative w-2 before:absolute before:inset-0 before:m-auto before:h-12 before:w-1 before:rounded-full before:bg-zinc-300 before:transition-[height,background] hover:before:h-16 hover:before:bg-zinc-400 focus:before:bg-zinc-400 dark:before:bg-zinc-600 dark:hover:before:bg-zinc-500 dark:focus:before:bg-zinc-400" />
156
- < Panel id = { `code-${ title } ` } order = { 2 } defaultSize = { 100 - DEFAULTSIZE } className = "-mr-[0.5px] ml-px" > </ Panel >
221
+ < Panel
222
+ id = { `code-${ title } ` }
223
+ order = { 2 }
224
+ defaultSize = { 100 - DEFAULTSIZE }
225
+ className = "-mr-[0.5px] ml-px" > </ Panel >
157
226
</ >
158
227
) }
159
228
</ PanelGroup >
160
229
</ div >
161
230
162
- < div className = "bg-white dark:bg-transparent" > { mode == 'code' && < CodeBlock code = { code as string } lang = "tsx" maxHeight = { iframeHeight } /> } </ div >
231
+ < div className = "bg-white dark:bg-transparent" >
232
+ { mode == 'code' && (
233
+ < CodeBlock
234
+ code = { code as string }
235
+ lang = "tsx"
236
+ maxHeight = { iframeHeight }
237
+ />
238
+ ) }
239
+ </ div >
163
240
</ div >
164
241
</ div >
165
242
</ section >
0 commit comments