Skip to content
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

Created a new package containing all icons #9648

Closed
wants to merge 2 commits into from

Conversation

caxco93
Copy link
Contributor

@caxco93 caxco93 commented Sep 6, 2018

Description

[IN PROGRESS] [NEEDS FEEDBACK]

Creates a new package called @wordpress/icons containing all new svg icons for reusability and maintainability.
This will help close #9642 and others in the future more easily

Fixes #9647

How has this been tested?

Check if the blocks show the correct icon

Types of changes

New feature (non-breaking change which adds functionality)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

This will help with reusability and maintainability.
@ZebulanStanphill
Copy link
Member

Nice! Notably, there are currently some icons missing from the embed block. (The generic ones for brands without a unique icon and the brand-specific ones.)

Should brand icons be included in this package or in a separate package?

@caxco93
Copy link
Contributor Author

caxco93 commented Sep 6, 2018

I was thinking on placing those at the bottom as well. Separated with a comment indicating they are used by the embed block.

@chrisvanpatten
Copy link
Contributor

Thanks for the PR @caxco93!

I get the theory and reasoning here, but I'm not sure this is the best solution. This would effectively be forking and maintaining our own copy of Material Design Icons (albeit a small subset), which seems potentially complicated.

If the ultimate goal is that the icons inside block placeholders reflect the block icons, perhaps there's a way that blocks could access their own properties — including the icon — from inside the block? That would allow you to reference something like blockProperties.icon.

@ZebulanStanphill
Copy link
Member

@chrisvanpatten I did something like that in #9646.

@caxco93
Copy link
Contributor Author

caxco93 commented Sep 6, 2018

This package would let other users reuse these icons, just like they are already used to reusing Dashicons.

Also it would be very easy to, in the future, add a custom SVG icon and have it be reusable everywhere else in Gutenberg.

@chrisvanpatten

I'd like more opinions on this

@@ -5,6 +5,7 @@ import { __ } from '@wordpress/i18n';
import { RichText } from '@wordpress/editor';
import { createBlock } from '@wordpress/blocks';
import { createBlobURL } from '@wordpress/blob';
import { video as videoIcon } from '@wordpress/icons';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably do this a bit differently:

import { video as icon } from '@wordpress/icons';

and then later in the file be able to use icon, instead of icon: videoIcon.

@chrisvanpatten
Copy link
Contributor

@caxco93 just as some background, the switch to raw SVGs was deliberate. The approach with Dashicons is considered a fallback at this point. There's some more info about the change in #8916.

To be clear I'm not the final arbiter on whether this is a good or bad approach, just want to provide some context on why raw SVGs were chosen over an icon library approach.

I also think that if this type of approach is preferred (pulling in the SVG component from a library), it may make long term maintenance easier to use an existing Material Design component library (like this one or this one) rather than maintaining our own fork of the icons.

That said it's not up to me, and I'm very interested to hear other feedback :)

@gziolo gziolo added Needs Decision Needs a decision to be actionable or relevant [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible npm Packages Related to npm packages labels Feb 1, 2019
@gziolo
Copy link
Member

gziolo commented Feb 12, 2019

@aduth
Copy link
Member

aduth commented Feb 12, 2019

Discussed in this week's #core-js meeting (link requires registration):

https://wordpress.slack.com/archives/C5UNMSU4R/p1549981547059600

@paaljoachim paaljoachim mentioned this pull request Aug 26, 2019
5 tasks
@gziolo
Copy link
Member

gziolo commented Aug 26, 2019

As mentioned by @paaljoachim, @senadir is working on the same task in #17055. It looks like he got to the more advanced stage but there is still a lot of concerns in his proposal. I suggest we focus on the more up to date proposal and close this PR to ensure we have one place to continue the discussion.

@gziolo gziolo closed this Aug 26, 2019
@gziolo gziolo added [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed and removed Needs Decision Needs a decision to be actionable or relevant labels Aug 26, 2019
@gziolo
Copy link
Member

gziolo commented Aug 26, 2019

@caxco93, many thanks for your initial work. It looks like @senadir is taking a very similar approach but as you can read in the linked PR this is a quite complex issue to solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
npm Packages Related to npm packages [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block icons SVGs are not reusable Old Block-Icons in Placeholders
5 participants