Skip to content

Commit ef88c58

Browse files
authored
[DevTools] Tweak the rects design and create multi-environment color scheme (#34880)
<img width="1011" height="811" alt="Screenshot 2025-10-16 at 2 20 46 PM" src="https://github.com/user-attachments/assets/6dea3962-d369-4823-b44f-2c62b566c8f1" /> The selection is now clearer with a wider outline which spans the bounding box if there are multi rects. The color now gets darked changes on hover with a slight animation. The colors are now mixed from constants defined which are consistently used in the rects, the time span in the "suspended by" side bar and the scrubber. I also have constants defined for "server" and "other" debug environments which will be used in a follow up.
1 parent dc485c7 commit ef88c58

File tree

5 files changed

+74
-23
lines changed

5 files changed

+74
-23
lines changed

packages/react-devtools-shared/src/devtools/constants.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
136136
'--color-timeline-text-dim-color': '#ccc',
137137
'--color-timeline-react-work-border': '#eeeeee',
138138
'--color-timebar-background': '#f6f6f6',
139-
'--color-timespan-background': '#62bc6a',
140-
'--color-timespan-background-errored': '#d57066',
141139
'--color-search-match': 'yellow',
142140
'--color-search-match-current': '#f7923b',
143141
'--color-selected-tree-highlight-active': 'rgba(0, 136, 250, 0.1)',
@@ -156,6 +154,14 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
156154
'--color-warning-text-color': '#ffffff',
157155
'--color-warning-text-color-inverted': '#fd4d69',
158156

157+
'--color-suspense': '#0088fa',
158+
'--color-transition': '#6a51b2',
159+
'--color-suspense-server': '#62bc6a',
160+
'--color-transition-server': '#3f7844',
161+
'--color-suspense-other': '#f3ce49',
162+
'--color-transition-other': '#917b2c',
163+
'--color-suspense-errored': '#d57066',
164+
159165
// The styles below should be kept in sync with 'root.css'
160166
// They are repeated there because they're used by e.g. tooltips or context menus
161167
// which get rendered outside of the DOM subtree (where normal theme/styles are written).
@@ -290,8 +296,6 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
290296
'--color-timeline-text-dim-color': '#555b66',
291297
'--color-timeline-react-work-border': '#3d424a',
292298
'--color-timebar-background': '#1d2129',
293-
'--color-timespan-background': '#62bc6a',
294-
'--color-timespan-background-errored': '#d57066',
295299
'--color-search-match': 'yellow',
296300
'--color-search-match-current': '#f7923b',
297301
'--color-selected-tree-highlight-active': 'rgba(23, 143, 185, 0.15)',
@@ -311,6 +315,14 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
311315
'--color-warning-text-color': '#ffffff',
312316
'--color-warning-text-color-inverted': '#ee1638',
313317

318+
'--color-suspense': '#61dafb',
319+
'--color-transition': '#6a51b2',
320+
'--color-suspense-server': '#62bc6a',
321+
'--color-transition-server': '#3f7844',
322+
'--color-suspense-other': '#f3ce49',
323+
'--color-transition-other': '#917b2c',
324+
'--color-suspense-errored': '#d57066',
325+
314326
// The styles below should be kept in sync with 'root.css'
315327
// They are repeated there because they're used by e.g. tooltips or context menus
316328
// which get rendered outside of the DOM subtree (where normal theme/styles are written).

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementSharedStyles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,13 @@
128128
.TimeBarSpan, .TimeBarSpanErrored {
129129
position: absolute;
130130
border-radius: 0.125rem;
131-
background-color: var(--color-timespan-background);
131+
background-color: var(--color-suspense);
132132
width: 100%;
133133
height: 100%;
134134
}
135135

136136
.TimeBarSpanErrored {
137-
background-color: var(--color-timespan-background-errored);
137+
background-color: var(--color-suspense-errored);
138138
}
139139

140140
.SmallHeader {
Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
.SuspenseRectsContainer {
22
padding: .25rem;
33
cursor: pointer;
4-
outline: 1px solid var(--color-component-name);
4+
outline-color: var(--color-transition);
5+
outline-style: solid;
6+
outline-width: 1px;
57
border-radius: 0.25rem;
8+
background-color: color-mix(in srgb, var(--color-transition) 5%, transparent);
9+
}
10+
11+
.SuspenseRectsContainer:hover:not(:has(.SuspenseRectsBoundary:hover))[data-highlighted='false'] {
12+
outline-width: 1px;
613
}
714

815
.SuspenseRectsContainer[data-highlighted='true'] {
9-
background: var(--color-dimmest);
16+
outline-style: solid;
17+
outline-width: 4px;
1018
}
1119

1220
.SuspenseRectsViewBox {
@@ -15,6 +23,11 @@
1523

1624
.SuspenseRectsBoundary {
1725
pointer-events: all;
26+
border-radius: 0.125rem;
27+
}
28+
29+
.SuspenseRectsBoundary[data-visible='false'] {
30+
background-color: transparent;
1831
}
1932

2033
.SuspenseRectsBoundaryChildren {
@@ -28,31 +41,47 @@
2841
.SuspenseRectsRect {
2942
box-shadow: var(--elevation-4);
3043
pointer-events: all;
44+
cursor: pointer;
45+
border-radius: 0.125rem;
46+
background-color: color-mix(in srgb, var(--color-background) 50%, var(--color-suspense) 25%);
47+
backdrop-filter: grayscale(100%);
48+
transition: background-color 0.2s ease-in;
49+
outline-color: var(--color-suspense);
3150
outline-style: solid;
3251
outline-width: 1px;
33-
border-radius: 0.125rem;
34-
cursor: pointer;
3552
}
3653

3754
.SuspenseRectsScaledRect {
3855
position: absolute;
39-
outline-color: var(--color-background-selected);
4056
}
4157

4258
.SuspenseRectsScaledRect[data-visible='false'] {
4359
pointer-events: none;
4460
outline-width: 0;
4561
}
4662

47-
.SuspenseRectsScaledRect[data-suspended='true'] {
48-
opacity: 0.3;
63+
.SuspenseRectsBoundary[data-suspended='true'] {
64+
opacity: 0.33;
4965
}
5066

5167
/* highlight this boundary */
52-
.SuspenseRectsBoundary:hover:not(:has(.SuspenseRectsBoundary:hover)) > .SuspenseRectsRect, .SuspenseRectsBoundary[data-highlighted='true'] > .SuspenseRectsRect {
53-
background-color: var(--color-background-hover);
68+
.SuspenseRectsBoundary:hover:not(:has(.SuspenseRectsBoundary:hover)) > .SuspenseRectsRect {
69+
background-color: color-mix(in srgb, var(--color-background) 50%, var(--color-suspense) 50%);
70+
transition: background-color 0.2s ease-out;
71+
}
72+
73+
.SuspenseRectsBoundary[data-selected='true'] {
74+
box-shadow: var(--elevation-4);
75+
}
76+
77+
.SuspenseRectOutline {
78+
outline-color: var(--color-suspense);
79+
outline-style: solid;
80+
outline-width: 4px;
81+
border-radius: 0.125rem;
82+
pointer-events: none;
5483
}
5584

56-
.SuspenseRectsRect[data-highlighted='true'] {
57-
background-color: var(--color-selected-tree-highlight-active);
85+
.SuspenseRectsBoundary[data-selected='true'] > .SuspenseRectsRect {
86+
box-shadow: none;
5887
}

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseRects.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ function ScaledRect({
3636
rect,
3737
visible,
3838
suspended,
39+
selected,
3940
adjust,
4041
...props
4142
}: {
4243
className: string,
4344
rect: Rect,
4445
visible: boolean,
4546
suspended: boolean,
47+
selected?: boolean,
4648
adjust?: boolean,
4749
...
4850
}): React$Node {
@@ -58,6 +60,7 @@ function ScaledRect({
5860
className={styles.SuspenseRectsScaledRect + ' ' + className}
5961
data-visible={visible}
6062
data-suspended={suspended}
63+
data-selected={selected}
6164
style={{
6265
// Shrink one pixel so that the bottom outline will line up with the top outline of the next one.
6366
width: adjust ? 'calc(' + width + ' - 1px)' : width,
@@ -152,6 +155,7 @@ function SuspenseRects({
152155
rect={boundingBox}
153156
className={styles.SuspenseRectsBoundary}
154157
visible={visible}
158+
selected={selected}
155159
suspended={suspense.isSuspended}>
156160
<ViewBox.Provider value={boundingBox}>
157161
{visible &&
@@ -162,7 +166,6 @@ function SuspenseRects({
162166
key={index}
163167
className={styles.SuspenseRectsRect}
164168
rect={rect}
165-
data-highlighted={selected}
166169
adjust={true}
167170
onClick={handleClick}
168171
onDoubleClick={handleDoubleClick}
@@ -182,6 +185,13 @@ function SuspenseRects({
182185
})}
183186
</ScaledRect>
184187
)}
188+
{selected ? (
189+
<ScaledRect
190+
className={styles.SuspenseRectOutline}
191+
rect={boundingBox}
192+
adjust={true}
193+
/>
194+
) : null}
185195
</ViewBox.Provider>
186196
</ScaledRect>
187197
);

packages/react-devtools-shared/src/devtools/views/SuspenseTab/SuspenseScrubber.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@
4040
.SuspenseScrubberBead {
4141
flex: 1;
4242
height: 0.5rem;
43-
background: var(--color-background-selected);
4443
border-radius: 0.5rem;
45-
background: var(--color-selected-tree-highlight-active);
46-
transition: all 0.3s ease-in-out;
44+
background: color-mix(in srgb, var(--color-suspense) 10%, transparent);
45+
transition: all 0.3s ease-in;
4746
}
4847

4948
.SuspenseScrubberBeadSelected {
5049
height: 1rem;
51-
background: var(--color-background-selected);
50+
background: var(--color-suspense);
5251
}
5352

5453
.SuspenseScrubberBeadTransition {
55-
background: var(--color-component-name);
54+
background: var(--color-transition);
5655
}
5756

5857
.SuspenseScrubberStepHighlight > .SuspenseScrubberBead,
5958
.SuspenseScrubberStep:hover > .SuspenseScrubberBead {
6059
height: 0.75rem;
60+
transition: all 0.3s ease-out;
6161
}

0 commit comments

Comments
 (0)