Skip to content

Commit

Permalink
Move defining style definitions meta to block-supports
Browse files Browse the repository at this point in the history
  • Loading branch information
aristath committed Jun 27, 2022
1 parent 213bd58 commit f46c925
Show file tree
Hide file tree
Showing 5 changed files with 225 additions and 179 deletions.
66 changes: 66 additions & 0 deletions lib/block-supports/border.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,69 @@ function gutenberg_has_border_feature_support( $block_type, $feature, $default =
'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' => 'static::get_css_individual_property_rules',
'path' => array( 'border', 'top' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
'right' => array(
'value_func' => 'static::get_css_individual_property_rules',
'path' => array( 'border', 'right' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
'bottom' => array(
'value_func' => 'static::get_css_individual_property_rules',
'path' => array( 'border', 'bottom' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
'left' => array(
'value_func' => 'static::get_css_individual_property_rules',
'path' => array( 'border', 'left' ),
'css_vars' => array(
'color' => '--wp--preset--color--$slug',
),
),
)
);
46 changes: 46 additions & 0 deletions lib/block-supports/colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,49 @@ 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(
'--wp--preset--color--$slug' => 'color',
),
'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' ),
'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',
),
'path' => array( 'color', 'gradient' ),
'classnames' => array(
'has-background' => true,
'has-$slug-gradient-background' => 'gradient',
),
)
);
20 changes: 20 additions & 0 deletions lib/block-supports/spacing.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,23 @@ 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' ),
),
'margin' => array(
'property_keys' => array(
'default' => 'margin',
'individual' => 'margin-%s',
),
'path' => array( 'spacing', 'margin' ),
),
)
);
60 changes: 60 additions & 0 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,63 @@ function gutenberg_typography_get_css_variable_inline_style( $attributes, $featu
'apply' => 'gutenberg_apply_typography_support',
)
);

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' ),
),
'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' ),
),
)
);
Loading

0 comments on commit f46c925

Please sign in to comment.