33import { usePascalI18n } from '@pascal-app/core'
44import { useViewer } from '@pascal-app/viewer'
55import { useIsMobile } from '@pascal-app/viewer/ui'
6- import { PanelLeftOpen , X } from 'lucide-react'
6+ import { X } from 'lucide-react'
77import { type ReactNode , useCallback , useEffect , useLayoutEffect , useRef } from 'react'
88import {
99 openSidebarPanel ,
@@ -67,6 +67,7 @@ function MenuColumn({
6767 const activePanel = useShownSidebarPanel ( tabs )
6868 const setActivePanel = useEditor ( ( s ) => s . setActiveSidebarPanel )
6969 const setIsMenuHidden = useSidebarStore ( ( s ) => s . setIsMenuHidden )
70+ const isMenuHidden = useSidebarStore ( ( s ) => s . isMenuHidden )
7071
7172 // Menu click: open a closed panel (at a usable width), close it when
7273 // re-clicking the open entry, otherwise switch panels.
@@ -105,7 +106,8 @@ function MenuColumn({
105106 activeTab = { columnShown ? columnTabId : activePanel }
106107 collapsed = { toolClosed && ! columnShown }
107108 footer = { footer }
108- onHide = { ( ) => setIsMenuHidden ( true ) }
109+ menuHidden = { isMenuHidden }
110+ onToggle = { ( ) => setIsMenuHidden ( ! isMenuHidden ) }
109111 onTabClick = { handleTabClick }
110112 tabs = { tabs }
111113 />
@@ -398,10 +400,7 @@ function RightColumn({
398400 children,
399401 overlays,
400402 stageOverlay,
401- menuButton,
402403} : {
403- /** Shown first in the view bar row (or over the stage without one): brings a hidden menu back. */
404- menuButton ?: ReactNode
405404 toolbarLeft ?: ReactNode
406405 toolbarRight ?: ReactNode
407406 viewBar : boolean
@@ -413,7 +412,7 @@ function RightColumn({
413412 < div className = "relative flex min-w-0 flex-1 flex-col overflow-hidden" >
414413 { /* The view bar row sits above the stage, one bar per pane; the host's
415414 left toolbar rides after the first pane's views. */ }
416- { viewBar && < ViewBarRow leading = { toolbarLeft } start = { menuButton } /> }
415+ { viewBar && < ViewBarRow leading = { toolbarLeft } /> }
417416 < div
418417 className = "relative flex min-h-0 flex-1 flex-col overflow-hidden"
419418 style = { {
@@ -422,16 +421,9 @@ function RightColumn({
422421 boxShadow : '-4px -2px 16px rgba(0, 0, 0, 0.08), -1px 0 4px rgba(0, 0, 0, 0.04)' ,
423422 } }
424423 >
425- { ( ( ! viewBar && ( toolbarLeft || menuButton ) ) || toolbarRight ) && (
424+ { ( ( ! viewBar && toolbarLeft ) || toolbarRight ) && (
426425 < StageToolbar
427- toolbarLeft = {
428- viewBar ? undefined : (
429- < >
430- { menuButton }
431- { toolbarLeft }
432- </ >
433- )
434- }
426+ toolbarLeft = { viewBar ? undefined : toolbarLeft }
435427 toolbarRight = { toolbarRight }
436428 />
437429 ) }
@@ -464,24 +456,6 @@ function RightColumn({
464456 )
465457}
466458
467- /** Brings a hidden side menu back, ahead of the view tabs. */
468- function ShowMenuButton ( ) {
469- const i18n = usePascalI18n ( )
470- const setIsMenuHidden = useSidebarStore ( ( s ) => s . setIsMenuHidden )
471- const label = i18n . _ ( { id : 'editor.sidebar.sideMenu.show' , message : 'Menu' } )
472- return (
473- < button
474- aria-label = { i18n . _ ( { id : 'editor.sidebar.sideMenu.showLabel' , message : 'Show menu' } ) }
475- className = "flex h-8 shrink-0 items-center gap-1.5 rounded-full border border-border/60 px-3 font-medium text-muted-foreground text-sm transition-colors hover:bg-sidebar-accent hover:text-foreground"
476- onClick = { ( ) => setIsMenuHidden ( false ) }
477- type = "button"
478- >
479- < PanelLeftOpen aria-hidden className = "size-4" />
480- { label }
481- </ button >
482- )
483- }
484-
485459// ── Main v2 layout ───────────────────────────────────────────────────────────
486460
487461export interface EditorLayoutV2Props {
@@ -527,7 +501,6 @@ export function EditorLayoutV2({
527501 // A host with only the column's tab still gets the column (and the menu that lists it).
528502 const showSideColumns =
529503 ! ( isMobile || isCaptureMode ) && ( toolTabs . length > 0 || columnTab !== undefined )
530- const isMenuHidden = useSidebarStore ( ( s ) => s . isMenuHidden )
531504 // On a phone the column tab is one more sheet, so it stays a pickable tab.
532505 const isCollapsed = useSidebarStore ( ( s ) => s . isCollapsed )
533506 // The column tab picked before its column was there to take it (a host
@@ -562,15 +535,14 @@ export function EditorLayoutV2({
562535 }
563536
564537 const tool = showSideColumns ? openTool : undefined
565- const menuButton = showSideColumns && isMenuHidden ? < ShowMenuButton /> : null
566538 return (
567539 < div className = "flex h-full w-full flex-col bg-sidebar text-foreground" >
568540 { /* Top navbar */ }
569541 { navbarSlot }
570542
571543 { /* Main content: side menu, the chat or the open tool, work area */ }
572544 < div className = "flex min-h-0 flex-1" >
573- { showSideColumns && ! isMenuHidden && (
545+ { showSideColumns && (
574546 < MenuColumn
575547 columnTabId = { columnTab ?. id }
576548 toolClosed = { toolClosed }
@@ -594,7 +566,6 @@ export function EditorLayoutV2({
594566 < RightColumn
595567 overlays = { overlays }
596568 stageOverlay = { stageOverlay }
597- menuButton = { isCaptureMode ? undefined : menuButton }
598569 toolbarLeft = { isCaptureMode ? undefined : viewerToolbarLeft }
599570 toolbarRight = { isCaptureMode ? undefined : viewerToolbarRight }
600571 viewBar = { viewBar && ! isCaptureMode && ! stageOverlay }
0 commit comments