Skip to content

Commit 559c0d1

Browse files
authored
editor: keep the side menu toggle at the left edge (#1283)
* editor: keep the side menu toggle at the left edge * editor: regenerate catalogs after removing the canvas menu label
1 parent 31642a7 commit 559c0d1

9 files changed

Lines changed: 69 additions & 111 deletions

File tree

‎packages/editor/src/components/editor/editor-layout-v2.tsx‎

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { usePascalI18n } from '@pascal-app/core'
44
import { useViewer } from '@pascal-app/viewer'
55
import { useIsMobile } from '@pascal-app/viewer/ui'
6-
import { PanelLeftOpen, X } from 'lucide-react'
6+
import { X } from 'lucide-react'
77
import { type ReactNode, useCallback, useEffect, useLayoutEffect, useRef } from 'react'
88
import {
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

487461
export 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}

‎packages/editor/src/components/ui/sidebar/tab-bar.tsx‎

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
'use client'
22

33
import { usePascalI18n } from '@pascal-app/core'
4-
import { PanelLeftClose } from 'lucide-react'
5-
import type { ReactNode } from 'react'
4+
import { PanelLeftClose, PanelLeftOpen } from 'lucide-react'
5+
import { type ReactNode, useId } from 'react'
66
import { triggerSFX } from './../../../lib/sfx-bus'
77
import { cn } from './../../../lib/utils'
8-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@pascal-app/viewer/ui'
98

109
export type SidebarTab = {
1110
id: string
@@ -85,8 +84,8 @@ interface SideMenuProps {
8584
onTabClick: (id: string) => void
8685
/** Listed after the entries, e.g. the host's recent chats. */
8786
footer?: ReactNode
88-
/** Hides the whole menu; a Menu button above the stage brings it back. */
89-
onHide: () => void
87+
menuHidden: boolean
88+
onToggle: () => void
9089
}
9190

9291
/**
@@ -100,10 +99,14 @@ export function SideMenu({
10099
collapsed,
101100
onTabClick,
102101
footer,
103-
onHide,
102+
menuHidden,
103+
onToggle,
104104
}: SideMenuProps) {
105105
const i18n = usePascalI18n()
106-
const hideLabel = i18n._({ id: 'editor.sidebar.sideMenu.hide', message: 'Hide menu' })
106+
const contentId = useId()
107+
const toggleLabel = menuHidden
108+
? i18n._({ id: 'editor.sidebar.sideMenu.showLabel', message: 'Show menu' })
109+
: i18n._({ id: 'editor.sidebar.sideMenu.hide', message: 'Hide menu' })
107110
const litTab = tabs.find((t) => t.id === activeTab)?.menuParent ?? activeTab
108111
const groups: { section?: string; tabs: SidebarTab[] }[] = []
109112
for (const tab of tabs) {
@@ -116,20 +119,36 @@ export function SideMenu({
116119

117120
return (
118121
<nav
119-
className="flex h-full w-44 shrink-0 flex-col border-border/50 border-r"
122+
className={cn(
123+
'flex h-full shrink-0 flex-col border-border/50 border-r',
124+
menuHidden ? 'w-12' : 'w-44',
125+
)}
120126
data-surface="icon-rail"
121127
>
122-
<div className="flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-2 py-2">
128+
<div className="shrink-0 p-2">
123129
<button
124-
aria-label={hideLabel}
125-
className="flex h-8 w-full shrink-0 items-center gap-2 rounded-xl px-2.5 text-muted-foreground text-xs transition-colors hover:bg-sidebar-accent/50 hover:text-foreground"
126-
onClick={onHide}
127-
title={hideLabel}
130+
aria-controls={contentId}
131+
aria-expanded={!menuHidden}
132+
aria-label={toggleLabel}
133+
className="flex size-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-sidebar-accent/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-2"
134+
onClick={onToggle}
135+
title={toggleLabel}
128136
type="button"
129137
>
130-
<PanelLeftClose aria-hidden className="size-4" />
131-
{hideLabel}
138+
{menuHidden ? (
139+
<PanelLeftOpen aria-hidden className="size-4" />
140+
) : (
141+
<PanelLeftClose aria-hidden className="size-4" />
142+
)}
132143
</button>
144+
</div>
145+
<div
146+
className={cn(
147+
'min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-2 pb-2',
148+
menuHidden ? 'hidden' : 'flex',
149+
)}
150+
id={contentId}
151+
>
133152
{groups.map((group) => (
134153
<div className="flex flex-col gap-0.5" key={group.section ?? ''}>
135154
{group.section ? (

‎packages/editor/src/i18n/locales/en-XA/messages.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎packages/editor/src/i18n/locales/en/messages.po‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6290,11 +6290,7 @@ msgstr "Hide menu"
62906290
msgid "editor.sidebar.sideMenu.plugins"
62916291
msgstr "Plugins"
62926292

6293-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
6294-
msgid "editor.sidebar.sideMenu.show"
6295-
msgstr "Menu"
6296-
6297-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
6293+
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
62986294
msgid "editor.sidebar.sideMenu.showLabel"
62996295
msgstr "Show menu"
63006296

‎packages/editor/src/i18n/locales/en/messages.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎packages/editor/src/i18n/locales/es/messages.po‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14656,6 +14656,7 @@ msgstr "Taller"
1465614656
# Source-Hash: 4323751093d4c560
1465714657
# Review: required
1465814658
# AI-Provider: claude-code
14659+
# English: "Still loading the project. Editing is paused until it finishes."
1465914660
#: packages/editor/src/components/editor/index.tsx
1466014661
#, fuzzy
1466114662
msgid "editor.sceneData.pending"
@@ -15601,25 +15602,25 @@ msgstr "Actualizar instantánea"
1560115602
msgid "editor.sidebar.panels.zonePanel.viewSnapshot"
1560215603
msgstr "Ver instantánea"
1560315604

15604-
# English: "Browse plugins"
1560515605
# Source-Hash: 7890c110650ad1e5
1560615606
# Review: required
15607+
# English: "Browse plugins"
1560715608
#: packages/editor/src/components/ui/sidebar/plugins-menu-panel.tsx
1560815609
#, fuzzy
1560915610
msgid "editor.sidebar.pluginsMenu.browse"
1561015611
msgstr "Explorar complementos"
1561115612

15612-
# English: "No plugins in this project yet."
1561315613
# Source-Hash: fd7380e83e3c88b3
1561415614
# Review: required
15615+
# English: "No plugins in this project yet."
1561515616
#: packages/editor/src/components/ui/sidebar/plugins-menu-panel.tsx
1561615617
#, fuzzy
1561715618
msgid "editor.sidebar.pluginsMenu.empty"
1561815619
msgstr "Aún no hay complementos en este proyecto."
1561915620

15620-
# English: "Hide menu"
1562115621
# Source-Hash: 8284b6d9e4c05fb1
1562215622
# Review: required
15623+
# English: "Hide menu"
1562315624
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
1562415625
#, fuzzy
1562515626
msgid "editor.sidebar.sideMenu.hide"
@@ -15636,18 +15637,10 @@ msgstr "Ocultar menú"
1563615637
msgid "editor.sidebar.sideMenu.plugins"
1563715638
msgstr "Complementos"
1563815639

15639-
# English: "Menu"
15640-
# Source-Hash: 1340afc2c56c0229
15641-
# Review: required
15642-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
15643-
#, fuzzy
15644-
msgid "editor.sidebar.sideMenu.show"
15645-
msgstr "Menú"
15646-
15647-
# English: "Show menu"
1564815640
# Source-Hash: 5e1ae5cd25820c60
1564915641
# Review: required
15650-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
15642+
# English: "Show menu"
15643+
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
1565115644
#, fuzzy
1565215645
msgid "editor.sidebar.sideMenu.showLabel"
1565315646
msgstr "Mostrar menú"

‎packages/editor/src/i18n/locales/fr/messages.po‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14656,6 +14656,7 @@ msgstr "Atelier"
1465614656
# Source-Hash: 4323751093d4c560
1465714657
# Review: required
1465814658
# AI-Provider: claude-code
14659+
# English: "Still loading the project. Editing is paused until it finishes."
1465914660
#: packages/editor/src/components/editor/index.tsx
1466014661
#, fuzzy
1466114662
msgid "editor.sceneData.pending"
@@ -15601,25 +15602,25 @@ msgstr "Mettre à jour l’instantané"
1560115602
msgid "editor.sidebar.panels.zonePanel.viewSnapshot"
1560215603
msgstr "Voir l’instantané"
1560315604

15604-
# English: "Browse plugins"
1560515605
# Source-Hash: 7890c110650ad1e5
1560615606
# Review: required
15607+
# English: "Browse plugins"
1560715608
#: packages/editor/src/components/ui/sidebar/plugins-menu-panel.tsx
1560815609
#, fuzzy
1560915610
msgid "editor.sidebar.pluginsMenu.browse"
1561015611
msgstr "Parcourir les plugins"
1561115612

15612-
# English: "No plugins in this project yet."
1561315613
# Source-Hash: fd7380e83e3c88b3
1561415614
# Review: required
15615+
# English: "No plugins in this project yet."
1561515616
#: packages/editor/src/components/ui/sidebar/plugins-menu-panel.tsx
1561615617
#, fuzzy
1561715618
msgid "editor.sidebar.pluginsMenu.empty"
1561815619
msgstr "Aucun plugin dans ce projet pour l’instant."
1561915620

15620-
# English: "Hide menu"
1562115621
# Source-Hash: 8284b6d9e4c05fb1
1562215622
# Review: required
15623+
# English: "Hide menu"
1562315624
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
1562415625
#, fuzzy
1562515626
msgid "editor.sidebar.sideMenu.hide"
@@ -15636,18 +15637,10 @@ msgstr "Masquer le menu"
1563615637
msgid "editor.sidebar.sideMenu.plugins"
1563715638
msgstr "Plugins"
1563815639

15639-
# English: "Menu"
15640-
# Source-Hash: 1340afc2c56c0229
15641-
# Review: required
15642-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
15643-
#, fuzzy
15644-
msgid "editor.sidebar.sideMenu.show"
15645-
msgstr "Menu"
15646-
15647-
# English: "Show menu"
1564815640
# Source-Hash: 5e1ae5cd25820c60
1564915641
# Review: required
15650-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
15642+
# English: "Show menu"
15643+
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
1565115644
#, fuzzy
1565215645
msgid "editor.sidebar.sideMenu.showLabel"
1565315646
msgstr "Afficher le menu"

‎packages/editor/src/i18n/locales/ja/messages.po‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14656,6 +14656,7 @@ msgstr "作業場"
1465614656
# Source-Hash: 4323751093d4c560
1465714657
# Review: required
1465814658
# AI-Provider: claude-code
14659+
# English: "Still loading the project. Editing is paused until it finishes."
1465914660
#: packages/editor/src/components/editor/index.tsx
1466014661
#, fuzzy
1466114662
msgid "editor.sceneData.pending"
@@ -15601,25 +15602,25 @@ msgstr "スナップショットを更新"
1560115602
msgid "editor.sidebar.panels.zonePanel.viewSnapshot"
1560215603
msgstr "スナップショットを表示"
1560315604

15604-
# English: "Browse plugins"
1560515605
# Source-Hash: 7890c110650ad1e5
1560615606
# Review: required
15607+
# English: "Browse plugins"
1560715608
#: packages/editor/src/components/ui/sidebar/plugins-menu-panel.tsx
1560815609
#, fuzzy
1560915610
msgid "editor.sidebar.pluginsMenu.browse"
1561015611
msgstr "プラグインを見る"
1561115612

15612-
# English: "No plugins in this project yet."
1561315613
# Source-Hash: fd7380e83e3c88b3
1561415614
# Review: required
15615+
# English: "No plugins in this project yet."
1561515616
#: packages/editor/src/components/ui/sidebar/plugins-menu-panel.tsx
1561615617
#, fuzzy
1561715618
msgid "editor.sidebar.pluginsMenu.empty"
1561815619
msgstr "このプロジェクトにはまだプラグインがありません。"
1561915620

15620-
# English: "Hide menu"
1562115621
# Source-Hash: 8284b6d9e4c05fb1
1562215622
# Review: required
15623+
# English: "Hide menu"
1562315624
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
1562415625
#, fuzzy
1562515626
msgid "editor.sidebar.sideMenu.hide"
@@ -15636,18 +15637,10 @@ msgstr "メニューを隠す"
1563615637
msgid "editor.sidebar.sideMenu.plugins"
1563715638
msgstr "プラグイン"
1563815639

15639-
# English: "Menu"
15640-
# Source-Hash: 1340afc2c56c0229
15641-
# Review: required
15642-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
15643-
#, fuzzy
15644-
msgid "editor.sidebar.sideMenu.show"
15645-
msgstr "メニュー"
15646-
15647-
# English: "Show menu"
1564815640
# Source-Hash: 5e1ae5cd25820c60
1564915641
# Review: required
15650-
#: packages/editor/src/components/editor/editor-layout-v2.tsx
15642+
# English: "Show menu"
15643+
#: packages/editor/src/components/ui/sidebar/tab-bar.tsx
1565115644
#, fuzzy
1565215645
msgid "editor.sidebar.sideMenu.showLabel"
1565315646
msgstr "メニューを表示"

0 commit comments

Comments
 (0)