Skip to content

Commit

Permalink
Site Logo: Fix default size (#30846)
Browse files Browse the repository at this point in the history
Add a new "is-default-size" class, and attach the 120px width to it.
  • Loading branch information
jasmussen authored Apr 15, 2021
1 parent 3b1360e commit a0f7498
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/site-logo/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export default function LogoEdit( {
);

const classes = classnames( className, {
'is-resized': !! width,
'is-default-size': ! width,
} );

const blockProps = useBlockProps( {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/site-logo/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/site-logo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<div %s>%s</div>', $wrapper_attributes, $custom_logo );
remove_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter );
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/site-logo/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a0f7498

Please sign in to comment.