Skip to content

[WIP] Standardize FontAwesome usage #20334

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

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

dannon
Copy link
Member

@dannon dannon commented May 22, 2025

Replace the string-based FontAwesome library approach with direct SVG icon imports for better tree-shaking and type safety.

  • Better tree-shaking (only used icons get bundled)
  • Type safety improvements
  • Reduced global state pollution
  • More explicit dependencies

Changes:

Removed library.add() calls: Eliminated all library.add() statements that were registering icons globally
Removed library imports: Removed import { library } from "@fortawesome/fontawesome-svg-core"
Updated icon usage patterns: Changed from string-based icon references to direct icon object references

Before:

  import { library } from "@fortawesome/fontawesome-svg-core";
  import { faCopy } from "@fortawesome/free-regular-svg-icons";
  library.add(faCopy);

  // Template usage:
  <FontAwesomeIcon icon="copy" />
  // or
  <FontAwesomeIcon :icon="['far', 'copy']" />

After:

  import { faCopy } from "@fortawesome/free-regular-svg-icons";

  // Template usage:
  <FontAwesomeIcon :icon="faCopy" />

The icon plugin/mixin are still up in the air. I could see pushing it all through a GIcon if we wanted, instead of FontAwesome directly, and can make that changes. This first standardization pass is important though, either way, just to get it all aligned.

@dannon
Copy link
Member Author

dannon commented May 22, 2025

There are a few remaining instances and some linting to fix, but I'll keep rebasing into this so we have a clear cutover changeset.

@dannon dannon force-pushed the fontawesome-standardization branch from 2d225bc to 65f0d92 Compare May 22, 2025 13:38
@dannon dannon force-pushed the fontawesome-standardization branch from 65f0d92 to d057818 Compare May 22, 2025 13:47

Choose a reason for hiding this comment

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

With removing the library function, I would be in favor of also removing this file. I feel like it's an ambiguous abstraction, that makes it harder to trace the actual icon. But maybe there's an upside I'm missing

Copy link
Member Author

@dannon dannon May 22, 2025

Choose a reason for hiding this comment

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

@ElectronicBlueberry That's what I was thinking, too, 👍

(mentioned above, the only question is on whether we want a GIcon or something as a compatibility interface between Galaxy and Icons in case we need/want to change down the road. But since we're locally importing a slew of direct SVGs from fontawesome anyway, I don't see a benefit here.)

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

Successfully merging this pull request may close these issues.

2 participants