-
Notifications
You must be signed in to change notification settings - Fork 2k
WP Button: Add reusable style for secondary A8C override #101626
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
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
|
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
|
Better than having many variations of these overrides scattered across the codebase 😓 Do you think we should try to consolidate all those overrides to use this new classname? |
@ciampo From a quick skim, I estimate the number of However I think the bigger problem is that the standard |
| */ | ||
| const meta: Meta< typeof Button > = { | ||
| title: 'packages/components/WP Overrides/Button', | ||
| component: 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.
@ciampo Aside: Apparently react-docgen-typescript doesn't pull types from external dependencies, which WP Button is in this case. It could be that there are config tweaks we could do to make that happen, but I didn't go down that rabbit hole for now. Anyway, that's why the full props table is not showing in Storybook.
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.
Mhh, definitely not ideal — maybe we can create, only for the purpose of Storybook, a Button component that more explicitly defines prop types (something like props: React.ComponentProps< typeof Button >, or any other technique) ?
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.
That kind of thing didn't work either 🫤 I also tried some of these tricks on Storybook 8, but didn't work.
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.
Ok, it's annoying but I figured out some workarounds. Will update.
|
|
||
| .a8c-components-wp-button { | ||
| &.is-secondary:not(:disabled, [aria-disabled="true"], [aria-pressed="true"]) { | ||
| box-shadow: inset 0 0 0 $border-width theme.$components-color-gray-300; |
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.
@ciampo Are the $components-color- variables too much? They're not strictly necessary but I thought some consistency here could be helpful since we're seeing some ad hoc CSS variable-based theming starting to happen.
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 don't like the idea because it can quickly spread across the codebase and become really hard to migrate away from.
I honestly think more and more that we should spend some time to create the theming engine that we've been long discussed about. It could live in @automattic/theme-provider and be general enough that, if/when needed, it can be ported to Gutenberg with virtually zero changes.
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.
CC: @jameskoster @youknowriad. Would love to see if parts of this can be reused. Also connecting some dots to this conversation: pgle0O-7K-p2#comment-193
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.
We can definitely reuse parts of Saxon's exploratory work — from my point of view, it's mostly a matter of prioritisation and resource assignment.
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 this!
I've rebased my social buttons PR on this branch again today and it's still working well. I've stripped back the styles on those buttons to the bare minimum; font size and layout rules for the internals. There are still overrides for some heavily branded buttons (eg. Woo, Gravatar), but otherwise it's mostly just theming using --color-accent.
Storybook works for me.
LGTM
Will you ping us there? I'm doing some Linear work today to hopefully set up some ping-groups, probably a design-system related one. But otherwise, just let me know if there was a specific action item, such as feedback on this particular PR. Visualyl this is solid, I'll defer to engineering on the technical side of things. But as-is, the existing Calypso/a8c button component does not seem superior to the core Button, as far as keeping around. I don't think a manual search/replace of the entire codebase, with the sole purpose of replacing one component with another, is an effort we should undertake. I think the legacy instances can exist until that section gets organically revisited for some other purpose. This is also to say, between completing untangling work, and work on an improved hosting dashboard, there will both be many such opportunities, but there will also be cases where the entire context disappears, gets retired, or deleted. |
|
@Automattic/team-calypso I'm going to merge now so we don't keep @adamwoodnz in rebase hell, but please leave any comments so I can address them as follow-up 🙏 |
* Button: Support secondary style override * Rejigger * Add to tsconfig * Add decorator for sans-serif font * Fix up * Improve theming support * Fix for destructive and disabled states
Addresses #100807 (comment)
Proposed Changes
Add a way to override the
@wordpress/componentssecondary Button variant style as frequently done in Calypso.CleanShot.2025-03-20.at.06.56.15.mp4
Why are these changes being made?
While we may want to abstract this differently in the near future, having this override class available will unblock us quickly for now in a way that's relatively simple to refactor.
Testing Instructions
yarn components:storybook:startand see the documentation for "WP Overrides".Styles for pseudostates (e.g.
:hover) should be looking good for the busy, destructive, disabled, and pressed button states.Pre-merge Checklist