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

Move defining style-engine definitions meta to block-supports #41965

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/block-supports/background.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,22 @@ function gutenberg_render_background_support( $block_content, $block ) {
);

add_filter( 'render_block', 'gutenberg_render_background_support', 10, 2 );

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'background',
array(
'backgroundImage' => array(
'property_keys' => array(
'default' => 'background-image',
),
'value_func' => array( 'WP_Style_Engine_Gutenberg', 'get_url_or_value_css_declaration' ),
'path' => array( 'background', 'backgroundImage' ),
),
'backgroundSize' => array(
'property_keys' => array(
'default' => 'background-size',
),
'path' => array( 'background', 'backgroundSize' ),
),
)
);
66 changes: 66 additions & 0 deletions lib/block-supports/border.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,69 @@ function gutenberg_has_border_feature_support( $block_type, $feature, $default_v
'apply' => 'gutenberg_apply_border_support',
)
);

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'border',
array(
'color' => array(
'property_keys' => array(
'default' => 'border-color',
'individual' => 'border-%s-color',
),
'path' => array( 'border', 'color' ),
'classnames' => array(
'has-border-color' => true,
'has-$slug-border-color' => 'color',
),
),
'radius' => array(
'property_keys' => array(
'default' => 'border-radius',
'individual' => 'border-%s-radius',
),
'path' => array( 'border', 'radius' ),
),
'style' => array(
'property_keys' => array(
'default' => 'border-style',
'individual' => 'border-%s-style',
),
'path' => array( 'border', 'style' ),
),
'width' => array(
'property_keys' => array(
'default' => 'border-width',
'individual' => 'border-%s-width',
),
'path' => array( 'border', 'width' ),
),
'top' => array(
'value_func' => array( 'WP_Style_Engine_Gutenberg', 'get_individual_property_css_declarations' ),
'path' => array( 'border', 'top' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
'right' => array(
'value_func' => array( 'WP_Style_Engine_Gutenberg', 'get_individual_property_css_declarations' ),
'path' => array( 'border', 'right' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
'bottom' => array(
'value_func' => array( 'WP_Style_Engine_Gutenberg', 'get_individual_property_css_declarations' ),
'path' => array( 'border', 'bottom' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
'left' => array(
'value_func' => array( 'WP_Style_Engine_Gutenberg', 'get_individual_property_css_declarations' ),
'path' => array( 'border', 'left' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
)
);
51 changes: 51 additions & 0 deletions lib/block-supports/colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,54 @@ function gutenberg_apply_colors_support( $block_type, $block_attributes ) {
'apply' => 'gutenberg_apply_colors_support',
)
);

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'color.text',
array(
'property_keys' => array(
'default' => 'color',
),
'path' => array( 'color', 'text' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
'classnames' => array(
'has-text-color' => true,
'has-$slug-color' => 'color',
),
)
);

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'color.background',
array(
'property_keys' => array(
'default' => 'background-color',
),
'path' => array( 'color', 'background' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
'classnames' => array(
'has-background' => true,
'has-$slug-background-color' => 'color',
),
)
);

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'color.gradient',
array(
'property_keys' => array(
'default' => 'background',
),
'css_vars' => array(
'gradient' => '--wp--preset--gradient--$slug',
),
'path' => array( 'color', 'gradient' ),
'classnames' => array(
'has-background' => true,
'has-$slug-gradient-background' => 'gradient',
),
)
);
16 changes: 16 additions & 0 deletions lib/block-supports/dimensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,19 @@ function gutenberg_apply_dimensions_support( $block_type, $block_attributes ) {
'apply' => 'gutenberg_apply_dimensions_support',
)
);


WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'dimensions',
array(
'minHeight' => array(
'property_keys' => array(
'default' => 'min-height',
),
'path' => array( 'dimensions', 'minHeight' ),
'css_vars' => array(
'spacing' => '--wp--preset--spacing--$slug',
),
),
)
);
15 changes: 15 additions & 0 deletions lib/block-supports/shadow.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,18 @@ function gutenberg_apply_shadow_support( $block_type, $block_attributes ) {
'apply' => 'gutenberg_apply_shadow_support',
)
);

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'shadow',
array(
'shadow' => array(
'property_keys' => array(
'default' => 'box-shadow',
),
'path' => array( 'shadow' ),
'css_vars' => array(
'shadow' => '--wp--preset--shadow--$slug',
),
),
)
);
26 changes: 26 additions & 0 deletions lib/block-supports/spacing.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,29 @@ function gutenberg_apply_spacing_support( $block_type, $block_attributes ) {
'apply' => 'gutenberg_apply_spacing_support',
)
);

WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'spacing',
array(
'padding' => array(
'property_keys' => array(
'default' => 'padding',
'individual' => 'padding-%s',
),
'path' => array( 'spacing', 'padding' ),
'css_vars' => array(
'spacing' => '--wp--preset--spacing--$slug',
),
),
'margin' => array(
'property_keys' => array(
'default' => 'margin',
'individual' => 'margin-%s',
),
'path' => array( 'spacing', 'margin' ),
'css_vars' => array(
'spacing' => '--wp--preset--spacing--$slug',
),
),
)
);
73 changes: 73 additions & 0 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,3 +580,76 @@ function gutenberg_get_typography_font_size_value( $preset, $should_use_fluid_ty
remove_filter( 'render_block', 'wp_render_typography_support' );
}
add_filter( 'render_block', 'gutenberg_render_typography_support', 10, 2 );


WP_Style_Engine_Gutenberg::register_block_style_definitions_metadata(
'typography',
array(
'fontSize' => array(
'property_keys' => array(
'default' => 'font-size',
),
'path' => array( 'typography', 'fontSize' ),
'classnames' => array(
'has-$slug-font-size' => 'font-size',
),
),
'fontFamily' => array(
'property_keys' => array(
'default' => 'font-family',
),
'path' => array( 'typography', 'fontFamily' ),
'classnames' => array(
'has-$slug-font-family' => 'font-family',
),
),
'fontStyle' => array(
'property_keys' => array(
'default' => 'font-style',
),
'path' => array( 'typography', 'fontStyle' ),
),
'fontWeight' => array(
'property_keys' => array(
'default' => 'font-weight',
),
'path' => array( 'typography', 'fontWeight' ),
),
'lineHeight' => array(
'property_keys' => array(
'default' => 'line-height',
),
'path' => array( 'typography', 'lineHeight' ),
),
'textColumns' => array(
'property_keys' => array(
'default' => 'column-count',
),
'path' => array( 'typography', 'textColumns' ),
),
'textDecoration' => array(
'property_keys' => array(
'default' => 'text-decoration',
),
'path' => array( 'typography', 'textDecoration' ),
),
'textTransform' => array(
'property_keys' => array(
'default' => 'text-transform',
),
'path' => array( 'typography', 'textTransform' ),
),
'letterSpacing' => array(
'property_keys' => array(
'default' => 'letter-spacing',
),
'path' => array( 'typography', 'letterSpacing' ),
),
'writingMode' => array(
'property_keys' => array(
'default' => 'writing-mode',
),
'path' => array( 'typography', 'writingMode' ),
),
)
);
Loading
Loading