Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

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

#accessibility#bem#sass/scss
P
tediko 6,580

@tediko

Desktop design screenshot for the News homepage coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

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!

Community feedback

P
Grace 27,870

@grace-snow

Posted

Here's some feedback

  1. 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..."
  2. 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.
  3. 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
  4. 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.
  5. This would benefit from using CSS grid for the main layout;
  6. 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.
  7. 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.
  8. The last section is clearly an ordered list so that's what it should be using in the html. (Not unordered)
  9. 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

1

P
tediko 6,580

@tediko

Posted

Hi @grace-snow!

Thank you for your valuable suggestions and feedback! I will remember not to write verbose aria-labels. It will definitely help me a lot in the future to check how the accessibility API displays my website so that I can better understand how it works. Logo link, nav toggle and nav labels are now changed respectively.

“Think through the page semantics without any styling”. This sentence puts a new perspective on headings for me and I definitely understand your point. It makes so much sense now. Appropriate headings have been added and existing ones tags changed. Additionally, for "New" heading I added a span with class sr-only to make this heading more descriptive like "New articles”

When I was creating the project, I noticed that it would be much easier to use grid here, and certainly to make the page look better on different screen widths because it would be easier for me to arrange the containers. I used flexbox because I still watch materials related to it and I wanted to consolidate my knowledge. Grid is definitely next in line and I will use it in future ones.

When it comes to alt attributes and decorative photos. I can't answer that for you now. I need to read more about how to write good alt texts. In my opinion they should not be decorative, but on the other hand, for example, how does the photo of the keyboard relate to "Top 10 laptops”?

Picture media query is defined with em’s now. The list in the trending section has been changed to ordered list.

I changed spans to ::before pseudo-class using the list counters to automatically number the trending articles. I know you pointed that out in card challenge that text should never be in divs or spans alone. It was more of a oversight or bad habit.

Thanks again and have a nice day!

0
P
Grace 27,870

@grace-snow

Posted

@tediko I do not recommend this Additionally, for "New" heading I added a span with class sr-only to make this heading more descriptive like "New articles”

If you do that you do not always have control over the order it would be read out because half the heading is inline and half Sr-only.

If something already has a visible heading, leave it as if is.

1
P
Maisha Mir 130

@maishamir

Posted

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.

1

P
tediko 6,580

@tediko

Posted

@maishamir Thanks! I am using Figma to get all dimensions and sizes to make it close to the design. Additionally you can use browser extension called pixel perfect to polish your solution to be as close as possible, but I wouldn't sweat about that.

Actually! Good catch with background-color! Now that you pointed that I checked and it is indeed slightly different. Should be fixed now. A little oversight 😅 Thanks for pointing that out!

1

Please log in to post a comment

Log in with GitHub
Discord logo

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