@@ -14,6 +14,12 @@ const DesktopThemePreview = ({
14
14
clearPreviewIds,
15
15
setPreviewIds,
16
16
} : DesktopThemePreviewProps ) => {
17
+ const [ isVisible , setIsVisible ] = useState ( false ) ;
18
+
19
+ const toggleDrawerVisibility = ( ) => {
20
+ setIsVisible ( ! isVisible ) ;
21
+ } ;
22
+
17
23
// flow for interactive chatbot
18
24
const flow = {
19
25
start : {
@@ -61,34 +67,80 @@ const DesktopThemePreview = ({
61
67
} ,
62
68
} ;
63
69
64
- console . log ( previewIds )
70
+ const handleRemoveSelectionClick = ( previewIdToRemove : string ) => {
71
+ const filteredPreviewIds = previewIds . filter (
72
+ ( previewId ) => previewId !== previewIdToRemove
73
+ ) ;
74
+ setPreviewIds ( [ ...filteredPreviewIds ] ) ;
75
+ } ;
65
76
66
- return (
67
- < div className = "h-screen bg-accent-800 p-5 w-[45rem] flex flex-col items-center" >
68
- < div className = "text-accent-50 mb-12 w-full" >
77
+ return isVisible ? (
78
+ < div
79
+ className = { `h-[92vh] bg-accent-800 p-5 flex flex-col items-center w-screen md:w-[45rem] absolute md:relative` }
80
+ >
81
+ < div className = "text-accent-50 mb-4 md:mb-12 w-full md:mt-14" >
69
82
< h2 className = "text-2xl font-semibold" > Preview</ h2 >
70
- < h3 className = "text-accent-400" > { previewIds . length } theme(s) selected</ h3 >
83
+ < h3 className = "text-accent-400" >
84
+ { previewIds . length } theme(s) selected
85
+ </ h3 >
86
+ </ div >
87
+ < button className = "text-accent-50 top-3 right-5 absolute" onClick = { toggleDrawerVisibility } > Close</ button >
88
+ < div className = "hidden md:block absolute left-[-2rem]" >
89
+ < span className = "bg-blue-500 text-accent-50 text-sm px-[8px] py-[3px] rounded-full absolute left-[-12px] top-[-10px]" >
90
+ { previewIds . length }
91
+ </ span >
92
+ < button
93
+ onClick = { toggleDrawerVisibility }
94
+ className = "text-accent-50 text-lg bg-accent-700 py-2 px-3 rounded-lg"
95
+ >
96
+ Collapse { '>>' }
97
+ </ button >
71
98
</ div >
72
99
< ChatBot
73
100
flow = { flow }
74
101
themes = { previewIds . map ( ( themeId ) => ( { id : themeId } ) ) }
75
102
settings = { { general : { embedded : true } } }
76
103
styles = { { chatWindowStyle : { height : '50vh' } } }
77
104
/>
78
- < div className = "w-full mt-8" >
105
+ < div className = "w-full mt-8 max-h-[300px] overflow-y-auto " >
79
106
{ previewIds . map ( ( previewId ) => {
80
- const previewTitle = formatPreviewIdToTitleCase ( previewId )
81
- return < div className = "flex justify-between my-2" >
82
- < span className = "text-accent-50 font-semibold text-lg" > { previewTitle } </ span >
83
- < span className = "text-blue-500 font-semibold" > Remove Selection (x)</ span >
84
- </ div >
107
+ const previewTitle = formatPreviewIdToTitleCase ( previewId ) ;
108
+ return (
109
+ < div className = "flex justify-between my-2" >
110
+ < span className = "text-accent-50 font-semibold text-lg" >
111
+ { previewTitle }
112
+ </ span >
113
+ < button
114
+ onClick = { ( ) => handleRemoveSelectionClick ( previewId ) }
115
+ className = "text-blue-500 hover:text-blue-600 font-semibold"
116
+ >
117
+ Remove Selection (x)
118
+ </ button >
119
+ </ div >
120
+ ) ;
85
121
} ) }
86
122
</ div >
87
123
< div className = "flex flex-col p-3 w-full items-center" >
88
- < button className = "bg-accent-700 text-accent-400 text-lg py-2 rounded-lg my-2 w-[90%] hover:bg-accent-600 hover:text-accent-300" > Download theme bundle</ button >
89
- < button className = "bg-accent-300 text-accent-950 text-lg py-2 rounded-lg my-2 w-[90%] hover:bg-accent-200" > Edit in theme builder</ button >
124
+ < button className = "bg-accent-700 text-accent-400 text-lg py-2 rounded-lg my-2 w-[90%] hover:bg-accent-600 hover:text-accent-300" >
125
+ Download theme bundle
126
+ </ button >
127
+ < button className = "bg-accent-300 text-accent-950 text-lg py-2 rounded-lg my-2 w-[90%] hover:bg-accent-200" >
128
+ Edit in theme builder
129
+ </ button >
90
130
</ div >
91
131
</ div >
132
+ ) : (
133
+ < div className = "absolute bottom-6 md:top-32 right-5" >
134
+ < span className = "bg-blue-500 text-accent-50 text-sm px-[8px] py-[3px] rounded-full absolute left-[-12px] top-[-10px]" >
135
+ { previewIds . length }
136
+ </ span >
137
+ < button
138
+ onClick = { toggleDrawerVisibility }
139
+ className = "text-accent-50 text-lg bg-accent-700 py-2 px-3 rounded-lg"
140
+ >
141
+ Show Preview
142
+ </ button >
143
+ </ div >
92
144
) ;
93
145
} ;
94
146
0 commit comments