-
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
Add border support to site logo #48354
Changes from all commits
3cb7840
41cdda1
1ea0a5f
279019b
47125e1
53892f4
b91090f
860ad11
dbf9900
6d506b9
5602da2
177b072
d30eccd
1b00379
06b939d
501fb91
882acf6
0c5ab73
8a74ce8
97b3a40
c340f86
09a0c96
549e075
2249153
0df97a5
c1d747d
ab6c5d4
4f19a03
038906b
5e438e3
a76a4ac
6bb7388
6552759
db034b7
122e4a7
2e987e5
17d4c72
cf4af0d
45702b0
3b94538
9c698f5
43eabd8
3d8c582
90cb781
551db7a
0d62516
c879a2e
cfb275a
33bd8af
357bad8
bc5a7ef
635476c
97fa100
9fbe66f
7eadd08
8f91248
8b08a4f
3aa4a50
7aeadef
d2374e8
b9008b8
b4eb312
07117f1
46c352b
31f50cf
12cdcf0
95f264f
1e7f619
e0251c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,6 @@ | |
} | ||
|
||
.wp-block-site-logo { | ||
// Make the block selectable. | ||
a { | ||
pointer-events: none; | ||
} | ||
|
||
.custom-logo-link { | ||
cursor: inherit; | ||
|
||
|
@@ -21,8 +16,10 @@ | |
|
||
img { | ||
display: block; | ||
height: auto; | ||
max-width: 100%; | ||
} | ||
|
||
.wp-block-image__crop-area { | ||
pointer-events: auto; | ||
} | ||
|
||
&.is-transient { | ||
|
@@ -52,19 +49,20 @@ | |
width: 60px; | ||
} | ||
|
||
/** | ||
// Inherit radius. | ||
> div, // A 60px width div shown only in the editor on mobile. | ||
.components-resizable-box__container { | ||
border-radius: inherit; | ||
} | ||
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. The |
||
*/ | ||
|
||
// Style the placeholder. | ||
.components-placeholder { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 0; | ||
border-radius: inherit; | ||
|
||
// Provide a minimum size for the placeholder, for when the logo is resized. | ||
// @todo resizing is currently only possible by adding an image, resizing, | ||
|
@@ -108,6 +106,18 @@ | |
} | ||
} | ||
|
||
// Reduced specificity for the placeholder border radius, | ||
// so that border-radius from global styles can be applied. | ||
:root :where(.wp-block-site-logo .components-placeholder) { | ||
border-radius: inherit; | ||
} | ||
|
||
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. Even with the
the placeholder component's own CSS still overrides the border radius from the global styles. |
||
// Reset the box-sizing for the placeholder to prevent the border | ||
// from covering the logo upload button. | ||
.wp-block-site-logo .components-placeholder.components-placeholder { | ||
box-sizing: initial; | ||
} | ||
|
||
.block-library-site-logo__inspector-upload-container { | ||
position: relative; | ||
// Since there is no option to skip rendering the drag'n'drop icon in drop | ||
|
@@ -165,3 +175,21 @@ | |
height: $grid-unit-50; | ||
} | ||
} | ||
|
||
// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized logo. | ||
.wp-block-site-logo .components-resizable-box__container { | ||
// Using "display: table" because: | ||
// - it visually hides empty white space in between elements | ||
// - it allows the element to be as wide as its contents (instead of 100% width, as it would be with `display: block`) | ||
display: table; | ||
img { | ||
display: block; | ||
width: inherit; | ||
} | ||
} | ||
|
||
.wp-block-site-logo.has-custom-border { | ||
.wp-block-image__crop-area { | ||
box-sizing: border-box; | ||
} | ||
} |
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.
If I don't remove the height and width, the upload button is misaligned when there is a border.
In this screenshot, a border width of 10px is added in global styles:
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.
I am not sure what this CSS is for, was 60px chosen because the default size of the logo is 120?
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.
Ok, I found the ticket #48218
I am not sure how to resolve it without letting it fall back to
height: 100%
andwidth:100%
though! @richtaborThere 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.
Yes, per https://github.com/WordPress/gutenberg/pull/48218—120x120 is too big for a logo placeholder, but 120px is the max initial width for when a logo is uploaded.
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.
This is a tricky one 🤔
While in the placeholder state the layout shift when adding a border sticks out. When not in the placeholder state the block has
border-box
set for thebox-sizing
. Addingborder-box
for the placeholder state exacerbates the problem with scrollbars etc.I'm not sure there is a bulletproof solution but maybe there is something we can do to smooth out the experience a bit for the less extreme use cases.
If we avoid applying the custom border on the placeholder directly and instead apply it to a new pseudo element. We can position the bordered pseudo element over the inner contents. It will start to crop the underlying button as the border increases but that seems better than scrollbars.
Hacking around in dev tools this is what I got:
Screen.Recording.2024-08-08.at.8.05.37.PM.mp4