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

Fix site logo unresized size take 2 #30846

Merged
merged 4 commits into from
Apr 15, 2021
Merged
Changes from 2 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
1 change: 1 addition & 0 deletions packages/block-library/src/site-logo/edit.js
Original file line number Diff line number Diff line change
@@ -337,6 +337,7 @@ export default function LogoEdit( {
);

const classes = classnames( className, {
'is-default-size': ! width,
'is-resized': !! width,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this then? Seems like there's only one occurence left here:

&.is-resized {
display: table;
}

...which we could probably replace with a &:not(.is-default-size)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is-resized rule, and the table display, was present before the changes I made to default sizes, and I believe are still necessary. I'd prefer to not touch them, or at least touch them separately if need be.

I suspect they were ported over when the block was copied from its Image block roots, and in the image block the table property is used to size the image the same as the caption when manually sized. But I'd still like to fix that separately.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't mean to remove the rule entirely, but rather to change its selector to &:not(.is-default-size) so we can drop the now-redundant is-resized className 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(If we can't do that, I think I'd prefer #30845, since it doesn't introduce another class name that is essentially just is-resized negated, which is kinda redundant.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh of course! I'll get on it. Can I have 20 minutes? I have to pick up a kid very quick

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! 😄

Copy link
Contributor Author

@jasmussen jasmussen Apr 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay here we go!

Editor:

Screenshot 2021-04-15 at 13 16 31

Frontend:

Screenshot 2021-04-15 at 13 16 37

Seemes to work fine! Thank you Bernie!

} );

2 changes: 1 addition & 1 deletion packages/block-library/src/site-logo/editor.scss
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
}

// Provide a sane starting point for the size.
&:not(.is-resized) {
&.is-default-size {
width: 120px;

img {
4 changes: 4 additions & 0 deletions packages/block-library/src/site-logo/index.php
Original file line number Diff line number Diff line change
@@ -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 );
2 changes: 1 addition & 1 deletion packages/block-library/src/site-logo/style.scss
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
}

// Provide a sane starting point for the size.
&:not(.is-resized) img {
&.is-default-size img {
width: 120px;
}