-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
refactor: import icons as svg files instead of using react components #6050
Conversation
@@ -67,6 +67,8 @@ | |||
|
|||
.expandSidebarButtonIcon { | |||
transform: rotate(0); | |||
/* todo: use variable */ | |||
color: #7a7a7a; |
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.
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.
any thoughts about this? we could actually remove this override and let control font color control how this icon looks
maybe we could use?
color: var(--ifm-menu-color);
or we just keep it and do this in separate PR, as style for this is not yet in infima
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 created issue for this in infima facebookincubator/infima#193
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
@Josh-Cena let me know if there is something else that i have to do in here |
packages/docusaurus-theme-classic/src/theme/NavbarItem/styles.module.css
Outdated
Show resolved
Hide resolved
I'm in favor of the current change. Just waiting for the input from @slorber |
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.
Thanks for working on this
This pr changes how svg files are stored in project and removes all css from them, this is first step to refactor how we import icons.
IMHO we should not do this in multiple steps, but in a single one, once we know exactly how we should handle the SVGs. This PR can serve as a POC to see if an approach is right.
This kind of change can be disruptive for our users with custom themes, and we should avoid doing 2 chances in 2 distinct releases when we can do only one.
The current approach is not good enough, the SVGs remain loaded through SVGR, converted to the same React components as before, and SVG markup is still duplicated in the final HTML
I don't know what is the best solution to this problem yet, just some ideas:
- Use
url('./icon.svg')
in CSS => this should use file-loader instead of SVGR due to usage in CSS - Force usage of inline file-loader in JS file and use with
<img>
tag?
I asked a question here, some proposed approaches might be interesting to explore: https://twitter.com/sebastienlorber/status/1466024866491080707
Using SVG defs and SVG use also seems interesting, preferably if we can somehow lazy-load those refs instead of having a global registry
packages/docusaurus-theme-classic/src/theme/Footer/styles.module.css
Outdated
Show resolved
Hide resolved
personally i do not like icons in css, as there is no way to easily style them/color outside of creating new one in my opinion sprites are way to go, i tested this change with https://github.com/JetBrains/svg-sprite-loader (or rather inspired version of it) and simple wrapper for react and it seem to work perfectly, i still can use: import arrow from './icons/arrow.svg';
return <arrow> if thats a case icons are added automatically, withotu change of api, only difference is that component returned by this import is: <svg viewBox="....">
<use xlink:href="#arrow" />
</svg> i could give it a try to implement it in non "mockup" version |
As long as they are one color icons, using |
509bf87
to
a67a647
Compare
This pr changes how svg files are stored in project and removes all css from them, this is first step to refactor how we import icons.
as we are using svgr to convert svg items to react components actual svg code stays the same
this may be considered a breaking change as icons do not contain styles anymore and consumers have to apply them when they are needed
related PR: #5865