Skip to content

Commit

Permalink
fix(grapher): ensure grapher frame is visibile when embedded via an i…
Browse files Browse the repository at this point in the history
…frame
  • Loading branch information
sophiamersmann committed Oct 9, 2023
1 parent 45e9f9f commit b0646b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ export class CaptionedChart extends React.Component<CaptionedChartProps> {
}

@computed protected get bounds(): Bounds {
return this.props.bounds ?? this.manager.tabBounds ?? DEFAULT_BOUNDS
return (
this.props.bounds ??
// right padding prevents grapher's frame to be obscured by the chart/map
this.manager.tabBounds?.padRight(2) ??
DEFAULT_BOUNDS
)
}

@computed protected get boundsForChartArea(): Bounds {
Expand Down
5 changes: 2 additions & 3 deletions packages/@ourworldindata/grapher/src/core/grapher.scss
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ $zindex-controls-drawer: 140;
container-type: size;
container-name: grapher;

// use box-shadow instead of border to make sure the border is in the foreground
box-shadow: 0 0 0 1px $frame-color; // equivalent to `border: 1px solid $frame-color`
border: 1px solid $frame-color;
z-index: $zindex-chart;

* {
Expand Down Expand Up @@ -171,7 +170,7 @@ $zindex-controls-drawer: 140;
// and the left and right borders are hidden. the top and bottom borders are visible,
// but stretch across the entire page.
.GrapherComponent.optimizeForHorizontalSpace {
box-shadow: none;
border: none;

// adds top and bottom borders that stretch across the entire page.
// since we don't know the width of the page, we use a large number (200vw)
Expand Down

0 comments on commit b0646b9

Please sign in to comment.