-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Blocks: icon can be passed as name (Dashicon) or SVG (file, raw) #1327
Comments
Noting that the documentation describes additional supported values for
Related to your third suggestion, instead of returning a string, one could return a Detecting file extension could be interesting. One downside is the additional network request could cause a delay in the icon being shown in the UI. |
I was sure this discussion happened already in some form ;)
What would be the use case for this? Also: why not both?
True. It's what led me to the solution of inlining it directly. |
Consistency in approaches for providing DOM structure;
I don't find more API options to be necessarily better, as it can cause confusion in disjointedness of approaches ("which should I use?"). To flip this on its head, what's the use case for an HTML string as icon? |
Makes sense. 👍 And I agree on more API options, especially if they cover the same problem.
As I mentioned I was coming from the intuitiveness angle, so yes: it's because seeing the SVG right there seem more intuitive for me. As you said, it's a balance between too many options and intuitiveness of the ones available. I wanted to start by listing them, so we can choose knowing which ones we are not choosing. :) |
* set ref of gutenberg to PR-17195
Referring to how blocks are currently declared:
Would be nice to allow a higher reusability to have the
icon
field to be more flexible. We could do basic detection and allow different sources, thus avoiding to limit the icons to Dashicons and/or bloating Dashicons for one-off uses.Brainstorming a possible approach:
icon: 'editor-ui'
)..svg
, it looks up a SVG file relative to the JS file (i.e. `icon: 'custom-icon.svg').<
(ends with>
?), it uses the content as pure SVG: (i.e.icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><rect x="0" fill="none" width="20" height="20"/><g><path d="M10 2.16c4.33 0 7.84 3.51 7.84 7.84s-3.51 7.84-7.84 7.84S2.16 14.33 2.16 10 5.71 2.16 10 2.16zm2 11.72V6.12L6.18 9.97z"/></g></svg>'
).Note: we don't need both 2 and 3, we can chose to do only one of the two. Just, we can do both if we thing both can be useful.
Initially discussed on WordPress/dashicons#203
The text was updated successfully, but these errors were encountered: