Skip to content

Fix appearance of focused logo and service name in header#1361

Merged
anandamaryon1 merged 17 commits into
mainfrom
header-focused-logo-and-service-name
Jun 16, 2025
Merged

Fix appearance of focused logo and service name in header#1361
anandamaryon1 merged 17 commits into
mainfrom
header-focused-logo-and-service-name

Conversation

@paulrobertlloyd
Copy link
Copy Markdown
Contributor

@paulrobertlloyd paulrobertlloyd commented Jun 5, 2025

Description

Fixes #1369.

Reviewing the focused header states, a few issues become apparent:

  • The focused NHS logo looks broken, with the bottom shadow merging with the logo, and only the top part of the logo showing a yellow outline
  • A linked service name stretches the full width of the header

Note

The commentary below is out of date. I’m now using a different approach by adding a mixin to use for focusing images. See the updated fix described in #1361 (comment)

This PR fixes these issues by:

  • Incorporating padding into the NHS logo SVG (this ensures consistent rendering, and saves having to make multiple adjustments in CSS)
  • Removing the top yellow box shadow on the focused state for a linked service logo to ensure the yellow outline around the logo is evenly spaced
  • Adding hover and active background colour to a linked service logo (except for in the white header variant) – these match the blue/darker blue hover/active colours used by the search submit button
  • Ensuring the NHS logo is resized with the correct aspect ratio when resized for use alongside an organisation name
  • Updating the padding for the organisation name and descriptor to match that of the NHS logo

and finally:

  • Preventing a service name from growing to fill any remaining space in the header

Focused NHS logo

Before, focused:

Screenshot of default header before.

After, focused:

Screenshot of default header after, focused.

After, hover:

Screenshot of default header after, hover.

After, active:

Screenshot of default header after, active.

Focused organiaation logo

Before:

Screenshot of organisation white header before.

After:

Screenshot of organisation white header after.

Focused service name

Before:

Screenshot of header with focused service name before.

After:

Screenshot of header with focused service name after.

Checklist

@paulrobertlloyd paulrobertlloyd added 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) header labels Jun 5, 2025
@paulrobertlloyd paulrobertlloyd force-pushed the header-focused-logo-and-service-name branch from 602bb8b to 2875cbf Compare June 5, 2025 21:25
Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredible work 😮

I'm working odd hours tomorrow so had a look straight away!

Can I double check the logo padding inside the SVG?

It pushes the logo right/down a little bit—do we need to offset that?

@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

A few notes:

  • Adding padding to the NHS logo directly is one approach, downside being that when it is scaled down the padding decreases too… think we just about get away with it, but it does mean the padding is not guaranteed to always be 2px.
  • The focus ring for form elements (including the search input) is 4px, not 2px. However, 2px matches the space we’ve added inside navigation items. So… 🤷🏼‍♂️
  • The alternative approach I tried got complicated quickly, namely because it involves trying to override mixins for link/focus styles, in certain contexts only. Maybe there’s an approach where we lean on our good friend the pseudo element, and style that, independently of any link styles. Lots of different ways to skin this particular cat.

@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

paulrobertlloyd commented Jun 5, 2025

It pushes the logo right/down a little bit—do we need to offset that?

It does, this is more of an issue for the organisational logos perhaps than when we use the NHS logo on its own. Open to other approaches to fix this!

@colinrotherham
Copy link
Copy Markdown
Contributor

Would the GOV.UK Frontend @include govuk-link-image mixin help?

Have a look at the image links example with double box shadow:

Image links with double box shadow

@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

Ooooh, I’ll give it a try.

@paulrobertlloyd paulrobertlloyd force-pushed the header-focused-logo-and-service-name branch 2 times, most recently from 1d7da81 to de516b5 Compare June 5, 2025 23:03
@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

paulrobertlloyd commented Jun 5, 2025

Updated this PR to add a new @nhsuk-link-image mixin (copied over from GOV.UK Frontend). This simplifies things greatly, and no longer requires messing about with the SVG.

I’ve removed the hover and active styles from the NHS logo however, as it gets weird when this is combined with a service name.

New comparison images below.

Focused NHS logo

Before:

Screenshot of default header before.

After:

Screenshot of default header after.

Focused NHS logo and service name combined

Before:

Screenshot of combined header before.

After:

Screenshot of combined header after.

Focused NHS organisation header

No change, baring one pixel increase in gap between logo and organisation name (thus the updated visual regression images, now only 22 down from 72 in the initial PR!)

Before:

Screenshot of organisation header before.

After:

Screenshot of organisation header after.

Focused service name

This remains unchanged from the initial commit for this PR.

Before:

Screenshot of header with focused service name before.

After:

Screenshot of header with focused service name after.


I have also added some extra visual regression tests for the focused NHS/service name/organisation name link.

Comment thread packages/nhsuk-frontend/src/nhsuk/components/header/_index.scss
Copy link
Copy Markdown
Contributor

@frankieroberto frankieroberto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

There’s no hover state for the logo, do we think that’s ok? Currently (in production) there’s a dark blue border, although I’ve just noticed that this doesn’t work in Safari properly for some reason...

Screenshot 2025-06-06 at 13 07 27

