import type { KeyboardEvent } from 'react' import { useTranslation } from '../../i18n' const STEP = 16 interface PanelResizeHandleProps { /** The panel this handle sits on: 'left' grows to the right, 'right' to the left. */ side: 'left' | 'right' width: number min: number max: number onStart: () => void onNudge: (delta: number) => void } /** * The grip on a planner panel's inner edge (#1012). A mouse drags it, a finger on * a tablet drags it (touch-action: none keeps the page and the map from taking * the gesture), and the arrow keys move it, since it is a separator a keyboard * can reach. On a touch screen the grip shows; with a mouse it lights on hover. */ export default function PanelResizeHandle({ side, width, min, max, onStart, onNudge }: PanelResizeHandleProps) { const { t } = useTranslation() const onKeyDown = (e: KeyboardEvent) => { const grow = side === 'left' ? 'ArrowRight' : 'ArrowLeft' const shrink = side === 'left' ? 'ArrowLeft' : 'ArrowRight' if (e.key !== grow && e.key !== shrink) return e.preventDefault() onNudge(e.key === grow ? STEP : -STEP) } return (
) }