Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: EE issues #936

Merged
merged 8 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ const CookiesLandingWrapper = ({
</div>
{description && (
<div className="text-center px-4 flex items-center justify-center -mt-2 mb-10">
<p className="lg:max-w-[450px] text-gray dark:text-bright-gray">
<div className="lg:max-w-[450px] text-gray dark:text-bright-gray">
{description}
</p>
</div>
</div>
)}
<div className="lg:max-w-[729px] mx-auto flex justify-center flex-col mt-2 pb-10 px-4">
Expand Down
14 changes: 10 additions & 4 deletions packages/design-system/src/components/draggableTray/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ const DraggableTray = forwardRef<

const [isCollapsed, setIsCollapsed] = useState(initialCollapsed);

const [height, setHeight] = useState<string | undefined>('20%');
const [height, setHeight] = useState<string | undefined>('30%');

useEffect(() => {
if (!isCollapsed) {
setHeight('20%');
setHeight('30%');
}
}, [isCollapsed]);

Expand All @@ -72,7 +72,7 @@ const DraggableTray = forwardRef<
<Resizable
defaultSize={{
width: '100%',
height: '20%',
height: '30%',
}}
onResizeStop={(_, __, ___, d) => {
setHeight(() => `calc(${height} + ${d.height}px)`);
Expand All @@ -98,7 +98,13 @@ const DraggableTray = forwardRef<
/>
</button>
</div>
{!isCollapsed && ActiveTabContent && <ActiveTabContent {...props} />}
<div
style={{
height: isCollapsed ? '0px' : 'calc(100% - 30px)',
}}
>
{ActiveTabContent && <ActiveTabContent {...props} />}
</div>
</div>
</Resizable>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,10 @@ export const interestGroupSketch = (p) => {
}
}

if (props.setIsBubbleExpanded) {
app.setIsBubbleExpanded = props.setIsBubbleExpanded;
}

if (props.setCurrentStep) {
app.setCurrentStep = props.setCurrentStep;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ bubbles.reverseBarrageAnimation = async (index) => {
bubbles.showExpandedBubbles = () => {
bubbles.clearAndRewriteBubbles();
bubbles.generateBubbles(true);
app.setIsBubbleExpanded(true);

app.bubbles.expandedSVG = bubbles.bubbleChart(app.bubbles.positions, {
label: (d) =>
Expand Down Expand Up @@ -389,6 +390,8 @@ bubbles.showExpandedBubbles = () => {
bubbles.showMinifiedBubbles = () => {
app.setHighlightedInterestGroup(null);
app.bubbles.highlightedInterestGroup = null;
app.setIsBubbleExpanded(false);

app.bubbles.minifiedSVG = bubbles.bubbleChart(app.bubbles.positions, {
label: (d) =>
[
Expand Down
14 changes: 9 additions & 5 deletions packages/extension/src/view/devtools/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,17 @@
}

.markdown-body {

--bgColor-default: #ffffff;
--bgColor-muted: #fbfbfb;
--fgColor-default: #000000;
--bgColor-neutral-muted: #fbfbfb;

h1, h2, h3, h4, h5, h6 {
h1,
h2,
h3,
h4,
h5,
h6 {
scroll-margin-top: 20px;
}

Expand Down Expand Up @@ -103,7 +107,6 @@
h6 {
font-size: 12px;
}

}

body {
Expand Down Expand Up @@ -184,7 +187,7 @@ body {
}

.circle-svg {
transition: transform .2s;
transition: transform 0.2s;
}

.circle-svg:hover {
Expand All @@ -200,12 +203,12 @@ text {
position: absolute;
display: block;
top: var(--expandedBubbleY);
left: var(--expandedBubbleX);
height: var(--expandedBubbleWidth);
width: var(--expandedBubbleWidth);
border-radius: 50%;
border: 1px solid #808080;
backdrop-filter: blur(10px);
left: var(--expandedBubbleX)
}

.bubble-container {
Expand All @@ -214,6 +217,7 @@ text {
}

.bubble-container.expanded {
position: absolute;
backdrop-filter: blur(1px);
z-index: 4;
height: 100vh;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
sketch as mainSketch,
} from '@google-psat/explorable-explanations';
import { ReactP5Wrapper } from '@p5-wrapper/react';
import classNames from 'classnames';
import { DraggableTray, useTabs } from '@google-psat/design-system';

/**
Expand Down Expand Up @@ -95,6 +96,7 @@ const Panel = ({
const [expandedBubbleWidth, setBubbleWidth] = useState(0);
const [expandedBubbleX, setExpandedBubbleX] = useState(0);
const [expandedBubbleY, setExpandedBubbleY] = useState(0);
const [isBubbleExpanded, setIsBubbleExpanded] = useState(false);

const setPlaying = useCallback(() => {
setPlay((prevState) => {
Expand Down Expand Up @@ -161,35 +163,44 @@ const Panel = ({
const containerWidth = containerRef.current.offsetWidth;
const containerHeight = containerRef.current.offsetHeight;
const newSize = Math.min(containerWidth, containerHeight) / 2;
const centerX = (containerWidth - newSize) / 4;
const centerY = (containerHeight - newSize) / 4;

setBubbleWidth(newSize);
setExpandedBubbleX(centerX);
setExpandedBubbleY(centerY);
}
});
}, []);

const getDivDimensions = useCallback(() => {
if (!divRef.current) {
return {
visibleWidth: 0,
visibleHeight: 0,
newSize: 0,
};
}

const divRect = divRef.current.getBoundingClientRect();
const visibleWidth = Math.max(
0,
Math.min(divRect.right, window.innerWidth) - Math.max(divRect.left, 0)
);
const visibleHeight = Math.max(
0,
Math.min(divRect.bottom, window.innerHeight) - Math.max(divRect.top, 0)
);
const newSize = Math.min(visibleWidth, visibleHeight) / 2;

return {
visibleWidth,
visibleHeight,
newSize,
};
}, []);

useEffect(() => {
if (divRef.current) {
const divRect = divRef.current.getBoundingClientRect();
const visibleWidth = Math.max(
0,
Math.min(divRect.right, window.innerWidth) - Math.max(divRect.left, 0)
);
const visibleHeight = Math.max(
0,
Math.min(divRect.bottom, window.innerHeight) - Math.max(divRect.top, 0)
);

const newSize = Math.min(visibleWidth, visibleHeight) / 2;
const centerX = (visibleWidth - newSize) / 4;
const centerY = (visibleHeight - newSize) / 4;
const { newSize } = getDivDimensions();

setBubbleWidth(newSize);
setExpandedBubbleX(centerX);
setExpandedBubbleY(centerY);
}

if (containerRef.current) {
Expand All @@ -204,7 +215,22 @@ const Panel = ({
handleResizeCallback.unobserve(containerRefCopy.current);
}
};
}, [handleResizeCallback]);
}, [getDivDimensions, handleResizeCallback]);

useEffect(() => {
if (isBubbleExpanded) {
const div = divRef.current;

if (div) {
const { visibleWidth, visibleHeight, newSize } = getDivDimensions();
const centerX = visibleWidth / 2 - newSize;
const centerY = visibleHeight / 4 - newSize / 4;

setExpandedBubbleX(div.scrollLeft + centerX);
setExpandedBubbleY(div.scrollTop + centerY);
}
}
}, [getDivDimensions, isBubbleExpanded]);

const resetHandler = useCallback(() => {
app.reset();
Expand Down Expand Up @@ -272,7 +298,13 @@ const Panel = ({
extraInterface={extraInterface}
/>
<div className="w-full h-full">
<main className="h-full w-full overflow-auto relative" ref={divRef}>
<main
className={classNames('h-full w-full relative', {
'overflow-hidden': isBubbleExpanded,
'overflow-auto': !isBubbleExpanded,
})}
ref={divRef}
>
<div id="ps-canvas">
<div id="canvas-container" />
</div>
Expand Down Expand Up @@ -322,6 +354,7 @@ const Panel = ({
sketch={interestGroupSketch}
expandedBubbleX={expandedBubbleX}
expandedBubbleY={expandedBubbleY}
setIsBubbleExpanded={setIsBubbleExpanded}
expandedBubbleWidth={expandedBubbleWidth}
speedMultiplier={2 * sliderStep}
setCurrentSite={setCurrentSite}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const ProtectedAudience = () => {
title: 'Explorable Explanations',
content: {
Element: ExplorableExplanation,
className: 'overflow-hidden',
},
},
{
Expand Down
Loading