|
1 | 1 | import { useRef, useState, type ReactNode } from "react"; |
2 | | -import { Box, Kbd, rawTheme, Text } from "@webstudio-is/design-system"; |
| 2 | +import { Kbd, rawTheme, Text } from "@webstudio-is/design-system"; |
3 | 3 | import { useSubscribe, type Publish } from "~/shared/pubsub"; |
4 | 4 | import { $dragAndDropState, $isPreviewMode } from "~/shared/nano-states"; |
5 | 5 | import { Flex } from "@webstudio-is/design-system"; |
@@ -183,80 +183,79 @@ export const SidebarLeft = ({ publish }: SidebarLeftProps) => { |
183 | 183 | }); |
184 | 184 |
|
185 | 185 | return ( |
186 | | - <Flex grow> |
187 | | - <SidebarTabs |
188 | | - activationMode="manual" |
189 | | - value={activePanel} |
190 | | - orientation="vertical" |
191 | | - > |
192 | | - { |
193 | | - // In preview mode, we don't show left sidebar, but we want to allow pages panel to be open in the preview mode. |
194 | | - // This way user can switch pages without exiting preview mode. |
195 | | - } |
196 | | - {isPreviewMode === false && ( |
197 | | - <> |
198 | | - <ExternalDragDropMonitor /> |
199 | | - <div ref={tabsWrapperRef} style={{ display: "contents" }}> |
200 | | - <SidebarTabsList> |
201 | | - {panels.map(({ name, Icon, label }) => { |
202 | | - return ( |
203 | | - <SidebarTabsTrigger |
204 | | - key={name} |
205 | | - label={label} |
206 | | - value={name} |
207 | | - onClick={() => { |
208 | | - toggleActiveSidebarPanel(name); |
209 | | - }} |
210 | | - > |
211 | | - <Icon size={rawTheme.spacing[10]} /> |
212 | | - </SidebarTabsTrigger> |
213 | | - ); |
214 | | - })} |
215 | | - </SidebarTabsList> |
216 | | - </div> |
217 | | - |
218 | | - <Box css={{ borderRight: `1px solid ${theme.colors.borderMain}` }}> |
219 | | - <AiTabTrigger /> |
220 | | - <HelpTabTrigger /> |
221 | | - </Box> |
222 | | - </> |
223 | | - )} |
| 186 | + <SidebarTabs |
| 187 | + activationMode="manual" |
| 188 | + value={activePanel} |
| 189 | + orientation="vertical" |
| 190 | + > |
| 191 | + { |
| 192 | + // In preview mode, we don't show left sidebar, but we want to allow pages panel to be open in the preview mode. |
| 193 | + // This way user can switch pages without exiting preview mode. |
| 194 | + } |
| 195 | + {isPreviewMode === false && ( |
| 196 | + <Flex |
| 197 | + grow |
| 198 | + direction="column" |
| 199 | + css={{ borderRight: `1px solid ${theme.colors.borderMain}` }} |
| 200 | + > |
| 201 | + <ExternalDragDropMonitor /> |
| 202 | + <div ref={tabsWrapperRef} style={{ display: "contents" }}> |
| 203 | + <SidebarTabsList> |
| 204 | + {panels.map(({ name, Icon, label }) => { |
| 205 | + return ( |
| 206 | + <SidebarTabsTrigger |
| 207 | + key={name} |
| 208 | + label={label} |
| 209 | + value={name} |
| 210 | + onClick={() => { |
| 211 | + toggleActiveSidebarPanel(name); |
| 212 | + }} |
| 213 | + > |
| 214 | + <Icon size={rawTheme.spacing[10]} /> |
| 215 | + </SidebarTabsTrigger> |
| 216 | + ); |
| 217 | + })} |
| 218 | + </SidebarTabsList> |
| 219 | + </div> |
| 220 | + <AiTabTrigger /> |
| 221 | + <HelpTabTrigger /> |
| 222 | + </Flex> |
| 223 | + )} |
224 | 224 |
|
225 | | - <SidebarTabsContent |
226 | | - value={activePanel === "none" ? "" : activePanel} |
227 | | - onKeyDown={(event) => { |
228 | | - if (event.key === "Escape") { |
229 | | - setActiveSidebarPanel("none"); |
230 | | - } |
231 | | - }} |
| 225 | + <SidebarTabsContent |
| 226 | + value={activePanel === "none" ? "" : activePanel} |
| 227 | + onKeyDown={(event) => { |
| 228 | + if (event.key === "Escape") { |
| 229 | + setActiveSidebarPanel("none"); |
| 230 | + } |
| 231 | + }} |
| 232 | + css={{ |
| 233 | + width: theme.spacing[30], |
| 234 | + // We need the node to be rendered but hidden |
| 235 | + // to keep receiving the drag events. |
| 236 | + visibility: |
| 237 | + dragAndDropState.isDragging && |
| 238 | + dragAndDropState.dragPayload?.origin === "panel" && |
| 239 | + getSetting("navigatorLayout") !== "undocked" |
| 240 | + ? "hidden" |
| 241 | + : "visible", |
| 242 | + }} |
| 243 | + > |
| 244 | + <Flex |
232 | 245 | css={{ |
233 | | - width: theme.spacing[30], |
234 | | - // We need the node to be rendered but hidden |
235 | | - // to keep receiving the drag events. |
236 | | - visibility: |
237 | | - dragAndDropState.isDragging && |
238 | | - dragAndDropState.dragPayload?.origin === "panel" && |
239 | | - getSetting("navigatorLayout") !== "undocked" |
240 | | - ? "hidden" |
241 | | - : "visible", |
| 246 | + position: "relative", |
| 247 | + height: "100%", |
| 248 | + flexGrow: 1, |
| 249 | + background: theme.colors.backgroundPanel, |
242 | 250 | }} |
| 251 | + direction="column" |
243 | 252 | > |
244 | | - <Flex |
245 | | - css={{ |
246 | | - position: "relative", |
247 | | - height: "100%", |
248 | | - flexGrow: 1, |
249 | | - background: theme.colors.backgroundPanel, |
250 | | - }} |
251 | | - direction="column" |
252 | | - > |
253 | | - <Panel |
254 | | - publish={publish} |
255 | | - onClose={() => setActiveSidebarPanel("none")} |
256 | | - /> |
257 | | - </Flex> |
258 | | - </SidebarTabsContent> |
259 | | - </SidebarTabs> |
260 | | - </Flex> |
| 253 | + <Panel |
| 254 | + publish={publish} |
| 255 | + onClose={() => setActiveSidebarPanel("none")} |
| 256 | + /> |
| 257 | + </Flex> |
| 258 | + </SidebarTabsContent> |
| 259 | + </SidebarTabs> |
261 | 260 | ); |
262 | 261 | }; |
0 commit comments