Improve selection / hovered state of visualiser

Summary:
Previously we used an overlay to indicated selected but this was kind of hard to see due to <1 opacity. I think this approach where we enchance the border is clearer.

Also we used border colour earlier to indicate type of node which i think was never obvious to the user. Given that nodes heavily overlap we should remove this design language

changelog: UIDebugger, improve selected and hover state of the visualiser

Reviewed By: antonk52

Differential Revision: D45737758

fbshipit-source-id: 5299043656787d6479cff6ec2b38cebe8417fd53
This commit is contained in:
Luke De Feo
2023-05-11 08:15:19 -07:00
committed by Facebook GitHub Bot
parent 33ae7f23db
commit cd67ce59f7

View File

@@ -227,12 +227,8 @@ function Visualization2DNode({
top: toPx(node.bounds.y), top: toPx(node.bounds.y),
width: toPx(node.bounds.width), width: toPx(node.bounds.width),
height: toPx(node.bounds.height), height: toPx(node.bounds.height),
opacity: isSelected || isHighlighted ? 0.3 : 1, opacity: isHighlighted ? 0.3 : 1,
backgroundColor: isHighlighted backgroundColor: isHighlighted ? 'red' : 'transparent',
? 'red'
: isSelected
? theme.selectionBackgroundColor
: 'transparent',
}} }}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
@@ -244,7 +240,10 @@ function Visualization2DNode({
onSelectNode(hoveredNodes[0]); onSelectNode(hoveredNodes[0]);
} }
}}> }}>
<NodeBorder hovered={isHovered} tags={node.tags}></NodeBorder> <NodeBorder
hovered={isHovered}
selected={isSelected}
tags={node.tags}></NodeBorder>
{children} {children}
</div> </div>
</Tooltip> </Tooltip>
@@ -336,21 +335,25 @@ const ContextMenu: React.FC<{nodes: Map<Id, UINode>}> = ({children}) => {
* node itself so that it has the same size but the border doesnt affect the sizing of its children * node itself so that it has the same size but the border doesnt affect the sizing of its children
* as border is part of the box model * as border is part of the box model
*/ */
const NodeBorder = styled.div<{tags: Tag[]; hovered: boolean}>((props) => ({ const NodeBorder = styled.div<{
tags: Tag[];
hovered: boolean;
selected: boolean;
}>((props) => ({
position: 'absolute', position: 'absolute',
top: 0, top: 0,
left: 0, left: 0,
bottom: 0, bottom: 0,
right: 0, right: 0,
boxSizing: 'border-box', boxSizing: 'border-box',
borderWidth: props.hovered ? '2px' : '1px', borderWidth: props.selected || props.hovered ? '2px' : '1px',
borderStyle: 'solid', borderStyle: 'solid',
color: 'transparent', color: 'transparent',
borderColor: props.tags.includes('Declarative') borderColor: props.selected
? 'green' ? theme.primaryColor
: props.tags.includes('Native') : props.hovered
? 'blue' ? theme.selectionBackgroundColor
: 'black', : theme.disabledColor,
})); }));
const longHoverDelay = 200; const longHoverDelay = 200;