Skip to content

Commit 097b7ce

Browse files
committed
Cap chart and map height to prevent vertical scrolling on smaller screens
1 parent b0fa56f commit 097b7ce

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/components/country-map.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212

1313
country-map {
1414
display: block;
15+
// Reserve space before svgmap loads to avoid layout shift
1516
aspect-ratio: auto 2 / 1;
17+
// 550px: comfortable max on large screens (leaves room for navbar, heading, footer on 900px viewports)
18+
// 65dvh: viewport-relative cap so the map never causes vertical scrolling
19+
max-height: min(550px, 65dvh);
20+
21+
// Propagate max-height into svgmap's padding-based layout
22+
.svgMap-map-wrapper {
23+
max-height: inherit;
24+
}
1625
}

src/components/popularity-chart.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
popularity-chart {
22
display: block;
3-
aspect-ratio: auto 16 / 9;
3+
// 600px: comfortable max on large screens (leaves room for navbar, heading, footer on 900px viewports)
4+
// 65dvh: viewport-relative cap so the chart never causes vertical scrolling
5+
height: min(600px, 65dvh);
46

57
// prevent scroll bars during graph rendering
68
canvas {

src/components/popularity-chart.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class PopularityChart extends HTMLElement {
8787
type: "line",
8888
data,
8989
options: {
90+
maintainAspectRatio: false,
9091
interaction: {
9192
mode: "index",
9293
intersect: false,

0 commit comments

Comments
 (0)