-
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
added outline support for blocks via theme.json #43526
Conversation
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
path: string[] = [ 'outline', 'color' ], | ||
ruleKey: string = 'outlineColor' |
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 think these two arguments are for box model generation (top, right, bottom, left) which outline doesn't have. They should probably be removed here and passed directly to the generateRule
function.
@ramonjd am I correct in thinking that? Or does this not matter?
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 the ping!
I think these two arguments are for box model generation (top, right, bottom, left) which outline doesn't have.
While they share similar arguments, box model generation should use generateBoxRules
rather than generateRule
.
Example is margin. Note the margin%s
pattern for individual sides:
const margin = {
name: 'margin',
generate: ( style: Style, options: StyleOptions ) => {
return generateBoxRules( style, options, [ 'spacing', 'margin' ], {
default: 'margin',
individual: 'margin%s',
} );
},
};
So I think this looks okay.
They should probably be removed here and passed directly to the generateRule function.
I don't think it matters in practice, but in theory it might be better to be explicit about the arguments passed to generateRule
, rather than set them as defaults.
There is little risk of it I'd say, but it would prevent unexpected path
and ruleKey
values being pass to the generate functions.
See how typography is set up, e.g., :
const fontSize = {
name: 'fontSize',
generate: ( style: Style, options: StyleOptions ) => {
return generateRule(
style,
options,
[ 'typography', 'fontSize' ],
'fontSize'
);
},
};
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 us know when this happens as we'll probably need to support outline in the style engine PHP classes as well. 👍 Not related to this PR (also on trunk), but it exposes how core classes are called before the extended Gutenberg classes. I see this PHP notice in the editor: The core Theme JSON class is trying to parse element selectors but |
1e43aa5
to
6d94d1c
Compare
This would be a great addition. I'm not sure I'll have time to test though. Just leaving feedback 😄 |
import spacing from './spacing'; | ||
import typography from './typography'; | ||
|
||
export const styleDefinitions = [ | ||
...border, | ||
...color, | ||
...outline, |
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.
These changes need an Unreleased change log entry, e.g.,
## New features
- Adding outline support in the Style Engine JS package [#43526](https://github.com/WordPress/gutenberg/pull/43526)
Adding unit tests for outline properties
Hey, while working on #46579 I realized this PR was not backported to WordPress 6.1. When we land that PR and then backport to WordPress 6.2 everything will be fine, but I wanted to raise in case you think this should be ported for a potential WordPress 6.1.X release. |
Thanks for letting me know @oandregal ! I don't know how urgent this one would be. I believe TT3 did not implement this but some other themes like Blockbase, Block Canvas... do have it. I created a backport PR in any case WordPress/wordpress-develop#3788 |
as it was mentioned on my PR, this change would benefit from some unit tests, but I don't think I can get to that before my vacation starts. If adding this is to a point release is time sensitive, I'm happy to wait until we can add those tests. |
Adds the ability to define outline CSS properties for elements and blocks within `theme.json` to render `outline-color`, `outline-offset`, `outline-style`, and `outline-width` styles. Originally developed and tested in [WordPress/gutenberg#43526 Gutenberg PR 43526]. Props onemaggie, hellofromTonya, audrasjb, ironprogrammer. Fixes #57354. git-svn-id: https://develop.svn.wordpress.org/trunk@55008 602fd350-edb4-49c9-b593-d223f7449a82
Adds the ability to define outline CSS properties for elements and blocks within `theme.json` to render `outline-color`, `outline-offset`, `outline-style`, and `outline-width` styles. Originally developed and tested in [WordPress/gutenberg#43526 Gutenberg PR 43526]. Props onemaggie, hellofromTonya, audrasjb, ironprogrammer. Fixes #57354. Built from https://develop.svn.wordpress.org/trunk@55008 git-svn-id: http://core.svn.wordpress.org/trunk@54541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Update: The backport (see Core Trac 57354) has been committed into Core with a unit test ✅ |
Adds the ability to define outline CSS properties for elements and blocks within `theme.json` to render `outline-color`, `outline-offset`, `outline-style`, and `outline-width` styles. Originally developed and tested in [WordPress/gutenberg#43526 Gutenberg PR 43526]. Props onemaggie, hellofromTonya, audrasjb, ironprogrammer. Fixes #57354. Built from https://develop.svn.wordpress.org/trunk@55008 git-svn-id: https://core.svn.wordpress.org/trunk@54541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds the ability to define outline CSS properties for elements and blocks within `theme.json` to render `outline-color`, `outline-offset`, `outline-style`, and `outline-width` styles. Originally developed and tested in [WordPress/gutenberg#43526 Gutenberg PR 43526]. Props onemaggie, hellofromTonya, audrasjb, ironprogrammer. Fixes #57354. Built from https://develop.svn.wordpress.org/trunk@55008 git-svn-id: http://core.svn.wordpress.org/trunk@54541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
What?
This PR adds support for outline for blocks and elements via theme.json
Why?
This is something themes have to add most of the time using CSS. We should discuss what's the best way to surface this to the UI and which blocks should show the option, but the first step is here to allow themes to set it using theme.json instead of having to write CSS for it.
How?
I implemented this following the lead of #41972
Testing Instructions
I'm testing TT3, with this in theme.json:
Screenshots or screencast
/cc @WordPress/block-themers