import { ANIMATION_MEDIUM_MS, useApp } from '@tldraw/editor' import * as React from 'react' import { track } from 'signia-react' import { useActions } from '../../hooks/useActions' import { useBreakpoint } from '../../hooks/useBreakpoint' import { useTranslation } from '../../hooks/useTranslation/useTranslation' import { Button } from '../primitives/Button' import * as M from '../primitives/DropdownMenu' export const ZoomMenu = track(function ZoomMenu() { const app = useApp() const msg = useTranslation() const breakpoint = useBreakpoint() const zoom = app.zoomLevel const hasShapes = app.shapeIds.size > 0 const hasSelected = app.selectedIds.length > 0 const isZoomedTo100 = app.zoomLevel === 1 const handleDoubleClick = React.useCallback(() => { app.resetZoom(app.viewportScreenCenter, { duration: ANIMATION_MEDIUM_MS }) }, [app]) return ( ) }) function ZoomMenuItem(props: { action: string disabled?: boolean noClose?: boolean 'data-wd'?: string }) { const { action, disabled = false, noClose = false } = props const actions = useActions() return ( actions[action].onSelect('zoom-menu')} noClose={noClose} disabled={disabled} /> ) }