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

Lisab/zoom buttons #173

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 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
49 changes: 49 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,61 @@ body {
}
}

// hides zoom controls in mobile
.leaflet-control-container {
@media (max-width: $mobile_breakpoint) {
display: none;
}
}

// customize zoom button styles
$border-radius: 6px;

.leaflet-bottom .leaflet-control {
box-shadow: -6px 7px 15px #242424;
margin-right: 28px;
margin-bottom: 80px;
}
.leaflet-container .leaflet-bar {
border: unset;
}
.leaflet-container .leaflet-bar a {
border-bottom: none;
background-color: unset;
}

.leaflet-touch .leaflet-bar a {
background-size: 64px;
}

.leaflet-touch .leaflet-bar a {
background-image: url("images/LUTI_Zoom_Icon.svg");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a bug/feature in create-react-app where images included in css like this must live in the src directory, not public (unless public is inside src!) so that's why this one images lives in new directory src/images

}

.leaflet-touch .leaflet-bar a:first-child {
border-top-left-radius: $border-radius;
border-top-right-radius: $border-radius;

background-position: top -10px left -15px;
}
.leaflet-touch .leaflet-bar a:last-child {
border-bottom-left-radius: $border-radius;
border-bottom-right-radius: $border-radius;

background-position: bottom -11px left -15px;
}

.leaflet-touch .leaflet-bar a:hover {
filter: contrast(95%);
}
.leaflet-touch .leaflet-bar a.leaflet-disabled {
filter: contrast(220%) brightness(0.9);

:hover {
filter: contrast(220%);

}
}
.leaflet-control-attribution {
display: none;
}
Expand Down
14 changes: 14 additions & 0 deletions src/Homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ class Homepage extends React.Component {
};
}

componentDidMount() {
window.setTimeout(() => {
// move to useEffect
L.control
.zoom({
zoomInText: "",
zoomOutText: "",
position: "bottomright",
})
.addTo(this.state.map);
}, 1000);
}

render() {
const query = queryString.parse(this.props.location.search);

Expand Down Expand Up @@ -207,6 +220,7 @@ class Homepage extends React.Component {
attributionControl={false}
bounceAtZoomLimits={false}
ref={this.onMapLoad}
zoomControl={false}
>
<Videos
debug={query.debug}
Expand Down
21 changes: 19 additions & 2 deletions src/components/InfoBox.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import classNames from "classnames";
import PropTypes from "prop-types";

Expand All @@ -14,6 +14,23 @@ const TRANSITION_SPEED = 500;
export default function InfoBox({ desc, displayMode, title, url }) {
const [hidden, setHidden] = useState(true);

const ref = useRef(null);

useEffect(() => {
const intro = document.querySelector(".leaflet-control-zoom");
const height = ref.current.clientHeight;

if (!height || !intro) return;

if (hidden) {
intro.style.transition = "margin 300ms";
intro.style.marginBottom = "80px"; // .leaflet-bottom .leaflet-control in App.scss
} else {
intro.style.transition = "margin 300ms 200ms";
intro.style.marginBottom = `${height + 64}px`;
}
}, [hidden]);

useEffect(() => {
const body = document.body;
body.classList.add("overflow-hidden");
Expand Down Expand Up @@ -45,7 +62,7 @@ export default function InfoBox({ desc, displayMode, title, url }) {
displayMode={displayMode}
handleClick={() => setHidden(!hidden)}
/>
<div className={classNames("info-wrapper", displayMode)}>
<div ref={ref} className={classNames("info-wrapper", displayMode)}>
<div className="info-title">
<h1>{title}</h1>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Intro.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@include luti_font;

position: fixed;
bottom: 25vh;
bottom: 7em;
left: 0;
right: 0;
margin: 0 auto;
Expand Down
16 changes: 16 additions & 0 deletions src/images/LUTI_Zoom_Icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.