@colinrotherham
Copy link
Copy Markdown
Contributor

Forgot to mention, we need :not(:active) on any focus styles (buttons included)

Until we align more with GOV.UK Frontend at least

@frankieroberto frankieroberto temporarily deployed to nhsuk-fonten-header-foc-squts5 June 9, 2025 11:56 Inactive
@colinrotherham colinrotherham force-pushed the header-focused-logo-and-service-name branch from de516b5 to d8b29f9 Compare June 9, 2025 14:30
@anandamaryon1 anandamaryon1 temporarily deployed to nhsuk-fronte-header-foc-kgt69h June 9, 2025 14:30 Inactive
@colinrotherham
Copy link
Copy Markdown
Contributor

I've fixed @include nhsuk-link-image being overridden in the white header

Think we need a design opinion on whether the "expanded focus box" should have a solid outline all around

@colinrotherham
Copy link
Copy Markdown
Contributor

Nice!

There’s no hover state for the logo, do we think that’s ok? Currently (in production) there’s a dark blue border, although I’ve just noticed that this doesn’t work in Safari properly for some reason...

Screenshot 2025-06-06 at 13 07 27

@frankieroberto I gave this a try by adding:

  &:hover,
  &:focus,
  &:active {
    .nhsuk-header__organisation-name,
    .nhsuk-header__organisation-name-descriptor,
    .nhsuk-header__service-name {
      color: inherit;
    }
  }
+
+ &:hover {
+   .nhsuk-header__logo {
+     outline: $nhsuk-focus-width solid transparent;
+     box-shadow: 0 0 0 4px #003d78;
+   }
+ }

Do you know where #003d78 comes from, or what we'd use for the white header?

See what you mean about the Safari :hover issue though

@anandamaryon1
Copy link
Copy Markdown
Contributor

Happy with the focus states, thanks for these @paulrobertlloyd

Seems a pity to drop the hover state, even though it was low-contrast. Could do a subtle colour or opacity change on hover, similar to buttons?

@anandamaryon1 anandamaryon1 had a problem deploying to nhsuk-frontend-pr-1361 June 11, 2025 15:00 Failure
@paulrobertlloyd paulrobertlloyd force-pushed the header-focused-logo-and-service-name branch from 55a462b to cd4b017 Compare June 11, 2025 15:01
@paulrobertlloyd paulrobertlloyd temporarily deployed to nhsuk-frontend-pr-1361 June 11, 2025 15:01 Inactive
@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

paulrobertlloyd commented Jun 11, 2025

Added a hover state that attempts to replicate the underline used in the service/organisation name. Some notes:

Combined logo and service name

Screenshot of logo and service name with hover.

Organisation name

Screenshot of organisation name with hover.

@colinrotherham colinrotherham force-pushed the header-focused-logo-and-service-name branch from 31cbf5c to 1d8fc5d Compare June 12, 2025 16:04
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1361 June 12, 2025 16:04 Inactive
@colinrotherham
Copy link
Copy Markdown
Contributor

Obviously @paulrobertlloyd found a brilliant workaround, but!

What if we use his same ::before workaround to stretch a border around the SVG?

Just pushed the old hover style back up, but feel free to drop the commit if we prefer the underline

Screenshot 2025-06-12 at 22 21 06

Screenshot 2025-06-12 at 22 20 42

@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1361 June 12, 2025 21:28 Inactive
@colinrotherham colinrotherham force-pushed the header-focused-logo-and-service-name branch from a9fe67f to 6e147fe Compare June 12, 2025 21:33
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1361 June 12, 2025 21:34 Inactive
@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

I tried to recreate the previous hover state originally once I figured out the work around, but then decided on the underline because it:

  1. is visually distinguishable (squint and you can see the underline whereas the dark border looks blurred)
  2. requires less CSS
  3. mimics the hover style used elsewhere in NHS frontend, but also mimics that used for the logo hover state on GOV.UK

@colinrotherham colinrotherham force-pushed the header-focused-logo-and-service-name branch from 6e147fe to 1d8fc5d Compare June 13, 2025 07:30
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1361 June 13, 2025 07:30 Inactive
@colinrotherham
Copy link
Copy Markdown
Contributor

No worries, it's gone. Like it never happened 😶

@sonarqubecloud
Copy link
Copy Markdown

@colinrotherham colinrotherham self-requested a review June 13, 2025 12:29
Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy for these hover/focus styles to go in @anandamaryon1?

Saw a thumbs up in #1361 (comment)

@paulrobertlloyd
Copy link
Copy Markdown
Contributor Author

All I’ll add is that, when the link underline stuff gets merged, we should update the line-weight for the logo hover to match.

Copy link
Copy Markdown
Contributor

@anandamaryon1 anandamaryon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff

@anandamaryon1 anandamaryon1 merged commit 7788c9d into main Jun 16, 2025
24 checks passed
@anandamaryon1 anandamaryon1 deleted the header-focused-logo-and-service-name branch June 16, 2025 09:48
colinrotherham pushed a commit that referenced this pull request Jun 23, 2025
Fix appearance of focused logo and service name in header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working the way it should (including incorrect wording in documentation) header

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NHS logo hover state not consistent in Safari

5 participants