-
Notifications
You must be signed in to change notification settings - Fork 4.7k
UI: Add Icon component
#74311
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
UI: Add Icon component
#74311
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: 0 B Total Size: 3.08 MB ℹ️ View Unchanged
|
|
Flaky tests detected in b707d57. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20642807566
|
aduth
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.
🚀
| * ``` | ||
| */ | ||
| export const Icon = forwardRef< SVGSVGElement, IconProps >( function Icon( | ||
| { icon, size = 24, ...restProps }, |
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.
Random thought: icon feels like it's mostly identical in purpose to the render prop in how it functions. I feel like icon is a more intuitive name, though maybe there'd be some benefit in using the useRender hook to manage its rendering? Then again, this doesn't feel very complex as it is.
| @@ -0,0 +1,30 @@ | |||
| import { forwardRef } from '@wordpress/element'; | |||
| import { SVG } from '@wordpress/primitives'; | |||
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'm not sure what the plans are with the native editor, but given past mentions of it being "paused" and ongoing development of GutenbergKit, do we think we'll need this primitive, or could we start with a plain <svg /> ?
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.
As best as I could assess, removal of the SVG component should be done in a way that's coordinated across the codebase, not just in the Icon component. I find three separate concerns that need to be considered:
- React Native (things breaking in the shipping WordPress/Jetpack mobile apps).
- Mandatory addition of a
aria-hidden="true". - The lint rule that enforces the above two concerns on every
svgin the codebase.
So in any case this will be outside the scope of this PR.
Can @WordPress/native-mobile confirm the first point, whether or not we're ready to remove the React Native compatibility for svgs?
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.
The mobile team is working to ship GutenbergKit to mobile users. Once achieved, we'll be ready to remove React Native-related logic. I suggest waiting for that and agree that it should be coordinated across the codebase rather than just the Icon component.
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.
@dcalhoun Thanks for confirming! We'll wait for that.
# Conflicts: # packages/ui/CHANGELOG.md
Prerequisite for #74178
What?
Add
Iconcomponent to@wordpress/ui.Why?
This is a replacement for the
Iconcomponent in@wordpress/components, with these changes:SVGs from@wordpress/primitives.fill="currentColor".Testing Instructions
See stories in Storybook.
Screenshots or screencast