30
SuspenseTreeStateContext,
31
SuspenseTreeDispatcherContext,
32
} from './SuspenseTreeContext';
33
+import {getClassNameForEnvironment} from './SuspenseEnvironmentColors.js';
34
35
function ScaledRect({
36
className,
158
hoveredTimelineIndex > -1 &&
159
timeline[hoveredTimelineIndex].id === suspenseID;
160
161
+ let environment: null | string = null;
162
+ for (let i = 0; i < timeline.length; i++) {
163
+ const timelineStep = timeline[i];
164
+ if (timelineStep.id === suspenseID) {
165
+ environment = timelineStep.environment;
166
+ break;
167
+ }
168
+ }
169
+
170
const boundingBox = getBoundingBox(suspense.rects);
171
172
return (
173
<ScaledRect
174
rect={boundingBox}
165
- className={styles.SuspenseRectsBoundary}
175
+ className={
176
+ styles.SuspenseRectsBoundary +
177
+ ' ' +
178
+ getClassNameForEnvironment(environment)
179
+ }
180
visible={visible}
181
selected={selected}
182
suspended={suspense.isSuspended}
341
const treeDispatch = useContext(TreeDispatcherContext);
342
const suspenseTreeDispatch = useContext(SuspenseTreeDispatcherContext);
343
// TODO: This relies on a full re-render of all children when the Suspense tree changes.
330
- const {roots, hoveredTimelineIndex, uniqueSuspendersOnly} = useContext(
331
- SuspenseTreeStateContext,
332
- );
344
+ const {roots, timeline, hoveredTimelineIndex, uniqueSuspendersOnly} =
345
+ useContext(SuspenseTreeStateContext);
346
347
// TODO: bbox does not consider uniqueSuspendersOnly filter
348
const boundingBox = getDocumentBoundingRect(store, roots);
402
}
403
}
404
405
+ const rootEnvironment =
406
+ timeline.length === 0 ? null : timeline[0].environment;
407
+
408
return (
409
<div
410
className={
411
styles.SuspenseRectsContainer +
396
- (hasRootSuspenders ? ' ' + styles.SuspenseRectsRoot : '')
412
+ (hasRootSuspenders ? ' ' + styles.SuspenseRectsRoot : '') +
413
+ ' ' +
414
+ getClassNameForEnvironment(rootEnvironment)
415
}
416
onClick={handleClick}
417
onDoubleClick={handleDoubleClick}