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

Try: Overlay caption w. text-shadow. #63471

Merged
merged 8 commits into from
Aug 19, 2024
Merged
Changes from 5 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
42 changes: 35 additions & 7 deletions packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,46 @@ figure.wp-block-gallery.has-nested-images {
width: auto;
}

// Position caption and scrim at the bottom.
&:has(figcaption)::before,
figcaption {
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.7) 0, rgba($color: $black, $alpha: 0.3) 70%, transparent);
position: absolute;
bottom: 0;
right: 0;
left: 0;
max-height: 100%;
}

// Create a background blur layer.
&:has(figcaption)::before {
content: "";
z-index: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

There doesn't seem to be any visual difference without z-index: 0, but is it necessary?

height: 100%;
max-height: 40%;

// Blur the background under the gradient scrim.
backdrop-filter: blur(4px);

// Crop the caption so the blur is only on the edge.
mask-image: linear-gradient(0deg, rgba($color: $black, $alpha: 1) 20%, rgba($color: $black, $alpha: 0) 100%);
jasmussen marked this conversation as resolved.
Show resolved Hide resolved
}

// Place the caption at the bottom.
figcaption {
z-index: 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

There doesn't seem to be any visual difference without z-index: 1, but is it necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch on both z-indexes. They were briefly necessary in one of the versions I was testing, but in this final version they are not.

color: $white;
text-shadow: 0 0 1.5px rgba($color: $black, $alpha: 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
text-shadow: 0 0 1.5px rgba($color: $black, $alpha: 1);
text-shadow: 0 0 1.5px $black;

Since rgba($color: $black, $alpha: 1) is the same as black, I think it can be made simpler.

font-size: $default-font-size;
left: 0;
margin-bottom: 0;
max-height: 60%;
margin: 0;
overflow: auto;
padding: 0 8px 8px;
position: absolute;
padding: 1em;
Copy link
Contributor

@t-hamano t-hamano Aug 17, 2024

Choose a reason for hiding this comment

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

This is a non-blocker suggestion.

Because scrollbar-gutter: stable both-edges has been applied to the figcaption, the padding on the left and right looks wider, we may want to make it a little smaller.

Below is what it looks like on my environment, but how does it look on yours?

padding: 1em:

image

padding: 1em 0.5em:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't disagree, though since this PR already touches a fair bit of CSS, I wonder if it's not best to do this separately?

Thank you again for the thorough reviews!

text-align: center;
width: 100%;
box-sizing: border-box;
@include custom-scrollbars-on-hover(transparent, rgba($white, 0.8));

// Dark gradient scrim.
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.4) 0%, rgba($color: $black, $alpha: 0) 100%, transparent);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.4) 0%, rgba($color: $black, $alpha: 0) 100%, transparent);
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.4) 0%, transparent 100%);

The gradient style should remain the same.


img {
display: inline;
}
Expand All @@ -85,6 +109,10 @@ figure.wp-block-gallery.has-nested-images {
margin: 0;
padding: 10px 10px 9px;
position: relative;
text-shadow: none;
}
&::before {
content: none;
}
}
}
Expand Down
Loading