-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
WP components audit: Button & IconButton #16541
Comments
Thanks for doing this! If we end up grouping all the components that are related to buttons together, I'm less concerned with having With things like #15830 I feel it's going to be quite convoluted to support all the variations in a single component. Also, it's going to be harder to say prop A cannot be used with prop B, and people would need to combine the right elements which seems prone to more errors.
Open to this as well.
I think it'd be good to do this, because it might help consider all the implications involved — can we have an
We already have an |
@drw158 also related #11937 |
If we go with separate components, would it help to determine which props are incompatible with each other? Is there a way to enforce that in code or just in guidelines? I could take a look at some other systems to see how that is handled.
Some disadvantages I see:
I couldn't tell if it worked in the environment I'm using, but yep that should work if both components have it. It would be nice if you could change the icon on toggle for Icon Button (e.g. empty star to filled star). |
Props auditAs an addendum, here is a deeper evaluation of the props for these components. This is an effort to expand the components to be more useful and to answer the question, "Are properties well thought out and consistently applied?" This only covers visual props. Event handler props will be evaluated at a later date. ButtonisPrimary, isDefault, isTertiaryI don't see why any of these would need to be used in conjunction with one another, so I propose they become mutually exclusive.
isLarge, isSmallTwo directions we could take. 1) Only offer one size, other than the default. 2) Offer 3 sizes, like we do now.
Although offering 3 sizes is a common practice for component libraries, it can be unclear how and when to use these just by looking at the prop names (e.g. "Should I use We can also use the ✨ New
📋 Rename
Removing "is" simplifies and removes redundancy. 👍 No change
✂️ Remove
IconButtontooltip, labelThe text here should be the same, so we should refactor how these are currently implemented:
✨ NewAll of the above props for Button should also apply for IconButton except for:
👍 No change
✂️ Remove
Event handler props will be evaluated at a later date. |
I think with the last button refactorings we have now a single Button component that supports icons, three variations (primary, secondary, tertiary) and support two sizes (small, default). I think the component is consistent enought that we can consider this issue closed. There might be some things that can be improved (link buttons) but let's follow-up with more specific issues now. |
I just wanted to check in on this, I see that However, @youknowriad I see you mention having 2 sizes as best. I see code in the component for What would be the best course of action?
I came across this today and thought it would be a nice way to make my first code contribution :) Thanks |
Seems like the path forward as it was an intended change. Thanks for your help. |
Prevents a console error in WP 5.5 caused by the attribute being removed in 5.5. See: - Removal: WordPress/gutenberg#23239 - Note about isLarge having no effect in the first place: WordPress/gutenberg#16541 (comment)
Is your feature request related to a problem? Please describe.
This issue is part of a review on the naming, structure, and composition of the UI components as brought up in #16367
Link vs Button
Please see this comment on how the link vs button discussion relates to this component library audit: #7534 (comment)
Button
Audit
Opportunities I came across while reviewing this component.
isLink
prop was confusing and problematic for me. Does it just style it as a link or does it actually use an anchor tag like in other component libraries?Grouping
I expect Buttons to be a top level category containing several components including, but not limited to, ClipboardButton, IconButton, ButtonGroup, etc.
Suggestions
isDefault
button style actually the default in the component. (e.g.<Button>Button</Button>
). Even if it's not named "Default" it's still a good default style for the component. Other styles are used only if a button requires more or less importance.isLink
in favor of the Tertiary style since they look very similar (assuming there is no functional change). This makes more sense if we add a new Link component.Primary
button style (e.g. a card might use theDefault
button for the primary action and theTertiary
button for the secondary action. Here are some options:IconButton
Audit
Opportunities I came across while reviewing this component.
Grouping
I expect IconButton to live in a Buttons category, instead of a top level item.
Suggestions
Two options for Button and IconButton:
1. Keep Button and IconButton separate components
Now that it seems like both components will have text and icon options in the component, here would be the main differences:
2. Combine Button and IconButton
It could be a simpler experience for designers/developers if we combined the two components. Here is an example of a component library that does this.
The main advantage is that the user of the system won't have to figure out which component to use, since it's all-in-one. The disadvantage is that it might be complex figuring out the different props, and the combination of certain props (e.g. isPrimary + isIconOnly). We might have to split the two components for technical reasons.
Feedback
The feedback I'm looking for is related to naming, structure, and composition. I'm not looking for visual feedback of the components. Prop audit can be seen in the comment below.
isLink
prop?The text was updated successfully, but these errors were encountered: