Skip to content

Commit 6c29cc0

Browse files
authored
Enhancement: Update IG highlighting logic (#933)
* feat: Remove timeout unhighlighting logic, and unhighlight when bubble minimized * feat: Add stroke to the selected bubble
1 parent 1a2c9c8 commit 6c29cc0

File tree

2 files changed

+18
-16
lines changed
  • packages
    • explorable-explanations/src/protectedAudience/modules
    • extension/src/view/devtools/components/privateAdvertising/protectedAudience/explorableExplanation

2 files changed

+18
-16
lines changed

packages/explorable-explanations/src/protectedAudience/modules/bubbles.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const bubbles = {};
3939
*/
4040
bubbles.init = () => {
4141
app.bubbles.positions = [];
42+
app.bubbles.highlightedInterestGroup = null;
4243
};
4344

4445
/**
@@ -386,6 +387,8 @@ bubbles.showExpandedBubbles = () => {
386387
};
387388

388389
bubbles.showMinifiedBubbles = () => {
390+
app.setHighlightedInterestGroup(null);
391+
app.bubbles.highlightedInterestGroup = null;
389392
app.bubbles.minifiedSVG = bubbles.bubbleChart(app.bubbles.positions, {
390393
label: (d) =>
391394
[
@@ -512,13 +515,26 @@ bubbles.bubbleChart = (
512515
interestGroupOwner: 'https://www.' + groups[d.data],
513516
color: app.color(groups[d.data]),
514517
});
518+
app.bubbles.highlightedInterestGroup = titles[d.data];
515519
event.stopPropagation();
516520
};
517521

518522
leaf
519523
.append('circle')
520-
.attr('stroke', stroke)
521-
.attr('stroke-width', strokeWidth)
524+
.attr('stroke', (d) => {
525+
if (app.bubbles.highlightedInterestGroup === titles[d.data]) {
526+
return '#dbdb48';
527+
}
528+
529+
return stroke === null ? 'none' : stroke;
530+
})
531+
.attr('stroke-width', (d) => {
532+
if (app.bubbles.highlightedInterestGroup === titles[d.data]) {
533+
return 5;
534+
}
535+
536+
return strokeWidth === null ? 0 : strokeWidth;
537+
})
522538
.attr('stroke-opacity', strokeOpacity)
523539
.attr('class', 'svg overflowing-text circle-svg')
524540
.attr('style', `${!app.bubbles.isExpanded ? 'pointer-events: none;' : ''}`)

packages/extension/src/view/devtools/components/privateAdvertising/protectedAudience/explorableExplanation/index.tsx

-14
Original file line numberDiff line numberDiff line change
@@ -192,20 +192,6 @@ const ExplorableExplanation = () => {
192192
color: string;
193193
} | null>(null);
194194

195-
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
196-
197-
useEffect(() => {
198-
timeoutRef.current = setTimeout(() => {
199-
setHighlightedInterestGroup(null);
200-
}, 1500);
201-
202-
return () => {
203-
if (timeoutRef.current) {
204-
clearTimeout(timeoutRef.current);
205-
}
206-
};
207-
}, [highlightedInterestGroup]);
208-
209195
const tabItems = useMemo<TabItems>(
210196
() => [
211197
{

0 commit comments

Comments
 (0)