/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format */ import {Button, Dropdown, Menu, Slider, Tooltip, Typography} from 'antd'; import {Layout, produce, theme, usePlugin} from 'flipper-plugin'; import {ClientNode, Id} from '../../ClientTypes'; import {plugin} from '../../index'; import React from 'react'; import { AimOutlined, FullscreenExitOutlined, FullscreenOutlined, PicCenterOutlined, } from '@ant-design/icons'; import {tracker} from '../../utils/tracker'; import {debounce} from 'lodash'; import {WireFrameMode} from '../../DesktopTypes'; import {SelectableDropDownItem} from '../shared/SelectableDropDownItem'; export type TargetModeState = | { state: 'selected'; targetedNodes: Id[]; sliderPosition: number; } | { state: 'active'; } | { state: 'disabled'; }; export function VisualiserControls({ targetMode, setTargetMode, selectedNode, focusedNode, wireFrameMode, onSetWireFrameMode, }: { wireFrameMode: WireFrameMode; onSetWireFrameMode: (mode: WireFrameMode) => void; selectedNode?: ClientNode; focusedNode?: Id; setTargetMode: (targetMode: TargetModeState) => void; targetMode: TargetModeState; }) { const instance = usePlugin(plugin); const focusDisabled = focusedNode == null && (selectedNode == null || selectedNode.children.length === 0); const focusToolTip = focusDisabled ? 'Select a non leaf node to focus it' : focusedNode == null ? 'Focus current node' : 'Remove focus'; const targetToolTip = targetMode.state === 'disabled' ? 'Target Mode' : 'Exit target mode'; return ( {targetMode.state === 'active' && ( Target mode: Select element )} {targetMode.state === 'disabled' && ( Interactive Visualizer )} {targetMode.state === 'selected' && ( { setTargetMode( produce(targetMode, (draft) => { draft.sliderPosition = value; }), ); instance.uiActions.onSelectNode( targetMode.targetedNodes[value], 'visualiser', ); debouncedReportTargetAdjusted(); }} /> )} }>