-
Notifications
You must be signed in to change notification settings - Fork 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
Components: Remove global button styles from Post Comment Actions #45344
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~34 bytes added 📈 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. App Entrypoints (~148 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~17579 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~15911 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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.
There seems to be a subtle difference between the original spacing above/below the comment action buttons, and the one in this branch.
As you can see, with the spacing in this PR, comment action buttons aren't vertically centered, while originally they are more or less vertically centered.
outline: 0; | ||
padding: 0; | ||
vertical-align: baseline; | ||
} |
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.
Let's add a newline at the end of the file.
This patch adds the After the patch, the space above the button row is smaller, i.e., the button row is closer to the text above it. That's because of: .button .gridicon {
margin-top: -2px;
} which adds negative margin on top of the gridicon element, making the overall After the patch, the space below the button row is bigger, i.e., there's more space above the next comment. That's because of: .button {
line-height: 22px;
} The button has a bigger If we want to rebalance the spacing again, the best solution seems to be adding a |
@@ -6,13 +6,16 @@ | |||
margin-top: -6px; | |||
|
|||
button { | |||
@extend %button; |
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.
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.
Thank you for pointing this out. I was indeed going about this the wrong way. I've updated the branch with new code that doesn't rely on the global styles.
The problem I was running into was that I was removing the global styles to check how my changes were working, and getting confused with the like button, which was using a different method of getting the button
tag. I've added something of a hack to make it work using the Button
component, but I'm not sure if there's a better way to do this. I've never worked with this tagName
pattern in React before, so I'm kind of just guessing based on what I can imagine will work based on the implementation I am seeing. I would especially love feedback with respect to that.
412893f
to
321ba38
Compare
@tyxla I believe there are still slight differences, but I think the new version is actually more consistent with respect to how the icons are lined up. Let me know if you think there's still an issue though and I can try to match it more exactly. |
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.
Thanks for your continuous work on this one 👍 I wouldn't want to block this PR any further, but I've noticed 2 more things I'd like to talk through before approving it:
- Spacing-wise, it's not ideal, but I think it's indeed closer to what we want. One thing I'm not super happy about is the spacing on the left - it doesn't align with the comment text above, so we might want to remove that left padding on the read more button. What are your thoughts?
- Color-wise, there's a difference between production and this branch for the read more button.
Is that change intentional?
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.
@saramarcondes I think we're dealing with three kinds of buttons here:
button
with native browser styles that make it look like, well, a button 🙂- Calypso
<Button>
that adds additional styling on top of the browser native ones (without any reset) and makes the button still look like button, but a Calypso-styled one (borders, colors, paddings, font, focus rings...) button
element that is styled to look like a regulardiv
, i.e., one that resets the native browser styles. That's useful at places where we wantbutton
behavior (with all the a11y benefits it provider over a<div onClick>
), but none of the styles. The comments actions buttons are good example of this: they're styled to look more like text links.
The %button
extend you had in the previous version of the patch provided these button-to-div resets.
<Button borderless>
is close to the button-as-div look, but not quite there. It's intended to still have the same dimensions, paddings and fonts like the regular button, just without the border. See how the borderless and border-ful buttons nicely align in this toolbar screenshot:
A button-as-div wouldn't do that. The .comments__comment-actions button.button
CSS rule needs to do several somewhat random overrides to get from borderless
to the desired button-as-div state.
Ideally, I think we need something like <Button plain>
or <Button bare>
to get that button-as-div styling with the reset. Such a button wouldn't have the .button
CSS class, as that's already used for the Calypso-styled button. Instead, there could be a .button-plain
CSS class that does the reset -- it would have the same contents as %button
had.
I don't want to block this PR, once it gets good enough to ship, until we implement some perfect solution, but let's discuss if what I write above makes sense and if it's a viable roadmap to make the Calypso buttons a bit better.
@diegohaz do you have any insights about how to do the button-as-div components and how, e.g., Reakit or @wordpress/components
approach this?
<Button { ...props } borderless compact> | ||
{ children } | ||
</Button> | ||
); |
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.
Some nits:
- I'd call it just
BorderlessCompactButton
. It's a component rather that a tag.tagName
, just likeReact.createElement
, accepts either a component (function) or a HTML tag name (string) children
is one of theprops
, no need to destructure it separately.( props ) => <Button { ...props } borderless compact />
works, too.- let's use
BorderlessCompactButton
consistenly across this module, using it everywhere instead of<Button borderless compact>
display: inline-block; | ||
color: var( --color-text-subtle ); | ||
color: var( --color-text-subtle ); |
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.
This style conflicts with the one that gives the "Read more" button the primary color:
.comments__comment-actions .comments__comment-actions-read-more {
color: var( --color-primary );
}
That causes the coloring issue that @tyxla reports in #45344 (review)
321ba38
to
5fa9f76
Compare
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.
Looks and works well to me, and the code looks good.
On a side note, I'm not sure bare
makes complete sense in terms of being predictive, obvious and clear what it does. What alternatives of bare
can we find? Material design calls those "text buttons". while Bootstrap calls them Links or Link Buttons (it also has a Jumbotron component, so not sure we wanna borrow naming ideas from there, lol). Chakra UI also calls them links FWIW.
What are your thoughts on the prop naming?
FWIW, consider the |
I'd rule out "link buttons" because that suggests the component is an |
I agree on all points @jsnajdr. While |
Reakit doesn't care about styling. The closest concept is the
In It has props like The polymorphism there is resumed to the |
85d9d0d
to
ffc5150
Compare
@tyxla I'd love a re-review after having replaced the Automattic component button with the WordPress components equivalent. Let me know what you think. |
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.
Thanks for using @wordpress/components
instead, @saramarcondes!
FWIW, currently in calypso, we don't add the @wordpress/components
stylesheet, so any WordPress components you use won't have their corresponding styles loaded.
#45724 is taking care of that, so maybe we should rebase and test this one again after we land #45724. What do you think?
@tyxla Oh gosh, I feel very silly! Yes, that would make sense to do first, wouldn't it 🤦♀️ It didn't even occur to me that we needed to load the stylesheet separately or that it would be affecting these PRs. Not sure how I didn't connect those dots. Lets land #45724 like you said and then revisit this one. |
c37f4d0
to
982ea2d
Compare
@saramarcondes I've rebased the PR since we merged #45724 and it seems like the buttons work really well! The only thing we needed to do is to reset the It's worth noting that I've also tested the moderation actions, which are currently disabled in the UI. Regardless, they work just fine with this PR. |
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.
LGTM! Nice work 👏
Going to help ship this once tests are green. |
Changes proposed in this Pull Request
Button
component for the comment action buttonsTesting instructions
Related to #45259