News homepage - Sass, BEM, Mobile first, accessible mobile navigation

Solution retrospective
Hello! 👋
The design of this project caught my attention, so I decided to do it. It was a great opportunity to learn Sass CSS pre-processor and implement it into this project. I tried to create accessible mobile navigation by following Web Accessibility Guidelines. Just like in other recent projects i used mobile-first approach.
💡Here's some new things I used or learned:
- Learned Sass CSS pre-processor. Sass is a stylesheet language that’s compiled to CSS. It allows to use variables, nested rules, mixins, functions, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized and makes it easy to share design within and across projects.
- Used Sass file structure called 7-1 Pattern. It offers great way to modularize Sass file structure and help keep things easier to maintain. It's all about having everything in order so it is easier to work with code.
- Followed Web Accessibility Guidelines v1.0 to make accessible mobile navigation
- Used CSS Counters to automatically number the articles in trending section. CSS counters let you adjust the appearance of content based on its location in a document. For example, you can use counters to automatically number the headings in a webpage, or to change the numbering on ordered lists.
🛠️Build with: (can be found also in my others projects)
- I used simple container as a proxy JavaScript technique to make entire container clickable in situations where container acts like illustrated introduction to article and it has a link inside (see articles or trending sections). One drawback was that by creating the entire container clickable, user will not be able to select anything.To allow selecting I detected how long the user is taking between mousedown and mouseup events and suppress the clicking event if user is likely to be selecting text.
- CSS
backdrop-filter
property for overlay when the modal pops up. The backdrop-filter property is used to apply a graphical effect to the area behind an element. I used it to blur the page behind my overlay. <picture>
HTML element for responsive images. That is images that work well on devices with widely differing screen size. HTML provides us with elements to display identical image content, just larger or smaller depending on the device. This helps to improve performance across different devices.- Reduced browser inconsistencies in things like default line heights, margins and font sizes of headings, and so on by using CSS Reset by Andy Bell
- BEM - Block, Element, Modifier methodology, which is a popular naming convention for classes in HTML and CSS. BEM is useful when it comes to larger, more complex projects when code organization becomes crucial. The idea behind it is to speed up the development process, and ease the teamwork of developers by arranging CSS classes into independent modules.
- mobile-first approach. It is one of the best strategies to create either a responsive or adaptive design. Started with the smallest mobile screen and worked my way up.
:focus-visible
pseudo-class to increase usability for sighted users who use keyboard navigation. The :focus-visible pseudo-class is a native CSS way to style elements that are in focus but only applies when you actually want a visual indicator to help the user see where the focus is.- Instead of repeating code for reusable elements I write some helper classes to reuse them throughout the project. I created reusable classes for headings, paragraphs or containers. This saves time as well as unnecessary code repetition. I will definitely try to improve in this aspect.
❓Questions:
- No specific questions. Any suggestions on how I can improve are welcome!
Please log in to post a comment
Log in with GitHubCommunity feedback
- @grace-snow
Here's some feedback
- You must change the aria label on that logo link. It must say name of the site and then destination e.g. W News - Home. Links already have a navigation role, never write verbose labels like "navigate to..."
- Similarly, the label on the nav toggle should say "Navigation toggle" or "menu toggle" not "Open X" and the label text should not change on click. Think about how this will be exposed to the accessibility API. It would currently be announced as "Open menu, Collapsed" or "Close menu, Expanded". That sounds kind of confusing when you compare to "Menu toggle, Collapsed/Expanded" doesn't it.
- Similar again, the label on the nav element doesn't need to include the word "navigation". It's already a nav! So just "main" or "primary" is fine
- Think through the page semantics without any styling. "The Bright Future of Web 3.0" is definitely not the page heading. This needs a visually hidden h1. Personally, I would make all article titles h3s in this and make sure appropriate visually-hidden h1 and in places h2s are added when needed. For example: h1 = "News Homepage"; h2 = "Featured"; h3 = "The bright future..."; h2 = "New"; h3s = The article titles in that section; h2 = "Most Read"; h3 = The articles within that section.
- This would benefit from using CSS grid for the main layout;
- I would expect the media query in the picture element to be defined in rem or em, just like the CSS. Not strictly necessary, just what I would do.
- Do you think all of the images are decorative on this?? I'd expect news article images to be considered meaningful content, at lease all except the abstract one.... Something to consider anyway. Not something you definitely need to change.
- The last section is clearly an ordered list so that's what it should be using in the html. (Not unordered)
- Text should never be in spans. I'd expect those numbers either to be paragraphs or pseudo content using the list counter.
Marked as helpful - P@maishamir
Wow that's spot on! How'd you make it so exact to the design? Only thing I noticed was that the background color is slightly different, but that might just be a design choice.
Join 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