Indicator style class simplification project: Prefer `.blockIndicator` for styling block indicators

Indicators
- in a perfect world each indicator is composed of 2 classes that
  combine to indicate how it should display.
- one to indicate whether it is a block or a inline indicator
- one to indicate what colour and icons it should halve
- in practice there are multiple classes that indicate these things
  and a few indicators that only have one class to serve both purposes
**********************************************************************

Based on that, it seems like the CSS classes .blockIndicator and .inlineIndicator should be used.


I’ve begun work on simplifying the block indicator classes so that the indicator type is determined using only the .blockIndicator and .inlineIndicator (and .indicatorInHeadline, which has special handling) classes.

The GitHub PRs: (merged; awaiting deployment)

See also:

I’m sorry, can you be more specific? What do you mean by “indicator” in this context? And what’s the reason why the change is useful?

Indicator refers to the styled blocks which are created by the {{SeeComptTable}}, {{Deprecated_Header}}, {{Non-standard_Header}} and similar macros, or the .note and .warning CSS classes.

Example can be seen on the MDN page template pages:

The advantage of this is that it will allow simplifying the CSS selectors needed for styling the block indicators, as there will be just one .blockIndicator (and .note and .warning), instead of the current mishmash of CSS classes used to apply the block indicator style.

I’m going to try to explain what @exe-boss is trying to do here, as best as I can understand it, so that a front-end dev, like @schalkneethling or @hobinjk can review it if they think it is important.

MDN has several cases where a banner is displayed on a page, such as the Obsolete banner on Web/Events/chargingcharge:

(I noticed the broken font, and opened bug 1496826).

This banner is added by the macro {{obsolete_header}}, which calls {{obsoleteGeneric}}, which injects a <div> with the three classes overheadIndicator, obsolete, and obsoleteHeader. overheadIndicater is used in many other macros, such as {{draft}}, used on How to find information in specifications:

It uses the class overheadIndicator and draft.

Back in August 2015, @Stephanie_Hobson noticed a lot of CSS reinventing banners with slight variations, and brought the code together in consistent styles in PR 3417, along with a page demonstrating all the headers. It also demonstrates the state of macros in 2015 - a lot has changed!

This was a big improvement, and was when this comment was added, which still lives in /kuma/static/styles/components/wiki/indicators.scss:

/*
Indicators
- in a perfect world each indicator is composed of 2 classes that
  combine to indicate how it should display.
- one to indicate whether it is a block or a inline indicator
- one to indicate what colour and icons it should halve
- in practice there are multiple classes that indicate these things
  and a few indicators that only have one class to serve both purposes
********************************************************************** */

This file shows all the classes which implement banner-like behaviour, such as the class note, used by {{NoteStart}}, and the class warning, used by {{WarningStart}}, both on /Mozilla/Tech/XUL/Attribute/buttons:

This page shows the issue that first caught @exe-boss’s attention. When you use a banner, you’d like some whitespace between the banner and the surrounding content. The exception is when two banners are displayed together. In this case, it is more pleasing to “snug” the two together, removing the whitespace. Because there are multiple classes that implement banners, the CSS rule that implements banner snugging is long and complex and probably doesn’t cover all the cases.

@exe-boss attempted to make this better by using the CSS psuedo-class:matches in PR 4884, and used PostCSS to compile a compatible CSS rule for browsers that don’t support :matches. We can’t use PostCSS yet, because we’re using django-pipeline (bug 1366868), so I merged a partial solution in PR 4958, which we had to amend in PR 4961.

Thus began @exe-boss’s crusade to simplify this corner of MDN design.

Rather than pick one of existing classes, @exe-boss is picking a new class, blockIndicator, to represent a banner-like indicator that stretches across the content. A similar class, inlineIndicator, is used for indicators that don’t span the content, like {{deprecated_inline(“gecko1.9”)} on Mozilla/Tech/XUL/Method/showPopup:

The idea, like the comment says, is that two classes will be used for these “indicators”:

  • A structure class, like blockIndicator, inlineIndicator or indicatorInHeadline, which will be used for the skeleton, and for snugging rules,
  • A display class, like obsolete or deprecated, that will specify the color, icon, and “clothing” of the indicator.

The problem is that this is a priority for no one on the MDN team, as far as I can see. I’d like to focus on fixing the asset pipeline, so we can start using PostCSS. Instead, I tried to review some CSS PRs and failed, and now I’m trying to explain these PRs I’m not going to review. I don’t use my time well.

3 Likes

It may be useful to use the class name index to find affected pages. For example, this returns the 2516 pages using the class overheadIndicator:

https://developer.mozilla.org/en-US/search?css_classnames=overheadIndicator

Another useful search is GitHub’s repository search (rendered as a banner here):

And finally the macro dashboard gives an easy interface to the kumascript macros index:

https://developer.mozilla.org/en-US/dashboards/macros

Does that count represent pages which use class="overheadIndicator" in the source code, or does it include any pages which use any current macro which outputs a block indicator using the overheadIndicator class? (if it’s the latter, then that number will go down by a lot after KumaScript PR #830 is merged and pages are re‑rendered).

Does that count represent pages which use class="overheadIndicator" in the source code, or does it include any pages which use any current macro which outputs a block indicator using the overheadIndicator class? (if it’s the latter, then that number will go down by a lot after KumaScript PR #830 is merged.

It is the classes on the page after KumaScript macros have been rendered, so it includes when class="overheadIndicator" was in the source and when it came from a macro. Pages are re-rendered when they are edited or a force-refresh is requested by a logged in user.

1 Like

Update: @schalkneethling has now approved the PRs and this is ready for merging.

I have mostly tested pages that uses the macros that has been changed. I also tested the same pages with the style changes in Kuma but, without the macro changes. There does not seem to be any major breakage I can find, but I am doing additional testing to be as sure as I can be.

As mentioned by @fscholz, there will be a space of time while the page are being re-rendered where the new style changes will be there but the macros will still use the old classes.

2 Likes