question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Work out what to do with styled links in the notification banner component

See original GitHub issue

What

Links in the error summary are red, because we target them in the component CSS:

https://github.com/alphagov/govuk-frontend/blob/2b7a162b0f915483190ad56b5b15c543b8cd36c9/src/govuk/components/error-summary/_index.scss#L39-L53

We’ve flagged in #1732 that this seems to break the BEM principles applied elsewhere, where we style things explicitly as elements using classes, rather than using tags in the selector.

From talking to @christopherthomasdesign, when we build the notification banner, we want to make the links red for the error variant and green for the success variant, so we’ll have a similar issue.

We should consider:

  • that this is a valid use case to bend the BEM principles and using the same approach we use in the error summary
  • creating error and success a link element and modifiers, scoped within the component (for example govuk-notification-banner__link govuk-notification-banner__link--error)
  • creating error and success link modifiers (for example govuk-link govuk-link--error)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
vanitabarrettcommented, Oct 20, 2020

Changed approach on this while implementing as we noticed a difference in the way we were styling the notification header and text (based on a parent modifier class) vs links (having its own modifier class). We think it makes more sense for things to be consistent, and as this BEM guidance states it is allowed to style a sub-element based on a parent-element modifier. So we’ve essentially switched from option 2b to 2a

1reaction
hannalaaksocommented, Oct 6, 2020

@vanitabarrett Yes I think what the others have said makes a lot of sense about the dangers of different styles of conflicting. I think 2b is probably the best option. 2a sounds okay as well but it could be a little bit too “magic” to make it clear how the styles get applied.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Create a Website Notification Bar + 10 Great Examples
We are all familiar with website notification bars. So, today let's actually learn how they work and what some good examples are.
Read more >
Alert Banner Best Practices (Web Design for Disaster, Part 1)
Links should be underlined or made into buttons so they can be easily identified.
Read more >
8 Tips for Designing Inclusive Notifications and Alerts
If the banner contains a link, make it look obvious with an underline. If it contains buttons make sure it looks like it...
Read more >
Notifications - Carbon Design System
Notifications are an important method of communicating with users and providing feedback.
Read more >
How to optimize your website alert banners and keep users in ...
Follow these tips and best practices for placement, content, style, and functionality to create the best alert banner for your website.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found