From c89200c05ce446a20c5551ce8686d01b454d5e28 Mon Sep 17 00:00:00 2001 From: Hristo Kanchev Date: Fri, 3 Apr 2020 12:12:48 +0200 Subject: [PATCH 1/5] [DevTools] - Highlight rendered by elements on hover. --- .../views/Components/SelectedElement.css | 21 +++++++++++++++---- .../views/Components/SelectedElement.js | 12 ++++++----- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css index d1bb28f19706e..efac27eaaaf2a 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.css @@ -82,7 +82,6 @@ .Owner { border-radius: 0.25rem; padding: 0.125rem 0.25rem; - cursor: pointer; background: none; border: none; display: block; @@ -107,12 +106,26 @@ } .OwnerButton { + cursor: pointer; + width: 100%; + padding: 0; +} + +.OwnerContent { display: flex; align-items: center; - margin-left: 0.5rem; - padding: 0; + padding-top: 0; + padding-right: 0; + padding-bottom: 0; + padding-left: 1rem; + width: 100%; + border-radius: 0.25rem; +} + +.OwnerContent:hover { + background-color: var(--color-background-hover); } .ContextMenuIcon { margin-right: 0.5rem; -} \ No newline at end of file +} diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js index f65b8e0a777e5..620d804bddbdb 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js @@ -538,12 +538,14 @@ function OwnerView({ className={styles.OwnerButton} disabled={!isInStore} onClick={handleClick}> - - {displayName} + + + {displayName} + + - ); } From cb82782841b4b6aebf79e6ce511082ba8a32034a Mon Sep 17 00:00:00 2001 From: Hristo Kanchev Date: Fri, 3 Apr 2020 12:23:05 +0200 Subject: [PATCH 2/5] Fixed formatting issue. --- .../devtools/views/Components/SelectedElement.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js index 620d804bddbdb..25cf06ba8a372 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js @@ -538,13 +538,13 @@ function OwnerView({ className={styles.OwnerButton} disabled={!isInStore} onClick={handleClick}> - - - {displayName} - - + + + {displayName} + + ); From c3f880c81e35734a8be948f67f4f2e088182c7cc Mon Sep 17 00:00:00 2001 From: Hristo Kanchev Date: Fri, 3 Apr 2020 17:26:10 +0200 Subject: [PATCH 3/5] DevTools - Extracted highlight logic to custom hook. Added highlight support for rendered by elements. --- .../views/Components/SelectedElement.js | 13 ++++++- .../src/devtools/views/Components/Tree.js | 29 ++++------------ .../src/devtools/views/hooks.js | 34 +++++++++++++++++++ 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js index 25cf06ba8a372..987c9edbb1c9d 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/SelectedElement.js @@ -26,6 +26,7 @@ import ViewElementSourceContext from './ViewElementSourceContext'; import NativeStyleEditor from './NativeStyleEditor'; import Toggle from '../Toggle'; import Badge from './Badge'; +import {useHighlightNativeElement} from '../hooks'; import { ComponentFilterElementType, ElementTypeClass, @@ -522,6 +523,10 @@ function OwnerView({ type, }: OwnerViewProps) { const dispatch = useContext(TreeDispatcherContext); + const { + highlightNativeElement, + clearHighlightNativeElement, + } = useHighlightNativeElement(); const handleClick = useCallback( () => @@ -532,12 +537,18 @@ function OwnerView({ [dispatch, id], ); + const onMouseEnter = () => highlightNativeElement(id); + + const onMouseLeave = () => clearHighlightNativeElement(); + return (