-
Notifications
You must be signed in to change notification settings - Fork 334
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
Work out what to do with styled links in the notification banner component #1934
Comments
Option 1: style by element (
|
Thanks for breaking down the options @vanitabarrett 👍 I think my preference would be to go with option 1 because:
We could make these "baked in styles" into a mixin used by notifications and error summary to reduce duplication in scss. If later on we found that the automatically applied styles were interfering with what some teams were trying to do (ie. some really custom styles) we could consider introducing a modifier class (eg. |
Thinking mostly about maintainability and 'BEMness', I think I'm leaning towards either option 2b or 3. Although option 1 follows the precedent set by the error summary, I think it breaks from the conventions of BEM. I think the point around styles being applied automatically making them easier to use is true, but is also true for many other parts of the codebase where we do not currently break from BEM – I can't see any good reason why we should give the notification banner 'special treatment'. I think the tradeoffs between simplicity of use and maintainability were already considered when we adopted BEM. Option 4 seems to violate BEM's open/closed principle because it modifies the styles of the link just by them being in a different context. Option 1 has a specificity of 11, and options 2a and 4 have a specificity of 20 which means that for example a Options 2b and 3 both have specificities of 10, and so how they interact with another link modifier (and the govuk-link class) will depend on where they appear in the source order. However, the 'conflict' exists between classes on the same element (rather than a conflict between a modifier on an element and a class on that element's parent), and so it seems to work logically. |
External view: I'd probably go with 2 (slight preference to for variant The design system is already quite strong on BEM-ey styles, so I think it follows a similar pattern for this to have each element styled. |
@36degrees @hannalaakso Thanks for your comments everyone! It sounds like there’s a preference for either Option 2 or 3. I think I’m more tempted towards Option 2 (adding a I’ve prototyped what Option 2(b) might look like (using the error-summary, but only because it’s similar to the notification banner) @hannalaakso How does this sound to you, as you previously said you were leaning towards Option 1? |
@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. |
Going to go with Option 2(b) for now. If, for some reason, that doesn't work out or we think might cause some issues, it's probably worth revisiting Option 2(a), especially given this guidance: http://getbem.com/faq/#block-modifier-affects-elements |
Styling for notification banner will be done as part of #1981 |
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 |
What
Links in the error summary are red, because we target them in the component CSS:
govuk-frontend/src/govuk/components/error-summary/_index.scss
Lines 39 to 53 in 2b7a162
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:
govuk-notification-banner__link govuk-notification-banner__link--error
)govuk-link govuk-link--error
)The text was updated successfully, but these errors were encountered: