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

Add individual css class to default block variations (by default) #54658

Open
hanneslsm opened this issue Sep 20, 2023 · 2 comments
Open

Add individual css class to default block variations (by default) #54658

hanneslsm opened this issue Sep 20, 2023 · 2 comments
Labels
[Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Technical Feedback Needs testing from a developer perspective. [Type] Enhancement A suggestion for improvement.

Comments

@hanneslsm
Copy link

When blocks have style variations, the default should have a corresponding css class.

Use case:
I want to add a text-shadow to my default button (but only this one).
I cannot do it via theme.json "css": "text-shadow…" because this adds it also to the outline and other custom variations. At the moment it's not possible to use "css":… in variations to remove this css then again.
Therefore, I must enqueue a css file.
However, I cannot only target the default button, because it does not have by default an individual css class. Only after I have clicked on the style variation "default" the css class is-style-fill is added. (By the way, it could make sense to rename this to default, instead of fill)

There is probably somewhere a discussion around this already, but I couldn't find it. If anyone knows where it was, it'd love to know the reason why this isn't implemented yet.

@mrfoxtalbot mrfoxtalbot added [Type] Enhancement A suggestion for improvement. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Technical Feedback Needs testing from a developer perspective. labels Sep 20, 2023
@cbirdsong
Copy link

cbirdsong commented Oct 24, 2023

The way I've handled this is adding extra awkward CSS selectors:

.wp-block-button:not([class*="is-style-"]) > .wp-block-button__link, 
.wp-block-button.is-style-fill > .wp-block-button__link {
  // styles here
}

It would make a lot more sense if there was a simple "reset" behavior to get back to the default. (see also #55258, #47976)

@cbirdsong cbirdsong added the [Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks label Oct 24, 2023
@hanneslsm
Copy link
Author

Genius, Thanks!
You're linked issues are very much needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Technical Feedback Needs testing from a developer perspective. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants