import React, { useEffect, useState } from "react"; import { Group, Panel, Separator, useDefaultLayout } from "react-resizable-panels"; import { ScrollContainer } from "./ScrollContainer"; import { useTranslation } from "react-i18next"; import { IconContext } from "react-icons"; const DEFAULT_LIST_WIDTH = 200; const DEFAULT_DRAWER_WIDTH = 370; const DEFAULT_SIDEBAR_WIDTH = DEFAULT_LIST_WIDTH + DEFAULT_DRAWER_WIDTH; const PANEL_STYLE: React.CSSProperties = { overflow: "hidden" }; const SIDEBAR_LAYOUT_ID = "maputnik:sidebar-layout"; const SIDEBAR_INNER_LAYOUT_ID = "maputnik:sidebar-inner-layout"; const SIDEBAR_PANEL_ID = "sidebar"; const MAP_PANEL_ID = "map"; const LIST_PANEL_ID = "list"; const DRAWER_PANEL_ID = "drawer"; type AppLayoutProps = { toolbar: React.ReactElement layerList: React.ReactElement layerEditor?: React.ReactElement codeEditor?: React.ReactElement map: React.ReactElement bottom?: React.ReactElement modals?: React.ReactNode }; export const AppLayout: React.FC = (props) => { const { t, i18n } = useTranslation(); const sidebarLayout = useDefaultLayout({ id: SIDEBAR_LAYOUT_ID, panelIds: [SIDEBAR_PANEL_ID, MAP_PANEL_ID], }); const innerLayout = useDefaultLayout({ id: SIDEBAR_INNER_LAYOUT_ID, panelIds: [LIST_PANEL_ID, DRAWER_PANEL_ID], }); // The bottom panel is position: fixed, so it can't be a flex sibling of the // map panel; it follows the sidebar through this custom property instead. const [sidebarWidth, setSidebarWidth] = useState(DEFAULT_SIDEBAR_WIDTH); useEffect(() => { document.body.dir = i18n.dir(); }, [i18n, i18n.language]); return
{props.toolbar}
setSidebarWidth(inPixels)} > {props.codeEditor && {props.codeEditor} } {!props.codeEditor && {props.layerList} {props.layerEditor} } {props.map}
{props.bottom &&
{props.bottom}
} {props.modals}
; };