2D wire frame highlight from tree, select from wireframe

Summary:
Introduced some basic bidirectional link between tree and wireframe, the specific interaction will need some tweaking but this should get us started.

When hovering over the tree we halt the rendering of the wireframe up to that point, this allows us to explore parent views that layout child views.

When clicking a view in the wireframe it is 'seleceted' as if it was clicked in the tree. This set the tree selection so you can identify it in the tree as well as opens the side bar

Reviewed By: lblasa

Differential Revision: D39539277

fbshipit-source-id: 3beb1ad4cb56b398c640ac3e7fac2cc97f3f1a18
This commit is contained in:
Luke De Feo
2022-09-21 07:02:48 -07:00
committed by Facebook GitHub Bot
parent cf176bb071
commit f3b7552338
3 changed files with 80 additions and 31 deletions

View File

@@ -9,23 +9,40 @@
import {Id, UINode} from '../types';
import {DataNode} from 'antd/es/tree';
import {Tree as AntTree, Typography} from 'antd';
import {Tree as AntTree} from 'antd';
import {DownOutlined} from '@ant-design/icons';
import React from 'react';
export function Tree(props: {
rootId: Id;
nodes: Map<Id, UINode>;
setSelectedNode: (id: Id) => void;
selectedNode?: Id;
onSelectNode: (id: Id) => void;
onHoveredNode: (id?: Id) => void;
}) {
const [antTree, inactive] = nodesToAntTree(props.rootId, props.nodes);
return (
<AntTree
onMouseLeave={() => {
//when mouse exits the entire tree then unhover
props.onHoveredNode(undefined);
}}
showIcon
showLine
titleRender={(node) => {
return (
<div
onMouseEnter={() => {
props.onHoveredNode(node.key as Id);
}}>
{node.title}
</div>
);
}}
selectedKeys={[props.selectedNode ?? '']}
onSelect={(selected) => {
props.setSelectedNode(selected[0] as Id);
props.onSelectNode(selected[0] as Id);
}}
defaultExpandAll
expandedKeys={[...props.nodes.keys()].filter(