@guardian/interactive-component-library 0.1.0-alpha.29 → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -444,46 +444,25 @@ const defaultStyles$s = {
|
|
|
444
444
|
unit,
|
|
445
445
|
container: container$6
|
|
446
446
|
};
|
|
447
|
-
function useWindowSize() {
|
|
448
|
-
const [windowSize, setWindowSize] = useState(() => {
|
|
449
|
-
if (typeof window === "undefined")
|
|
450
|
-
return {
|
|
451
|
-
width: 0,
|
|
452
|
-
height: 0
|
|
453
|
-
};
|
|
454
|
-
return {
|
|
455
|
-
width: window.innerWidth,
|
|
456
|
-
height: window.innerHeight
|
|
457
|
-
};
|
|
458
|
-
});
|
|
459
|
-
useEffect(() => {
|
|
460
|
-
if (typeof window === "undefined")
|
|
461
|
-
return;
|
|
462
|
-
function handleResize() {
|
|
463
|
-
setWindowSize({
|
|
464
|
-
width: window.innerWidth,
|
|
465
|
-
height: window.innerHeight
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
window.addEventListener("resize", handleResize);
|
|
469
|
-
return () => {
|
|
470
|
-
window.removeEventListener("resize", handleResize);
|
|
471
|
-
};
|
|
472
|
-
}, []);
|
|
473
|
-
return windowSize;
|
|
474
|
-
}
|
|
475
447
|
function useContainerSize(containerRef) {
|
|
476
|
-
const windowSize = useWindowSize();
|
|
477
448
|
const [containerSize, setContainerSize] = useState();
|
|
478
449
|
useLayoutEffect(() => {
|
|
479
450
|
const container2 = containerRef.current;
|
|
480
451
|
if (!container2)
|
|
481
452
|
return;
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
453
|
+
const observer = new ResizeObserver((entries) => {
|
|
454
|
+
for (let entry of entries) {
|
|
455
|
+
setContainerSize({
|
|
456
|
+
width: entry.contentRect.width,
|
|
457
|
+
height: entry.contentRect.height
|
|
458
|
+
});
|
|
459
|
+
}
|
|
485
460
|
});
|
|
486
|
-
|
|
461
|
+
observer.observe(container2);
|
|
462
|
+
return () => {
|
|
463
|
+
observer.disconnect();
|
|
464
|
+
};
|
|
465
|
+
}, [containerRef]);
|
|
487
466
|
return containerSize;
|
|
488
467
|
}
|
|
489
468
|
const WaffleType = {
|
|
@@ -1567,17 +1546,13 @@ const SlopeChart = ({
|
|
|
1567
1546
|
}
|
|
1568
1547
|
}) => {
|
|
1569
1548
|
const wrapperRef = useRef(null);
|
|
1570
|
-
const
|
|
1571
|
-
const
|
|
1549
|
+
const containerSize = useContainerSize(wrapperRef);
|
|
1550
|
+
const width = containerSize ? containerSize.width : 0;
|
|
1572
1551
|
const contentWidth = Math.floor(width - padding.left - padding.right);
|
|
1573
1552
|
const contentHeight = contentWidth;
|
|
1574
1553
|
const height = contentHeight + padding.top + padding.bottom;
|
|
1575
1554
|
const yScale = scaleLinear(domain, [contentHeight, 0]);
|
|
1576
1555
|
const show = width > 0;
|
|
1577
|
-
useLayoutEffect(() => {
|
|
1578
|
-
const newWidth = wrapperRef.current.getBoundingClientRect().width;
|
|
1579
|
-
setWidth(newWidth);
|
|
1580
|
-
}, [windowSize]);
|
|
1581
1556
|
const y1Labels = useMemo(() => {
|
|
1582
1557
|
let labels = lines.map((d2) => ({
|
|
1583
1558
|
y: yScale(d2.y1),
|
|
@@ -3881,6 +3856,8 @@ const SVGMap = forwardRef(({
|
|
|
3881
3856
|
}, [width, height]);
|
|
3882
3857
|
const organisedChildren = useOrganisedChildren(children);
|
|
3883
3858
|
const renderSVG = containerSize && !config.drawToCanvas;
|
|
3859
|
+
const zoomControl2 = organisedChildren.controls["ZoomControl"];
|
|
3860
|
+
const renderZoomControl = zoomControl2 && zoom2.enabled;
|
|
3884
3861
|
return jsxs("div", {
|
|
3885
3862
|
ref: containerRef,
|
|
3886
3863
|
className: styles$4.container,
|
|
@@ -3901,9 +3878,9 @@ const SVGMap = forwardRef(({
|
|
|
3901
3878
|
})
|
|
3902
3879
|
}), jsx("div", {
|
|
3903
3880
|
className: styles$4.controls,
|
|
3904
|
-
children: jsx("div", {
|
|
3881
|
+
children: renderZoomControl && jsx("div", {
|
|
3905
3882
|
className: styles$4.zoomControl,
|
|
3906
|
-
children: cloneElement(
|
|
3883
|
+
children: cloneElement(zoomControl2, {
|
|
3907
3884
|
onZoomIn: () => rendererRef.current.zoomIn(),
|
|
3908
3885
|
onZoomOut: () => rendererRef.current.zoomOut()
|
|
3909
3886
|
})
|
|
@@ -7429,6 +7406,34 @@ class GeoJSON {
|
|
|
7429
7406
|
});
|
|
7430
7407
|
}
|
|
7431
7408
|
}
|
|
7409
|
+
function useWindowSize() {
|
|
7410
|
+
const [windowSize, setWindowSize] = useState(() => {
|
|
7411
|
+
if (typeof window === "undefined")
|
|
7412
|
+
return {
|
|
7413
|
+
width: 0,
|
|
7414
|
+
height: 0
|
|
7415
|
+
};
|
|
7416
|
+
return {
|
|
7417
|
+
width: window.innerWidth,
|
|
7418
|
+
height: window.innerHeight
|
|
7419
|
+
};
|
|
7420
|
+
});
|
|
7421
|
+
useEffect(() => {
|
|
7422
|
+
if (typeof window === "undefined")
|
|
7423
|
+
return;
|
|
7424
|
+
function handleResize() {
|
|
7425
|
+
setWindowSize({
|
|
7426
|
+
width: window.innerWidth,
|
|
7427
|
+
height: window.innerHeight
|
|
7428
|
+
});
|
|
7429
|
+
}
|
|
7430
|
+
window.addEventListener("resize", handleResize);
|
|
7431
|
+
return () => {
|
|
7432
|
+
window.removeEventListener("resize", handleResize);
|
|
7433
|
+
};
|
|
7434
|
+
}, []);
|
|
7435
|
+
return windowSize;
|
|
7436
|
+
}
|
|
7432
7437
|
const coalitionsWrapper = "_coalitionsWrapper_4egbd_9";
|
|
7433
7438
|
const coalitionsContainer = "_coalitionsContainer_4egbd_14";
|
|
7434
7439
|
const coalition = "_coalition_4egbd_9";
|