Skip to content

Commit

Permalink
Use display/visibility instead of z-index for managing pane display
Browse files Browse the repository at this point in the history
  • Loading branch information
mileswwatkins committed Nov 30, 2024
1 parent 83ead81 commit b5a5399
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
12 changes: 1 addition & 11 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,10 @@ a {
position: absolute;
top: 0;
left: 0;
z-index: 2;
}

.FilterPane--hidden {
z-index: -1;
}

.mapboxgl-map {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100dvh;
z-index: 1;
display: none;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/components/Attribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ const Attribution = () => {
</a>{" "}
by Adrien Coquet
</span>
{/*
Colors c/o Kevin Blake
https://github.com/kevinsblake/NatParksPalettes
*/}
</div>
);
};
Expand Down
27 changes: 26 additions & 1 deletion src/components/Map.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.Map {
width: 100%;
}

.Map-circle {
cursor: pointer;
width: 10px;
Expand Down Expand Up @@ -25,14 +29,35 @@
border-radius: 50%;
top: 1rem;
left: 1rem;
z-index: 3;
z-index: 2;
background: #faf3ce;
justify-content: center;
align-items: center;
cursor: pointer;
}

.mapboxgl-map {
width: 100%;
height: 100dvh;
}

@media (max-width: 700px) {
.Map {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100dvh;
}

.Map--hidden {
/*
If you use `display: none` instead, then the Mapbox GL JS map will not
render at full height
*/
visibility: hidden;
}

.Map-Logo-Backing--active {
display: flex;
}
Expand Down
6 changes: 2 additions & 4 deletions src/components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ class Map extends Component {
};

render() {
console.log(this.props);

return (
<>
<div className={`Map ${!this.props.isActive && "Map--hidden"}`}>
<div
className={`Map-Logo-Backing ${this.props.isActive && "Map-Logo-Backing--active"}`}
onClick={this.props.returnToFilters}
Expand Down Expand Up @@ -96,7 +94,7 @@ class Map extends Component {

{this.state.popup.visible && <MapPopup {...this.state.popup} />}
</ReactMapGL>
</>
</div>
);
}
}
Expand Down

0 comments on commit b5a5399

Please sign in to comment.