import { ToolTip } from './useStore' import { Fragment, WheelEvent, useRef, useMemo } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faSearch, faX } from '@fortawesome/free-solid-svg-icons' import { Popover, Transition } from '@headlessui/react' import styles from './Toolbar.module.css' import { isCursorInSketchCommandRange } from 'lang/util' import { ActionIcon } from 'components/ActionIcon' import { engineCommandManager } from './lang/std/engineConnection' import { useModelingContext } from 'hooks/useModelingContext' export const sketchButtonClassnames = { background: 'bg-chalkboard-100 group-hover:bg-chalkboard-90 hover:bg-chalkboard-90 dark:bg-fern-20 dark:group-hover:bg-fern-10 dark:hover:bg-fern-10 group-disabled:bg-chalkboard-50 dark:group-disabled:bg-chalkboard-60 group-hover:group-disabled:bg-chalkboard-50 dark:group-hover:group-disabled:bg-chalkboard-50', icon: 'text-fern-20 h-auto group-hover:text-fern-10 hover:text-fern-10 dark:text-chalkboard-100 dark:group-hover:text-chalkboard-100 dark:hover:text-chalkboard-100 group-disabled:bg-chalkboard-60 hover:group-disabled:text-inherit', } const sketchFnLabels: Record = { sketch_line: 'Line', line: 'Line', move: 'Move', angledLine: 'Angled Line', angledLineThatIntersects: 'Angled Line That Intersects', angledLineOfXLength: 'Angled Line Of X Length', angledLineOfYLength: 'Angled Line Of Y Length', angledLineToX: 'Angled Line To X', angledLineToY: 'Angled Line To Y', lineTo: 'Line to Point', xLine: 'Horizontal Line', yLine: 'Vertical Line', xLineTo: 'Horizontal Line to Point', yLineTo: 'Vertical Line to Point', } export const Toolbar = () => { const { state, send, context } = useModelingContext() const toolbarButtonsRef = useRef(null) const pathId = useMemo( () => isCursorInSketchCommandRange( engineCommandManager.artifactMap, context.selectionRanges ), [engineCommandManager.artifactMap, context.selectionRanges] ) function handleToolbarButtonsWheelEvent(ev: WheelEvent) { const span = toolbarButtonsRef.current if (!span) { return } span.scrollLeft = span.scrollLeft += ev.deltaY } function ToolbarButtons({ className }: React.HTMLAttributes) { return ( {state.nextEvents.includes('Enter sketch') && ( )} {state.nextEvents.includes('Enter sketch') && pathId && ( )} {state.nextEvents.includes('Cancel') && !state.matches('idle') && ( )} {state.matches('Sketch') && !state.matches('idle') && ( )} {state.matches('Sketch') && ( )} {state.matches('Sketch.SketchIdle') && state.nextEvents .filter( (eventName) => eventName.includes('Make segment') || eventName.includes('Constrain') ) .map((eventName) => ( ))} {state.matches('idle') && ( )} ) } return (
{state.matches('Sketch') ? '2D' : '3D'}

You're in {state.matches('Sketch') ? '2D' : '3D'}

) }