
News homepage - HTML, SCSS, TypeScript, RWD
Design comparison
Solution retrospective
I found a way to “import” breakpoints declared in SCSS into JavaScript in a way that makes maintainance easier, IMHO.
What challenges did you encounter, and how did you overcome them?In order to use the breakpoints I named in SCSS in JavaScript, I added custom properties targeting the breakpoints to the :root
selector. First, I wanted to use getComputedStyle()
to retrieve the custom properties, but Chrome does not include custom properties within the object returned by such a method (Chrome 131- at the time when I wrote these lines). Instead, I used document.styleSheets
and nested for
loops to get the custom properties.
Do not hesitate over giving feedback about how I implemented the way the menu appears on mobile view. I am wondering if there is a way to do that without JavaScript and in an accessible way.
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord