/** * 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, Slider, Tooltip, Typography} from 'antd'; import {Layout, produce, theme, usePlugin} from 'flipper-plugin'; import {Id} from '../../ClientTypes'; import {plugin} from '../../index'; import React from 'react'; import { AimOutlined, FullscreenExitOutlined, FullscreenOutlined, } from '@ant-design/icons'; import {tracker} from '../../utils/tracker'; import {debounce} from 'lodash'; export type TargetModeState = | { state: 'selected'; targetedNodes: Id[]; sliderPosition: number; } | { state: 'active'; } | { state: 'disabled'; }; export function VisualiserControls({ targetMode, setTargetMode, selectedNode, focusedNode, }: { selectedNode?: Id; focusedNode?: Id; setTargetMode: (targetMode: TargetModeState) => void; targetMode: TargetModeState; }) { const instance = usePlugin(plugin); const focusDisabled = focusedNode == null && selectedNode == null; const focusToolTip = focusDisabled ? 'Select a node to focus it' : focusedNode == null ? 'Focus current node' : 'Remove focus'; const targetToolTip = targetMode.state === 'disabled' ? 'TargetMode' : '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(); }} /> )}