import React from "react"; import { Flex, Input, Text } from "theme-ui"; import ToolSection from "./ToolSection"; import MeasureChebyshevIcon from "../../../icons/MeasureChebyshevIcon"; import MeasureEuclideanIcon from "../../../icons/MeasureEuclideanIcon"; import MeasureManhattanIcon from "../../../icons/MeasureManhattanIcon"; import MeasureAlternatingIcon from "../../../icons/MeasureAlternatingIcon"; import Divider from "../../Divider"; import { useKeyboard } from "../../../contexts/KeyboardContext"; function MeasureToolSettings({ settings, onSettingChange }) { // Keyboard shortcuts function handleKeyDown({ key }) { if (key === "g") { onSettingChange({ type: "chebyshev" }); } else if (key === "l") { onSettingChange({ type: "euclidean" }); } else if (key === "c") { onSettingChange({ type: "manhattan" }); } else if (key === "a") { onSettingChange({ type: "alternating" }); } } useKeyboard(handleKeyDown); const tools = [ { id: "chebyshev", title: "Grid Distance (G)", isSelected: settings.type === "chebyshev", icon: , }, { id: "alternating", title: "Alternating Diagonal Distance (A)", isSelected: settings.type === "alternating", icon: , }, { id: "euclidean", title: "Line Distance (L)", isSelected: settings.type === "euclidean", icon: , }, { id: "manhattan", title: "City Block Distance (C)", isSelected: settings.type === "manhattan", icon: , }, ]; return ( onSettingChange({ type: tool.id })} /> Scale: onSettingChange({ scale: e.target.value })} autoComplete="off" /> ); } export default MeasureToolSettings;