[2.x] feat: setting to force a FontAwesome icon style forum-wide - #4868
Merged
Conversation
Adds fontawesome_forced_style (default empty = no behavior change) to the FontAwesome section of the admin Advanced page. When set — e.g. 'fa-duotone fa-light' or 'fa-regular' — every icon rendered through the Icon component swaps its declared style classes for the configured one. Both syntaxes are recognized for every family (fas/fa-solid, far/fa-regular, ..., sharp variants, bare fa), via a closed style-class list: icon names (fa-lightbulb) and utility classes (fa-fw, fa-spin) also start with fa- and must pass through untouched. Brand icons are never rewritten — their glyphs only exist in the brands family. A noStyleOverride prop on Icon is the per-icon escape hatch for icons whose style IS their meaning (solid vs regular star for starred state). Non-string names pass through instead of throwing mid-render. The forum attribute only ships when the feature is on. tags' tagIcon helper now renders through the Icon component so tag icons — the most visible icon surface — honor the forced style too. Input.less pins position on prefix icons with !important, matching the file's existing FA-cascade workarounds: FA's duotone CSS sets position: relative on the icon element after our equal-specificity rule, which popped the search icon out of its input.
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request
Adds a Forced Icon Style setting (
fontawesome_forced_style, default empty = zero behavior change) to the FontAwesome section of the admin Advanced page. When set — e.g.fa-duotone fa-light, or simplyfa-regular— every icon rendered through theIconcomponent swaps its declared style classes for the configured one, giving forums with FontAwesome Pro a uniform icon style without forking extensions.fas/fa-solid,far/fa-regular, light/thin/duotone, the sharp variants, barefa). Deliberately not pattern-based: icon names (fa-lightbulb) and utility classes (fa-fw,fa-spin,fa-2x) also start withfa-and pass through untouched.noStyleOverrideprop onIconis the per-icon escape hatch, for icons whose style is their meaning (the solid vs regular star conveying starred state). Stripped before the DOM spread, pinned by test.visible()guard), and non-string icon names pass through instead of throwing mid-render (anIconwithout a name previously took down the whole mithril tree during live testing — now pinned).tagIconhelper renders throughIcon— previously it built<i>directly, so the tag sidebar (the most visible icon surface on most forums) bypassed the setting entirely.Input.lessfix found during live testing: FA's duotone CSS setsposition: relativeon the icon element itself (for its two-glyph::afterlayering) and loads after our stylesheet at equal specificity — popping the search box's prefix icon out of the input into normal flow. Pinningposition: absolute !importantfollows the exact pattern that block already documents for FA Kit's injectedwidth/displaystyles, and duotone renders correctly on any non-static position.The style must be available in the forum's configured icon source — most styles need FontAwesome Pro; the setting's help text says so.
Reviewers should focus on
applyIconStyle.ts(22 table-driven unit tests: every family in both syntaxes, sharp compounds replaced atomically, brands exemption,fa-lightbulb-style false positives, utility passthrough, duplicate-style collapse, non-string names).Iconcomponent tests: set/unset behavior, brands,noStyleOverride(including that it doesn't leak as a DOM attribute).fa-duotone fa-lightandfa-light: 117/122 icons rewritten on the index page, brands intact, clean console, search box intact.Confirmed
yarn jest), typings check passes.composer test).