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

Fix broken icons #1768

Merged
merged 2 commits into from
Aug 9, 2024
Merged

Fix broken icons #1768

merged 2 commits into from
Aug 9, 2024

Conversation

andysellick
Copy link
Contributor

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What / why

  • fixes broken icons across the site
  • icons are glyphicons from bootstrap, which are included as part of that dependency and can't be directly modified
  • problem is caused by the compiled Sass not being able to find and download the icon font files e.g. https://content-tagger.publishing.service.gov.uk/assets/content-tagger/bootstrap/glyphicons-halflings-regular.eot
  • this appears to be because the syntax in bootstrap for defining these files uses url(font-path(path)) which doesn't seem to work anymore, could be related to the recent dart-sass migration but unclear
  • as a workaround have copied the font-face declaration from the bootstrap CSS into our own, and replaced the above with url(path), which works
  • this occurs after the bootstrap declaration, overriding it and allowing the icon font file to be found and loaded correctly

Visual changes

Before
Screenshot 2024-08-08 at 16 12 33

After
Screenshot 2024-08-08 at 16 12 40

Trello card: https://trello.com/c/gW2NW1sB/239-fix-sass-compilation-warnings

- fixes broken icons across the site
- icons are glyphicons from bootstrap, which are included as part of that dependency and can't be directly modified
- problem is caused by the compiled Sass not being able to find and download the icon font files e.g. https://content-tagger.publishing.service.gov.uk/assets/content-tagger/bootstrap/glyphicons-halflings-regular.eot
- this appears to be because the syntax in bootstrap for defining these files uses `url(font-path(path))` which doesn't seem to work anymore, could be related to the recent dart-sass migration but unclear
- as a workaround have copied the font-face declaration from the bootstrap CSS into our own, and replaced the above with `url(path)`, which works
- this occurs after the bootstrap declaration, overriding it and allowing the icon font file to be found and loaded correctly
@andysellick andysellick marked this pull request as ready for review August 8, 2024 15:31
Copy link
Contributor

@mtaylorgds mtaylorgds left a comment

Choose a reason for hiding this comment

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

Looking at integration, this seems to have fixed some of the icons, but not all of them. For example looking at this page I can see that the double-headed arrow on the right of the drop down now appears, but the X on the left hand side still does not:
image

@andysellick andysellick force-pushed the fix-icons branch 2 times, most recently from 3685e47 to a4b6a86 Compare August 9, 2024 09:26
- these icons appear on the edit a page page and should be on the left of things that can be added or removed from a page
- can't be fixed by the previous change as this isn't a glyphicon, for some reason, is part of a dependency so can't directly modify the now not-compiling-in-dart-sass image page
- easiest thing is to switch to a glyphicon instead
- adding some custom styles to position it properly, have to make it this specific as there's an override to float all glyphicons in this element to the right, where there's already an icon
- also adding a JS class for the JavaScript hook
@andysellick
Copy link
Contributor Author

Think I've fixed all the icons now. Unfortunately they're mostly in external dependencies, which aren't fully compatible with the new dart-sass compilation, meaning we can't access that code to fix it. I've had to add some unfortunately quite specific overrides in our our Sass, the problem is around background images originally written using image-url instead of url.

Copy link
Contributor

@mtaylorgds mtaylorgds left a comment

Choose a reason for hiding this comment

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

LGTM—great work figuring this out!

@andysellick andysellick merged commit 57f815e into main Aug 9, 2024
10 checks passed
@andysellick andysellick deleted the fix-icons branch August 9, 2024 10:14
andysellick added a commit to alphagov/transition that referenced this pull request Aug 12, 2024
- relying upon glyphicons as part of bootstrap, but the Sass for that doesn't compile properly in dart-sass because it uses `url(font-path(path))`
- instead copy the font-face declaration from bootstrap into our code, overridding the original with this one, which fixes the icon paths and the icons
- see similar problem fixed in content-tagger: alphagov/content-tagger#1768
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.

2 participants