2026-07-13 07:30:12 -07:00
|
|
|
import React from 'react';
|
2026-07-13 06:54:15 -07:00
|
|
|
import { BottomSheet } from './BottomSheet';
|
|
|
|
|
import { BlocksPanel } from '../left/BlocksPanel';
|
|
|
|
|
import { PagesPanel } from '../left/PagesPanel';
|
|
|
|
|
import { LayersPanel } from '../left/LayersPanel';
|
|
|
|
|
import { AssetsPanel } from '../left/AssetsPanel';
|
|
|
|
|
import { GuidedStyles } from '../right/GuidedStyles';
|
2026-07-13 07:30:12 -07:00
|
|
|
import { useMobileChrome, MobileSheetTab } from '../../state/MobileChromeContext';
|
2026-07-13 06:54:15 -07:00
|
|
|
|
2026-07-13 07:30:12 -07:00
|
|
|
const TABS: { id: MobileSheetTab; label: string; icon: string }[] = [
|
2026-07-13 06:54:15 -07:00
|
|
|
{ id: 'blocks', label: 'Blocks', icon: 'fa-cube' },
|
|
|
|
|
{ id: 'pages', label: 'Pages', icon: 'fa-file-o' },
|
|
|
|
|
{ id: 'layers', label: 'Layers', icon: 'fa-sitemap' },
|
|
|
|
|
{ id: 'assets', label: 'Assets', icon: 'fa-image' },
|
|
|
|
|
{ id: 'styles', label: 'Styles', icon: 'fa-paint-brush' },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mobile replacement for the desktop LeftPanel/RightPanel column layout
|
|
|
|
|
* (Phase A). A fixed bottom tab bar (Blocks/Pages/Layers/Assets/Styles)
|
|
|
|
|
* toggles a single `BottomSheet` at a time, hosting the SAME panel
|
|
|
|
|
* component the desktop side panels use -- unchanged, so behavior/state
|
|
|
|
|
* stays identical, only the chrome around it differs. Tapping the active
|
|
|
|
|
* tab again, tapping the backdrop, the sheet's close button, or Escape all
|
|
|
|
|
* close the open sheet.
|
|
|
|
|
*
|
|
|
|
|
* "Styles" hosts `GuidedStyles`, which already falls back to the
|
|
|
|
|
* site-design panel when nothing is selected and switches to the
|
|
|
|
|
* per-type style panel once something is -- this is the natural place to
|
|
|
|
|
* edit a tapped element's styling (Phase B deepens the tap-to-select flow;
|
|
|
|
|
* this component only wires up the sheet, per the Phase A brief).
|
2026-07-13 07:30:12 -07:00
|
|
|
*
|
|
|
|
|
* Sheet-open state itself lives in `MobileChromeContext` (Mobile-A2), not
|
|
|
|
|
* a private `useState`, so Phase B can open/close a sheet from elsewhere
|
|
|
|
|
* (e.g. a canvas selection toolbar). The toggle-to-close-on-repeat-tap
|
|
|
|
|
* behavior is local to this click handler -- `openSheet` always opens.
|
2026-07-13 06:54:15 -07:00
|
|
|
*/
|
|
|
|
|
export const MobilePanelBar: React.FC = () => {
|
2026-07-13 07:30:12 -07:00
|
|
|
const { activeSheet, openSheet, closeSheet } = useMobileChrome();
|
2026-07-13 06:54:15 -07:00
|
|
|
|
2026-07-13 07:30:12 -07:00
|
|
|
const handleTabClick = (tab: MobileSheetTab) => {
|
|
|
|
|
if (activeSheet === tab) closeSheet();
|
|
|
|
|
else openSheet(tab);
|
2026-07-13 06:54:15 -07:00
|
|
|
};
|
|
|
|
|
|
2026-07-13 07:30:12 -07:00
|
|
|
const activeLabel = TABS.find((t) => t.id === activeSheet)?.label ?? '';
|
2026-07-13 06:54:15 -07:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
2026-07-13 07:30:12 -07:00
|
|
|
<BottomSheet open={activeSheet !== null} onClose={closeSheet} title={activeLabel}>
|
|
|
|
|
{activeSheet === 'blocks' && <BlocksPanel />}
|
|
|
|
|
{activeSheet === 'pages' && <PagesPanel />}
|
|
|
|
|
{activeSheet === 'layers' && <LayersPanel />}
|
|
|
|
|
{activeSheet === 'assets' && <AssetsPanel />}
|
|
|
|
|
{activeSheet === 'styles' && <GuidedStyles />}
|
2026-07-13 06:54:15 -07:00
|
|
|
</BottomSheet>
|
|
|
|
|
|
|
|
|
|
<nav className="mobile-tab-bar" aria-label="Editor panels">
|
|
|
|
|
{TABS.map((tab) => (
|
|
|
|
|
<button
|
|
|
|
|
key={tab.id}
|
|
|
|
|
type="button"
|
2026-07-13 07:30:12 -07:00
|
|
|
className={`mobile-tab-btn${activeSheet === tab.id ? ' active' : ''}`}
|
2026-07-13 06:54:15 -07:00
|
|
|
onClick={() => handleTabClick(tab.id)}
|
2026-07-13 07:30:12 -07:00
|
|
|
aria-pressed={activeSheet === tab.id}
|
2026-07-13 06:54:15 -07:00
|
|
|
>
|
|
|
|
|
<i className={`fa ${tab.icon}`} aria-hidden="true" />
|
|
|
|
|
<span>{tab.label}</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</nav>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|