From a0f749880985fa06c3b7d943989b40be004f2c88 Mon Sep 17 00:00:00 2001 From: Joen A <1204802+jasmussen@users.noreply.github.com> Date: Thu, 15 Apr 2021 14:54:52 +0200 Subject: [PATCH] Site Logo: Fix default size (#30846) Add a new "is-default-size" class, and attach the 120px width to it. --- packages/block-library/src/site-logo/edit.js | 2 +- packages/block-library/src/site-logo/editor.scss | 4 ++-- packages/block-library/src/site-logo/index.php | 4 ++++ packages/block-library/src/site-logo/style.scss | 3 ++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/site-logo/edit.js b/packages/block-library/src/site-logo/edit.js index 9c6c52022efad9..d7c9da3181827a 100644 --- a/packages/block-library/src/site-logo/edit.js +++ b/packages/block-library/src/site-logo/edit.js @@ -337,7 +337,7 @@ export default function LogoEdit( { ); const classes = classnames( className, { - 'is-resized': !! width, + 'is-default-size': ! width, } ); const blockProps = useBlockProps( { diff --git a/packages/block-library/src/site-logo/editor.scss b/packages/block-library/src/site-logo/editor.scss index bb2ba56d62d159..694cc980312839 100644 --- a/packages/block-library/src/site-logo/editor.scss +++ b/packages/block-library/src/site-logo/editor.scss @@ -10,12 +10,12 @@ pointer-events: none; } - &.is-resized { + &:not(.is-default-size) { display: table; } // Provide a sane starting point for the size. - &:not(.is-resized) { + &.is-default-size { width: 120px; img { diff --git a/packages/block-library/src/site-logo/index.php b/packages/block-library/src/site-logo/index.php index 902daad001457d..f14feb0cb07a8f 100644 --- a/packages/block-library/src/site-logo/index.php +++ b/packages/block-library/src/site-logo/index.php @@ -32,6 +32,10 @@ function render_block_core_site_logo( $attributes ) { $classnames[] = "align{$attributes['align']}"; } + if ( empty( $attributes['width'] ) ) { + $classnames[] = 'is-default-size'; + } + $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) ); $html = sprintf( '
%s
', $wrapper_attributes, $custom_logo ); remove_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter ); diff --git a/packages/block-library/src/site-logo/style.scss b/packages/block-library/src/site-logo/style.scss index 774a701f6fc6e3..dd8a883238f56c 100644 --- a/packages/block-library/src/site-logo/style.scss +++ b/packages/block-library/src/site-logo/style.scss @@ -6,8 +6,9 @@ } // Provide a sane starting point for the size. - &:not(.is-resized) img { + &.is-default-size img { width: 120px; + height: auto; } .aligncenter {