-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use embedded Font Awesome SVG icons #2484
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
Conversation
Co-authored-by: Michael Howell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it's a good idea to try to work around this, but existing books are going to be written to the old fontawesome version.
Co-authored-by: Michael Howell <[email protected]>
Would it be possible to get a review on this PR? I don't want it to lose momentum and have to deal with conflicts again down the road. |
fa::svg(type_, &icon).or_else(|_| fa::svg(fa::Type::Brands, &icon)) | ||
{ | ||
format!( | ||
r#"<span{before}class="fa-svg{other_classes}"{after}>{svg}</span>"#, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better instead of generating the SVG in the DOM directly to rely on CSS instead? It brings multiple advantages:
- Smaller DOM
- If the same SVG is used more than once, it's not duplicated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't want to build a giant stylesheet with every icon in it unless we have to. That file would be immense, and most of it wouldn't get used. But mdBook exposes an API that lets the user include any icon they want, so we'd have to?
Besides, fontawesome SVGs almost all have a single <path>
in them. The DOM is tiny.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FontAwesome is a font. Meaning that as long as we have the font, we have easily use their icons without needing to declare them ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FontAwesome is a font. Meaning that as long as we have the font, we have easily use their icons without needing to declare them ourselves.
But then you must include the entirety of the font (which is quite large iirc), unless you want to deal with subsetting? And then that is a whole other ordeal.
Overall I think it's a very good idea, but unless I'm wrong, you're inlining the SVGs directly into the HTML, and I don't think this is the right approach. If you use the CSS and font provided by font awesome, then no need for this. |
CSS is a valid way to go about the inclusion of icons, and could be done in the future, but it should not be a blocker for this pull request to land. Much of the point of this pull request is to avoid the 77kb of fonts that must be loaded from FontAwesome, and to avoid the other downsides as mentioned in #1330 (comment). |
Then please inline the SVG into the CSS to prevent duplication in HTML. |
Incorporates the changes from #1330, brings up to date with repository and adds various fixes & improvements.