1
1
import { Button } from "@/components/Button" ;
2
- import { ResizablePanel } from "@/components/Resizable" ;
2
+ import {
3
+ ResizableHandle ,
4
+ ResizablePanel ,
5
+ ResizablePanelGroup ,
6
+ } from "@/components/Resizable" ;
3
7
import { ActivityIcon , ExternalLinkIcon } from "lucide-react" ;
4
- import type { FC } from "react" ;
8
+ import { useRef , useState , type FC } from "react" ;
9
+ import type { ImperativePanelHandle } from "react-resizable-panels" ;
5
10
6
11
export const Preview : FC = ( ) => {
12
+ const errorPanelRef = useRef < ImperativePanelHandle > ( null ) ;
13
+ const onCollapseError = ( ) => {
14
+ errorPanelRef . current ?. collapse ( ) ;
15
+ } ;
16
+ const [ overlayOpacity , setOverlayOpacity ] = useState ( ( ) => 50 ) ;
17
+
7
18
return (
8
- < ResizablePanel className = "flex flex-col items-start gap-6 p-8" >
19
+ < ResizablePanel className = "relative flex flex-col items-start gap-6 p-8" >
20
+ < div
21
+ className = "pointer-events-none absolute top-0 left-0 h-full w-full bg-black"
22
+ style = { { opacity : overlayOpacity / 100 } }
23
+ >
24
+ { /* OVERLAY */ }
25
+ </ div >
26
+
9
27
< div className = "flex w-full items-center justify-between" >
10
28
< p className = "font-semibold text-3xl text-content-primary" >
11
29
Parameters
@@ -16,7 +34,11 @@ export const Preview: FC = () => {
16
34
< div className = "flex h-full w-full items-center justify-center rounded-xl border p-4" >
17
35
< div className = "flex flex-col items-center justify-center gap-3" >
18
36
< div className = "flex items-center justify-center rounded-[6px] bg-highlight-sky p-2" >
19
- < ActivityIcon className = "text-content-invert" width = { 24 } height = { 24 } />
37
+ < ActivityIcon
38
+ className = "text-content-invert"
39
+ width = { 24 }
40
+ height = { 24 }
41
+ />
20
42
</ div >
21
43
22
44
< div className = "flex flex-col items-center gap-2" >
@@ -33,14 +55,37 @@ export const Preview: FC = () => {
33
55
href = "#todo"
34
56
className = "flex items-center gap-0.5 text-content-link text-sm"
35
57
>
36
- Read the docs{ " " }
58
+ Read the docs
37
59
< span className = "inline" >
38
60
< ExternalLinkIcon width = { 16 } />
39
61
</ span >
40
62
</ a >
41
63
</ div >
42
64
</ div >
43
65
</ div >
66
+
67
+ < ResizablePanelGroup
68
+ direction = "vertical"
69
+ className = "pointer-events-none absolute top-0 left-0"
70
+ >
71
+ < ResizablePanel aria-hidden className = "pointer-events-none" >
72
+ { /* EMPTY */ }
73
+ </ ResizablePanel >
74
+ < ResizableHandle
75
+ onClick = { onCollapseError }
76
+ className = "flex h-4 min-h-4 w-full items-center justify-center rounded-t-xl bg-[#AA5253]"
77
+ withHandle = { true }
78
+ />
79
+ < ResizablePanel
80
+ ref = { errorPanelRef }
81
+ className = "bg-surface-secondary"
82
+ collapsible = { true }
83
+ collapsedSize = { 0 }
84
+ onResize = { ( size ) => {
85
+ setOverlayOpacity ( ( ) => size ) ;
86
+ } }
87
+ > </ ResizablePanel >
88
+ </ ResizablePanelGroup >
44
89
</ ResizablePanel >
45
90
) ;
46
91
} ;
0 commit comments