import { useMemo } from "react"; import { useTranslation } from "react-i18next"; import { Columns2, LayoutPanelLeft, Rows2 } from "lucide-react"; import { Button } from "@/components/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, } from "@/components/dropdown-menu"; import type { LayoutNode } from "@/types/ui-types"; import { buildPreset, SPLIT_PRESETS, type SplitPresetId, } from "./split-presets"; import { MAX_PANES, type PaneEdge } from "./split-tree"; function NodeThumb({ node }: { node: LayoutNode }) { if (node.kind === "pane") { return
; } return (
{node.children.map((child, index) => (
))}
); } /** A small drawing of a preset's panes. */ export function PresetThumb({ id }: { id: SplitPresetId }) { const node = useMemo(() => buildPreset(id), [id]); return ; } /** * The tab bar's split button: split the active tab right or down, or lay it * out as one of the presets. */ export function SplitLayoutMenu({ activeIsSplit, canAddPane, onSplit, onPreset, }: { activeIsSplit: boolean; canAddPane: boolean; onSplit: (edge: Extract) => void; onPreset: (id: SplitPresetId) => void; }) { const { t } = useTranslation(); const fullTitle = canAddPane ? undefined : t("splitScreen.maxPanes", { count: MAX_PANES }); return ( onSplit("right")} > {t("splitScreen.splitRight")} Ctrl+Shift+\ onSplit("bottom")} > {t("splitScreen.splitDown")} Ctrl+Shift+- {activeIsSplit ? t("splitScreen.applyLayout") : t("splitScreen.layouts")}
{SPLIT_PRESETS.map((preset) => ( onPreset(preset.id)} >
))}
{t("splitScreen.shortcuts")}
{t("splitScreen.shortcutNavigate")} Alt+Arrows
{t("splitScreen.zoom")} Ctrl+Shift+Enter
); }