-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Use @primer/octicons-react icons
#3227
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
Yeah not worth it then. If we make this change, it should make things easier during development, not harder/more verbose. Those classes are important because sometimes we just add sections and those classes just pick up the existing styles that GitHub put in place. The less CSS we have, the less we have to update when the move things by 3px. |
|
I created two PRs in upstream repos:
That would leave us with just problem 2, but we could still override the resulting attributes manually instead of passing custom props, like mentioned in the suggested <SomeIcon width={32} height={32} /> // <svg … width="32" height="32">
<SomeIcon size={32} /> // <svg … width="16" height="16" size="32">Now let's see if those PRs get merged 😄 |
|
Thank you for working on this! I hope primer/octicons#453 can be resolved soon |
|
Let's get this over with: I added a webpack loader to take care of this without having to wait forever for Octicons. Please check, speak now or forever hold your peace. I think the last step is to make sure that the icons are tree shaken: primer/octicons#405 |
@primer/octicons-react icons@primer/octicons-react icons
yakov116
left a comment
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.
|
@yakov116 that was due to the broken regex suggested by the linter, probably |
This reverts commit 8c7b457.
Given the file increase, the icons are definitely not being tree-shaken 😬 |
Hopefully the beautifier is enough for AMO reviewers. If not, I have to figure out which Terser compress flag actually tree shakes
|
| declare module 'react' { | ||
| const FC = (): JSX.Element => JSX.Element; | ||
| const React = {FC}; | ||
| export default React; |
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 think this isn't needed, right? Doesn't the module already export the correct types?
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.
In the react module, the return type of functional components is ReactElement, not JSX.Element (which is of course not actually true for us because not dom-chef is used instead of react). So when I remove the type declaration, I get errors like this:
source/github-widgets/notice-bar.tsx:17:6 - error TS2786: 'XIcon' cannot be used as a JSX component.
Its return type 'ReactElement<any, any> | null' is not a valid JSX element.
Type 'ReactElement<any, any>' is not assignable to type 'Element'.
17 <XIcon/>
|
Yessss 🙌 |
|
@yakov116 |
|
I tried everything I delete node modules, npm update etc |



I've tried to use the official
@primer/octicons-reactpackage, as suggested in #3147 (comment).I think this is not possible, at least not for now. (Or I am not skilled enough in TypeScript / JSX / React /
dom-chef.)The default props are not applied.
In particular the
sizeprop is missing, so all the icons are huge.Relevant code snippets in octicons-react/dist/index.esm.js:
There is no nice way to pass props to an icon function in
dom-chef, as<SomeIcon some-prop="foo"/>is compiled tocreateElement(SomeIcon(), {someProp: 'foo'})instead ofcreateElement(SomeIcon({someProp: 'foo'})).The icons don't have specific classes, i.e. we have to add the classes manually where we need it. E.g. this selector will break:
https://github.com/sindresorhus/refined-github/blob/4dabb8ce0539222101d39c5329857dafb88327b6/source/features/toggle-files-button.css#L11-L12
Nevertheless, I wanted to share my progress, maybe someone else can figure out how to fix those issues 🤞