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

Layout Does Not Appear Responsive On Small Viewports #301

Open
jeffnyman opened this issue Mar 31, 2022 · 0 comments
Open

Layout Does Not Appear Responsive On Small Viewports #301

jeffnyman opened this issue Mar 31, 2022 · 0 comments

Comments

@jeffnyman
Copy link

jeffnyman commented Mar 31, 2022

Just looking at the Lanyon example itself, if you shrink your viewport down and use the sidebar widget, the text is pushed off the screen.

I would presume the idea is either to not show the sidebar widget in such cases or to just have it overlay the text maybe?

lanyon-text

Are there ways to handle this?

I'm thinking you can do this to try and handle when the viewport size gets too small:

@media (max-width: 45em) {
  .sidebar-toggle {
    display: none;
  }
}

I just picked 45em by eyeballing when the primary content seems to start running up into the hamburger toggle.

Guessing maybe the other part of this would be handled by automatically adding the .sidebar-overlay class when the size of the viewport is too small. I'm not entirely sure how to do that as it seems it would be JavaScript that executes only on a certain media query being viable (i.e., a max-width like I have above).

It feels like this might be workable:

(function (document) {
  var x = window.matchMedia("(max-width: 45em)");

  x.onchange = (e) => {
    if (e.matches) {
      document.body.classList.add("sidebar-overlay");
    } else {
      document.body.classList.remove("sidebar-overlay");
    }
  };
})(document);

So I might have answered my own question on reporting this issue. That said I'm curious if I'm missing some setting since it seems like a responsive layout would have to include this by default. Since this isn't in Lanyon, I'm presuming that perhaps there are better ways to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant