Skip to content
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

[SPIKE] Update favicons (v5) #4185

Closed
wants to merge 8 commits into from
Closed

[SPIKE] Update favicons (v5) #4185

wants to merge 8 commits into from

Conversation

querkmachine
Copy link
Member

@querkmachine querkmachine commented Sep 8, 2023

Provisionally update the favicons based on my thoughts in this comment (#4175 (comment)), implementing all except for the 'maskable' version of the Android icon, as that would likely require a unique graphical treatment to ensure legibility.

Warning

The graphical assets used in this PR are not final. The PR, whilst in draft, is intended to test changes to what icons we provide and how we implement them from a technical perspective. Final iconography will be produced as part of #4058.

Changes

  • Replaces icons using the St. Edward's Crown with equivalents using the Tudor Crown. These are not final assets, as described above.
  • Renames all of the icons to be largely agnostic to their usage, instead being named for the image's dimensions.
  • Changes the way the ICO favicon is referenced in HTML:
    • Fixes a potential issue with the sizes attribute where Chrome would always use the ICO even when an SVG favicon was available (sizes issue detailed here in section 2.3).
    • Changes rel="shortcut icon" to rel="icon". The shortcut keyword was only needed for supporting Internet Explorer 8 and earlier, which Frontend no longer does.
  • Removes apple-touch-icon sizes smaller than 180x180. These aren't used by Apple devices released in the last few years and lower resolution Apple devices can scale down the larger image automatically.
  • Adds an SVG favicon.
    • This favicon deviates from the .ico version by not containing the crown within a box, instead utilising the prefers-color-scheme CSS query to change the colour of the crown depending on the user's colour settings.
    • The removal of the containing box also allows the crown to be larger, as there's no need to provide padding around it.
  • Adds 192x192 PNG icon. This is most commonly used by Android devices.
  • Adds a 512x512 PNG icon. This is a bit of a future-proofing 'catch-all' unspecific to any specific device or OS, but present in case an icon larger than 192x192 is needed. This may also be used by macOS Sonoma.
  • Adds a manifest.json file listing all of the available PNG icon sizes.
  • Adds Jest tests for the icons and manifest file.

Screenshots

All of the below display the icons from this PR alongside the current favicon that GOV.UK serves to that browser, so that the differences between their appearance can be clearly seen,

Chrome 116, light system theme

SVG favicon.

Screenshot of two tabs in Chrome, but light

Chrome 116, dark system theme

SVG favicon.

Screenshot of two tabs in Chrome, but dark

Edge 116, light system theme

SVG favicon.

Screenshot of two tabs in Edge, but light

Edge 116, dark system theme

SVG favicon.

Screenshot of two tabs in Edge, but dark

Firefox 115, light system theme

SVG favicon.

Screenshot of two tabs in Firefox, but light

Firefox 115, dark system theme

SVG favicon.

Screenshot of two tabs in Firefox, but dark

Safari 16.6 on macOS, light system theme with separate tab bar

Safari mask icon.

Screenshot of two tabs in Safari, but light

Safari 16.6 on macOS, dark system theme with separate tab bar

Safari mask icon.

A white background is added to the icon as Safari surmises that the configured mask colour is too dark to be visible against the dark system theme.

Screenshot of two tabs in Safari, but dark

Safari 16.6 on macOS, compact tab bar

Safari mask icon.

When Safari is configured to use the compact tab bar layout, the tab bar takes on a colour from the current page (either automatically, or the one defined by theme-color meta tag).

As there is no guarantee that the favicon will have contrast against those colours, a white background is added around it.

Screenshot of two tabs in Safari, but in rounded boxes against a purple background

Internet Explorer 11

ICO favicon. Captured through Browserstack, which may have distorted the appearance of the icons due to video compression.

Screenshot of two tabs in Internet Explorer 11

Safari 17.0 (beta) on iOS, tab switcher

ICO favicon.

Screenshot of the tab switcher on an iPhone, showing previews of two webpages with their favicons and page titles written below them

iOS 17.0 (beta) home screen

Apple touch icons.

Two app-like icons on an iPhone homescreen, the first renamed 'v4' and the second named 'v5'

macOS 14.0 (beta) dock

Uses the largest icon defined in the manifest file, if any are defined. If not, falls back to using apple-touch-icon. If neither are available, the favicon is used. If none of them are available, macOS generates an icon using the first letter of the page's title with a background colour.

Two app-like icons on the macOS dock

Android 13

Android 192 PNG favicon.

Both the homescreen and Android version of Chrome use the Android icon defined in the manifest. I couldn't get screenshots of this because the device security policy disallowed it, but they work.

The theme-color HTML attribute still works too, and has not been affected by the addition of a manifest file.

@querkmachine querkmachine self-assigned this Sep 8, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 8, 2023 14:01 Inactive
@github-actions
Copy link

github-actions bot commented Sep 8, 2023

📋 Stats

File sizes

File Size
dist/govuk-frontend-4.6.0.min.css 118.07 KiB
dist/govuk-frontend-4.6.0.min.js 47.1 KiB
dist/govuk-frontend-ie8-4.6.0.min.css 79.27 KiB
packages/govuk-frontend/dist/govuk/all.bundle.js 77.65 KiB
packages/govuk-frontend/dist/govuk/all.bundle.mjs 72.94 KiB
packages/govuk-frontend/dist/govuk/all.mjs 3.84 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend-component.mjs 359 B
packages/govuk-frontend/dist/govuk/govuk-frontend.min.css 120.49 KiB
packages/govuk-frontend/dist/govuk/govuk-frontend.min.js 37.89 KiB
packages/govuk-frontend/dist/govuk/i18n.mjs 5.83 KiB

Modules

File Size
all.mjs 69.04 KiB
components/accordion/accordion.mjs 21.91 KiB
components/button/button.mjs 4.71 KiB
components/character-count/character-count.mjs 22.03 KiB
components/checkboxes/checkboxes.mjs 5.69 KiB
components/error-summary/error-summary.mjs 6.01 KiB
components/exit-this-page/exit-this-page.mjs 16.61 KiB
components/header/header.mjs 3.84 KiB
components/notification-banner/notification-banner.mjs 4.55 KiB
components/radios/radios.mjs 4.68 KiB
components/skip-link/skip-link.mjs 3.74 KiB
components/tabs/tabs.mjs 9.32 KiB

View stats and visualisations on the review app


Action run for e9d0dd3

@github-actions

This comment was marked as resolved.

3 similar comments
@github-actions

This comment was marked as duplicate.

@github-actions

This comment was marked as duplicate.

@github-actions

This comment was marked as duplicate.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 11, 2023 08:42 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 11, 2023 10:07 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 11, 2023 13:37 Inactive
Copy link
Contributor

@colinrotherham colinrotherham Sep 13, 2023

Choose a reason for hiding this comment

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

Good to chuck away the alpha channel from these PNGs or try limiting to 256 colours not full sRGB

ImageOptim will nearly save 70% on this big one, down to just over 5KB

Copy link
Member Author

Choose a reason for hiding this comment

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

As these aren't the final assets, I'm not gonna do this just yet, but optimisation is definitely on the cards for later. ✌️

@@ -0,0 +1,19 @@
{
"icons": [
Copy link
Contributor

@colinrotherham colinrotherham Sep 13, 2023

Choose a reason for hiding this comment

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

How much do we need to match these up with template.njk?

E.g. We've not got a 48x48 size here but maybe that's fine as it's an *.ico

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think they practically need to match at all. If the only reason we're providing a manifest is for Android devices, we could get away with only defining the 192x192 image.

I included the 180x180 and 512x512 as options in case a requesting service or device might find them useful, as we already have them on hand, and to provide a little bit of futureproofing in case iOS does start using the manifest (as we're seeing with macOS Sonoma), or some other usage comes along that prefers an even larger graphic to be available.

Copy link
Contributor

Choose a reason for hiding this comment

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

…provide a little bit of futureproofing…

Yeah for this bit

i.e. For future proofing, and as a safety net, should we match template.njk to prepare for the day other browsers also ship support for manifest.json?

Making sure all the familiar sizes they support are still in there

I've double checked the What’s New in Safari documentation to find when manifest support was added (Safari 11.1) but they default to apple-touch-icon in the HTML

Future browsers might default to icons in the manifest instead 🤷‍♂️

Copy link
Contributor

@colinrotherham colinrotherham Sep 13, 2023

Choose a reason for hiding this comment

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

Sizes wise, we're all set for the Google docs for Chromium browsers:

For Chromium, you must provide at least a 192x192 pixel icon, and a 512x512 pixel icon. If only those two icon sizes are provided

But given their examples, we likely want an SVG touch icon too?

Chromium-based browsers also support SVG icons which can be scaled arbitrarily without looking pixelated and that support advanced features like responsiveness to prefers-color-scheme, with the caveat that the icons do not update live, but remain in the state they were in at install time.

Suggested change
"icons": [
"icons": [
{
"src": "/images/govuk-icon.svg",
"type": "image/svg+xml",
"sizes": "512x512"
},

Copy link
Contributor

Choose a reason for hiding this comment

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

To add, Apple's documentation has widened since alphagov/govuk_template#300

They suggest 1024×1024 for auto scaling, but for exact pixel sizes they list:

iPhone

  • 180×180 @3x — Home screen
  • 120×120 @2x — Home screen

iPad

  • 167×167 @1x — Home screen (iPad Pro)
  • 152×152 @1x — Home screen (iPad, iPad mini)

Mac

  • 512×512 @1x — Desktop, Dock
  • 1024×1024 @2x — Desktop, Dock

Copy link
Member Author

Choose a reason for hiding this comment

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

We could supply all of those if we really want to, it's just not really necessary.

I've stuck with a single 180x180 that seems to be the sole size used in many modern implementations and recommended by folks dedicated enough to write about the subject.1234

I'm not too concerned with re-defining every single icon from the template in the manifest either. The backwards-compatible nature of the web means that even if Safari, et al. update to prefer the manifest, they're unlikely to only use the manifest, and letting them choose the icon that fits best is why we specify size information in the first place.

Footnotes

  1. https://www.leereamsnyder.com/blog/favicons-in-2021

  2. https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs

  3. https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7

  4. realfavicongenerator.net changed to only supply a single 180x180 icon way back in 2016 — https://github.com/RealFaviconGenerator/realfavicongenerator/issues/211

Copy link
Contributor

@colinrotherham colinrotherham Sep 13, 2023

Choose a reason for hiding this comment

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

There's only one size missing if we say the desktop sizes are out of scope?

  • 120×120 @2x — Home screen

Maybe add the SVG though? #4185 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've opted to relent and add all of the icons to the manifest. Seemingly this isn't unexpected (MDN has examples that include even the .ico being defined within the manifest), but I'll be surprised if at least some of these aren't superfluous, being unused by any current browser/device.

I'm not sure whether the current SVG supplied is really suitable for the intended use cases either. It's not the same design as the PNGs offered and doesn't come with any included margins, so if it were to be selected for an app icon on a device it may end up looking a bit weird. Something to test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Removes apple-touch-icon sizes smaller than 180x180. These aren't used by Apple devices released in the last few years and lower resolution Apple devices can scale down the larger image automatically.

Based on your findings, wondering if the 192px icon is enough to delete this one?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is more of a design preference question. We have 180x180 for iOS because their icons are 60x60 dips, rendered on all recent devices at 3x resolution. We can be confident that a 180x180 image will scale perfectly and remain crisp.

We're providing a 192x192 image for Android for the same reasons, except their icons are rendered at 64x64 dips.

I couldn't see any evidence that either functionally needs the icons to be those sizes—we could toss a 3000x3000 monster at both and be done with it—but supplying the sizes that look the best on each feels like the nicer thing to do.

Copy link
Contributor

@colinrotherham colinrotherham Sep 13, 2023

Choose a reason for hiding this comment

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

Thanks @querkmachine makes total sense to keep it

To double check, I've reviewed the Apple documentation in #4185 (comment) and found a few gaps

Mainly 2018, 2019 devices (iPhone X) at @2x or the previous non-retina iPad Pro and iPad mini

Seems fair to follow what we did back in 2017 and review them all again

@colinrotherham
Copy link
Contributor

@querkmachine If you give this branch a rebase, we fixed the Rollup build failures in #4208

- Updates favicons to use the new Tudor crown.
- Removes apple-touch-icon sizes that are no longer in common use.
- Adds SVG favicon.
- Adds manifest file and icons for Android devices.

The assets used in this commit are not final and are subject to change.
We anticipate that some servers may not be configured to correctly serve the .webmanifest content-type, so we're gonna stick with the (seemingly now legacy) .json
extension for now.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 28, 2023 10:51 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 28, 2023 17:07 Inactive
The `maskable` keyword tells Android devices that the icon has been designed with a circular, central safe area, and that Android launchers can
safely crop the edges of the icon instead of shrinking the icon down:
https://css-tricks.com/maskable-icons-android-adaptive-icons-for-your-pwa/

Despite the name, these are not 'masks' in the same way as the Safari icon. The Safari icon is an alpha mask, which is indicated using the
`monochrome` keyword instead.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-4185 September 29, 2023 11:00 Inactive
@querkmachine querkmachine changed the title [WIP] Update favicons [SPIKE] Update favicons (v5) Sep 29, 2023
@querkmachine
Copy link
Member Author

Closing this spike for now as I think it's accomplished what it needed to. A new PR has been created for the implementation of new icon formats using the Tudor crown: #4354

Depending on the scheduling of the v5 release and GOV.UK comms, we may also have a 'transitional' PR that implements the new formats but continues using the St. Edward's crown (but that doesn't exist yet!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants