-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site icon: Fix site icon styling to display non-square site icons within a square button #37570
Merged
andrewserong
merged 2 commits into
trunk
from
fix/site-icon-styling-to-support-non-square-site-icons
Dec 23, 2021
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,5 +62,8 @@ | |
|
||
.edit-site-navigation-toggle__site-icon { | ||
width: $button-size; | ||
height: $button-size; | ||
border-radius: $radius-block-ui; | ||
background-size: cover; | ||
margin-top: -1px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above, could use a comment and a variable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switched to using the variable, and added a comment. |
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent eye. Interestingly, when you're just toggling off that minus 1 margin in the inspector, it makes the site icon look vertically uncentered when it's on:
However when you zoom in and look at the details, you can see that it has to have that negative margin in order to horizontally align with the other buttons in the toolbar. With negative margin:
Without negative margin:
This is, per your instinct, related to the dark square being 61px tall. That math comes $header-height + $border-width, so that the black area covers the gray border below the top-bar.
So which do we keep? I don't have a strong opinion, but I appreciate your attention to detail, so probably do keep it. But I'd add a small comment above, something like
// Compensate for the top-bar border.
, and then change1px
to$border-width
instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might it be neater to make the black square 60px tall, then add a shadow to hide the grey border? Then we don't need the awkward negative margin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed approach here! I had a go at switching to 60px tall and using a shadow to hide the grey border. Unfortunately the styling in the site editor then wound up being a bit unreliable due to the
z-index
stacking order. With60px
and box-shadow, from time to time the shadow would pop out / a white line would be visible:I've gone with adding the inline comment and using
$border-width
instead of the hard-coded1px
, and we can always look at switching to the60px
approach in a follow-up if we'd like to tweak further.