increase highlight time and random colours for event monitoring

Summary:
1. makes it easier to tellwhen a parent and child hightlight together
2. Longer times means you have more time to click it and see

changelog: UIDebugger event debugger - increased highlight time. Nodes get random highlight color

Reviewed By: lblasa

Differential Revision: D49501954

fbshipit-source-id: 9456c00e0df77c40934eb95b4b48b566c7715181
This commit is contained in:
Luke De Feo
2023-09-21 08:50:36 -07:00
committed by Facebook GitHub Bot
parent 796fb161dc
commit 2ff91170e0
4 changed files with 27 additions and 20 deletions

View File

@@ -26,6 +26,8 @@ export type LiveClientState = {
nodes: Map<Id, ClientNode>; nodes: Map<Id, ClientNode>;
}; };
export type Color = string;
export type UIState = { export type UIState = {
viewMode: Atom<ViewMode>; viewMode: Atom<ViewMode>;
wireFrameMode: Atom<WireFrameMode>; wireFrameMode: Atom<WireFrameMode>;
@@ -36,7 +38,7 @@ export type UIState = {
isContextMenuOpen: Atom<boolean>; isContextMenuOpen: Atom<boolean>;
hoveredNodes: Atom<Id[]>; hoveredNodes: Atom<Id[]>;
selectedNode: Atom<NodeSelection | undefined>; selectedNode: Atom<NodeSelection | undefined>;
highlightedNodes: Atom<Set<Id>>; highlightedNodes: Atom<Map<Id, Color>>;
focusedNode: Atom<Id | undefined>; focusedNode: Atom<Id | undefined>;
expandedNodes: Atom<Set<Id>>; expandedNodes: Atom<Set<Id>>;
visualiserWidth: Atom<number>; visualiserWidth: Atom<number>;

View File

@@ -8,7 +8,7 @@
*/ */
import {Id, ClientNode} from '../../ClientTypes'; import {Id, ClientNode} from '../../ClientTypes';
import {OnSelectNode} from '../../DesktopTypes'; import {Color, OnSelectNode} from '../../DesktopTypes';
import React, { import React, {
CSSProperties, CSSProperties,
Ref, Ref,
@@ -373,7 +373,7 @@ function TreeNodeRow({
transform: string; transform: string;
innerRef: Ref<any>; innerRef: Ref<any>;
treeNode: TreeNode; treeNode: TreeNode;
highlightedNodes: Set<Id>; highlightedNodes: Map<Id, Color>;
selectedNode?: Id; selectedNode?: Id;
hoveredNode?: Id; hoveredNode?: Id;
isUsingKBToScroll: RefObject<MillisSinceEpoch>; isUsingKBToScroll: RefObject<MillisSinceEpoch>;
@@ -410,7 +410,7 @@ function TreeNodeRow({
/> />
<TreeNodeContent <TreeNodeContent
isHighlighted={highlightedNodes.has(treeNode.id)} highlightColor={highlightedNodes.get(treeNode.id)}
isSelected={isSelected} isSelected={isSelected}
isHovered={hoveredNode === treeNode.id} isHovered={hoveredNode === treeNode.id}
onMouseEnter={() => { onMouseEnter={() => {
@@ -501,8 +501,8 @@ const TreeNodeContent = styled.li<{
item: TreeNode; item: TreeNode;
isHovered: boolean; isHovered: boolean;
isSelected: boolean; isSelected: boolean;
isHighlighted: boolean; highlightColor?: string;
}>(({item, isHovered, isSelected, isHighlighted}) => ({ }>(({item, isHovered, isSelected, highlightColor}) => ({
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
height: TreeItemHeight, height: TreeItemHeight,
@@ -513,13 +513,15 @@ const TreeNodeContent = styled.li<{
borderStyle: 'solid', borderStyle: 'solid',
overflow: 'hidden', overflow: 'hidden',
whiteSpace: 'nowrap', whiteSpace: 'nowrap',
backgroundColor: isHighlighted opacity: highlightColor != null ? 0.6 : 1,
? 'rgba(255,0,0,.3)' backgroundColor:
: isSelected highlightColor != null
? theme.selectionBackgroundColor ? highlightColor
: isHovered : isSelected
? theme.backgroundWash ? theme.selectionBackgroundColor
: theme.backgroundDefault, : isHovered
? theme.backgroundWash
: theme.backgroundDefault,
})); }));
function ExpandedIconOrSpace(props: { function ExpandedIconOrSpace(props: {

View File

@@ -324,7 +324,7 @@ function Visualization2DNode({
/> />
)); ));
const isHighlighted = useValue(instance.uiState.highlightedNodes).has( const highLightColor = useValue(instance.uiState.highlightedNodes).get(
node.id, node.id,
); );
@@ -346,8 +346,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: isHighlighted ? 0.3 : 1, opacity: highLightColor != null ? 0.7 : 1,
backgroundColor: isHighlighted ? 'red' : 'transparent', backgroundColor: highLightColor,
}}> }}>
{showBorder && <NodeBorder />} {showBorder && <NodeBorder />}

View File

@@ -30,6 +30,7 @@ import {
WireFrameMode, WireFrameMode,
AugmentedFrameworkEvent, AugmentedFrameworkEvent,
StreamInterceptorEventEmitter, StreamInterceptorEventEmitter,
Color,
} from './DesktopTypes'; } from './DesktopTypes';
import EventEmitter from 'eventemitter3'; import EventEmitter from 'eventemitter3';
import {addInterceptors} from './fb-stubs/StreamInterceptor'; import {addInterceptors} from './fb-stubs/StreamInterceptor';
@@ -235,7 +236,10 @@ export function plugin(client: PluginClient<Events, Methods>) {
uiState.highlightedNodes.update((draft) => { uiState.highlightedNodes.update((draft) => {
for (const node of nodesToHighlight) { for (const node of nodesToHighlight) {
draft.add(node); draft.set(
node,
`#${Math.floor(Math.random() * 16777215).toString(16)}`,
);
} }
}); });
@@ -300,8 +304,7 @@ export function plugin(client: PluginClient<Events, Methods>) {
}; };
} }
const HighlightTime = 300; const HighlightTime = 1500;
export {Component} from './components/main'; export {Component} from './components/main';
export * from './ClientTypes'; export * from './ClientTypes';
@@ -317,7 +320,7 @@ function createUIState(): UIState {
streamState: createState<StreamState>({state: 'Ok'}), streamState: createState<StreamState>({state: 'Ok'}),
visualiserWidth: createState(Math.min(window.innerWidth / 4.5, 500)), visualiserWidth: createState(Math.min(window.innerWidth / 4.5, 500)),
highlightedNodes: createState(new Set<Id>()), highlightedNodes: createState(new Map<Id, Color>()),
selectedNode: createState<NodeSelection | undefined>(undefined), selectedNode: createState<NodeSelection | undefined>(undefined),
//used to indicate whether we will higher the visualizer / tree when a matching event comes in //used to indicate whether we will higher the visualizer / tree when a matching event comes in