Skip to content

SVG icon component#64

Merged
kirkaracha merged 1 commit intomainfrom
svg-icon-collector
Jul 5, 2025
Merged

SVG icon component#64
kirkaracha merged 1 commit intomainfrom
svg-icon-collector

Conversation

@wrose504
Copy link
Collaborator

@wrose504 wrose504 commented Jul 4, 2025

The site is using SVG icons embedded via img tags. These have the advantage of making it simple to cache the resources and support alt and title attributes, but come with the major drawback that the SVG is rendered independent of the page styles. This means that the icon colors do not match the element in which they appear:

svg in img

If we instead embed the SVGs directly in the HTML, then they can be styled, and can pick up the currentColor, allowing them to match other page elements.

svg in html

The drawbacks of embedding the SVGs like this are that it becomes more difficult to specify the equivalent of alt text and title per-instance, and to avoid reproducing the whole SVG each time we want to use it. To work around both issues, this PR adds components that can convert an existing SVG into a Blade template that can be rendered to yield the SVG with optional aria-label and aria-describedby attributes, a title element and where the drawing primitives are captured as a reusable symbol, so that subsequent references can just use the symbol emitted earlier in the page.

@wrose504 wrose504 requested a review from kirkaracha July 4, 2025 10:27
@wrose504 wrose504 self-assigned this Jul 4, 2025
@wrose504 wrose504 force-pushed the svg-icon-collector branch from 000c9f7 to 1e422f9 Compare July 4, 2025 10:36
@kirkaracha
Copy link
Collaborator

Wow, nice work!

@kirkaracha kirkaracha merged commit d6c5ca4 into main Jul 5, 2025
1 check passed
@wrose504 wrose504 deleted the svg-icon-collector branch July 16, 2025 02:10
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