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

Layers browser width calculated based on map width #430

Merged
merged 8 commits into from
Mar 3, 2020

Conversation

nstjean
Copy link
Contributor

@nstjean nstjean commented Mar 2, 2020

Fixes #420 (<=== Add issue number here)

I've reformatted the styling of the menus as they shrink down in size so that the menu style applied is calculated based on the size of the map itself, not the browser window. This is done by dynamically adding a class to the .leaflet-container
Width 0-379px gets "xs"
width 380-589px gets "sm"
width 590-879px gets "md"
width 880+ gets "lg"

Unfortunately the width of the menu itself is a set width for each of the classes, as using a % width doesn't work correctly and it would take me more time to figure out a solution. But I think this offers a pretty reasonable experience at any map width!

lg
FireShot Capture 333 - Leaflet Environmental Layers -

md
FireShot Capture 334 - Leaflet Environmental Layers -

sm
FireShot Capture 335 - Leaflet Environmental Layers -

xs
FireShot Capture 336 - Leaflet Environmental Layers -

Peek 2020-03-02 15-18

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
  • code is in uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updation
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@crisner
Copy link
Contributor

crisner commented Mar 3, 2020

Does this work with browser resizing too as media queries does?

@@ -0,0 +1,33 @@
// set the map menu to the correct size
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this file for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops forgot to remove that. I ended up not using it.

@nstjean
Copy link
Contributor Author

nstjean commented Mar 3, 2020

Does this work with browser resizing too as media queries does?

Yes, as long as the map size changes then the menu will adjust its size.

@crisner
Copy link
Contributor

crisner commented Mar 3, 2020

I am curious. Does the map have to resize for it to take effect? Would it work as expected on smaller screens?

@nstjean
Copy link
Contributor Author

nstjean commented Mar 3, 2020

No resize is needed, the function is called on load.

Phone size:
FireShot Capture 337 - Leaflet Environmental Layers -

And here's ipad size on example/index.html:
FireShot Capture 338 - Leaflet Environmental Layers -

@crisner
Copy link
Contributor

crisner commented Mar 3, 2020

Awesome!!! 🎉

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

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

This is gorgeous! Thanks a ton! I think it needs a rebase but otherwise this is good to go!

@nstjean nstjean merged commit c2c9bc4 into publiclab:master Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Browser Menu not displaying correct size and style
3 participants