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 a white style variant for gallery caption backgrounds #24897

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
13 changes: 12 additions & 1 deletion packages/block-library/src/gallery/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { __, _x } from '@wordpress/i18n';
import { gallery as icon } from '@wordpress/icons';

/**
Expand All @@ -22,6 +22,17 @@ export const settings = {
description: __( 'Display multiple images in a rich gallery.' ),
icon,
keywords: [ __( 'images' ), __( 'photos' ) ],
styles: [
{
name: 'default',
label: _x( 'Default', 'block style' ),
isDefault: true,
},
{
name: 'white-caption-background',
label: _x( 'White caption background', 'block style' ),
},
],
example: {
attributes: {
columns: 2,
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/gallery/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
font-size: $default-font-size;
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.7) 0, rgba($color: $black, $alpha: 0.3) 70%, transparent);

// White background variation
.is-style-white-caption-background & {
color: inherit;
Copy link
Member

Choose a reason for hiding this comment

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

I think we could add user-selected colors for the caption and links within. In that case, would it make sense that this color is opinionated (black-ish) if the user hasn't selected any color?

Copy link
Contributor

Choose a reason for hiding this comment

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

I do like the idea of the user providing the colors and having some defaults.

The gradient has actually been slightly headachy because it doesn't work with multiple lines. Not that we can change it easily, but I do like the idea of Global Styles expanding the palette here.

background: linear-gradient(0deg, rgba($color: $white, $alpha: 0.7) 0, rgba($color: $white, $alpha: 0.3) 70%, rgba($color: $white, $alpha: 0));
}

img {
display: inline;
}
Expand Down