nhsuk-frontend icon indicating copy to clipboard operation
nhsuk-frontend copied to clipboard

RFC: Combine `service` and `transactionalService` header options and remove layout modifiers

Open paulrobertlloyd opened this issue 1 year ago • 1 comments

Follow up to #996 and fixes #997

Description

Prior to any work on adding account links to the header, or refining its design, this PR aims to reduce the complexity of the component template by refactoring the different variants and reducing the number of different layout variants and associated modifiers in the markup and CSS.

[!Note] In general, the header component appears to have suffered from a sticking plaster approach to adding features, accumulating tactical fixes that over time have increased the complexity of the Nunjucks template, its public API, the markup and CSS.

Before adding account links, we should aim to simplify and fix what is already here.

This PR:

  • Removes the transactional boolean option and the transactionalService option. The component API now accepts organisation and service options, these being the 2 significant variants of the header. This means there are now only 2 sizes of NHS logo, of which only the organisation variant uses the smaller size.
  • Removes the following layout modifiers:
    • .nhsuk-header__logo--only
    • .nhsuk-header__transactional--logo
    • .nhsuk-header__link--service
    • ~~.nhsuk-header__search-no-nav~~ (fixed in #1046)
  • Removes the .nhsuk-header__content#content-header container
  • Removes the following transactional containers and styles:
    • .nhsuk-header__transactional-service-name
    • .nhsuk-header__transactional-service-name--link
  • Adds a new .nhsuk-header__service-link style
  • ~~Uses a single path NHS logo, allowing it to inherit link and focus styles~~ (broken out into #1047)
  • Fixes weird clipping that occurs around the hover and/or focus state on the NHS logo
  • ~~Fixes additional padding appearing at the bottom of the header when there is no navigation~~ (fixed in #1046)
  • Ensures style rules for the white variant only modify colour properties
  • Removes a number of media queries and uses flex layout a bit more – there’s a lot more that can be achieved using this approach, but tried not to go overboard!

Some of these changes can (and probably should) be pulled out into smaller, non-breaking PRs, if required.

Handling long service names

Here’s a preview of a header with both navigation, search and a long service name, which addresses #997:

280px

w280 |

280px (organisation)

w280-organisation

400px

w400

640px

w640

800px

w800

800px (organisation)

w800-organisation

1024px

w1024

I have added the text-wrap: balance to .nhsuk-header__service-link; this is a relatively new CSS value, but can be used as a progressive enhancement; the screenshots above show it being used, but if a browser doesn’t support this value, a (long) service name will break later in its title.

Logo focus styles

Before After
before-w800-logo-focus w800-logo-focus
before-w800-organisation-logo-focus w800-organisation-logo-focus

Checklist

paulrobertlloyd avatar Aug 23 '24 11:08 paulrobertlloyd