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

Increase CSS specificity of text alignment classes #62260

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,22 @@ function gutenberg_get_typography_font_size_value( $preset, $settings = array()
return $preset['size'];
}

function gutenberg_output_typography_styles() {
foreach ( array( 'left', 'center', 'right' ) as $alignment ) {
gutenberg_style_engine_get_styles(
array(
'typography' => array(
'textAlign' => $alignment,
),
),
array(
'selector' => ".has-text-align-{$alignment}",
'context' => 'block-supports',
)
);
}
}

// Register the block support.
WP_Block_Supports::get_instance()->register(
'typography',
Expand All @@ -621,3 +637,8 @@ function gutenberg_get_typography_font_size_value( $preset, $settings = array()
remove_filter( 'render_block', 'wp_render_typography_support' );
}
add_filter( 'render_block', 'gutenberg_render_typography_support', 10, 2 );

if ( function_exists( 'wp_output_typography_styles' ) ) {
remove_action( 'enqueue_block_assets', 'wp_output_typography_styles' );
}
add_filter( 'enqueue_block_assets', 'gutenberg_output_typography_styles', 9 );
15 changes: 0 additions & 15 deletions packages/block-library/src/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@
font-size: var(--wp--preset--font-size--huge);
}

// Text alignments.
.has-text-align-center {
text-align: center;
}

.has-text-align-left {
/*rtl:ignore*/
text-align: left;
}

.has-text-align-right {
/*rtl:ignore*/
text-align: right;
}

// This tag marks the end of the styles that apply to editing canvas contents and need to be manipulated when we resize the editor.
#end-resizable-editor-section {
display: none;
Expand Down
6 changes: 6 additions & 0 deletions packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@
),
'path' => array( 'typography', 'lineHeight' ),
),
'textAlign' => array(

Check warning on line 270 in packages/style-engine/class-wp-style-engine.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Array double arrow not aligned correctly; expected 6 space(s) between "'textAlign'" and double arrow, but found 7.
'property_keys' => array(
'default' => 'text-align',
),
'path' => array( 'typography', 'textAlign' ),
),
'textColumns' => array(
'property_keys' => array(
'default' => 'column-count',
Expand Down
Loading