thepensionsregulator / govuk-frontend-aspnetcore-extensions

Adds client-side validation, additional components and editing in Umbraco to https://github.com/gunndabad/govuk-frontend-aspnetcore
MIT License
16 stars 1 forks source link

Support headings beyond h3, and starting headings from xl instead of large #350

Closed sussexrick closed 2 weeks ago

sussexrick commented 1 month ago

What problem does this solve?

In v6.0.0 we only style HTML heading levels 1, 2 and 3. Heading levels 4, 5 and 6 are rendered with default browser styles, typically Times New Roman. You also can't format a heading as 4, 5 or 6 in the Umbraco rich text editor. For upcoming work we need to support deeper nesting of headings.

The GOV.UK Design System page on headings says:

"For a question page, or pages with long headings, follow the usual hierarchy of heading levels and styles associated with them. For example, govuk-heading-l for an <h1>, followed by govuk-heading-m for an <h2> and so on."

This is what we support already. It goes on to say:

"In rare cases, you might want to alter how you use the headings hierarchy to achieve a better visual balance. ... If your page has lots of long form content, start with govuk-heading-xl for an <h1>, govuk-heading-l for an <h2>, and so on."

In v6.0.0 we don't support any of this flexibility. Headings always start with govuk-heading-l.

Constraints and considerations

Proposed approach

In the absence of an agreed TPR standard, keep the styles we have now for h1, h2 and h3 to make this a non-breaking change, and otherwise follow the GOV.UK Design System.

Accept that we may need to revisit this for TPR styles, but know that with the ability to apply all heading levels and use classes at every level we can adjust them however we choose to at a later date. Heading levels 4, 5 and 6 currently look the same but they are semantically different and correct, and we can adjust the appearance later if desired.

Implementation

Limitations

Any text you enter in an Umbraco rich text editor is formatted automatically with GOV.UK Frontend classes. This happens automatically for any rich text value using a PropertyValueConverter, so consuming apps cannot forget. However a PropertyValueConverter has no access to the current page, so it can't read and apply the page setting. Instead it always applies the default setting starting with govuk-heading-l.

However, this only affects headings pasted into the rich text editor with no class or the wrong class, and these can easily be corrected by selecting the correct class from the style dropdown. If you are formatting text from scratch in the editor, the user applies the class when they select the heading level.

Documentation

Updated example apps

Heading styles starting with govuk-heading-l (unchanged)

Heading levels 1-3 starting with govuk-heading-l

Heading styles starting with govuk-heading-xl (new)

Heading levels 1-6 starting with govuk-heading-xl

Work item reference

AB#204479