Skip to content

Image: Fix design of close button for the lightbox (correct PR)#51206

Merged
artemiomorales merged 10 commits into
WordPress:trunkfrom
artemiomorales:fix/lightbox-close-button-design
Jun 6, 2023
Merged

Image: Fix design of close button for the lightbox (correct PR)#51206
artemiomorales merged 10 commits into
WordPress:trunkfrom
artemiomorales:fix/lightbox-close-button-design

Conversation

@artemiomorales

@artemiomorales artemiomorales commented Jun 2, 2023

Copy link
Copy Markdown
Contributor

What?

This PR changes the design of the close button in the lightbox so that it is easily visible at all times.
Additionally, it ensures the image is contained within the lightbox so that the close button design is implemented as closely as possible.

Why?

Fixes #51126, wherein the close button was appearing on top of images and was hard to see in cases where the image was dark, and also fixes #51125, #51170, and #51171 as a part of those changes.

How?

It rebases on top of and replaces #51164 to make use of those fixes, then uses and sets the close button color to be the theme contrast color, adds padding, and makes the close button smaller.

Testing Instructions

  1. Ensure the Interactivity API and Behaviors UI setting is enabled in Gutenberg > Experiments in the admin.
  2. Create a new post and insert a vertically oriented image as well as a horizontally oriented one.
  3. Activate the image lightboxes via Advanced > Behaviors > Lightbox in block settings.
  4. Publish and view the post.
  5. Click on the images; in the lightbox, the close button should be clearly visible and unobscured by the image.
  6. Change the theme background color and contrast color. (Note: Manually setting these colors individually will not work, I believe due to wp_get_global_styles: return values instead of CSS Custom Properties #49712, but you can experiment with changing theme styles.)
  7. Test again to ensure that the colors are applied as expected.

Testing Instructions for Keyboard

  • When viewing the post, tab to the image instead and press Enter or Space to open the lightbox.
  • See that the close button and focus are visible.

@artemiomorales artemiomorales force-pushed the fix/lightbox-close-button-design branch from 252521c to 85182b5 Compare June 5, 2023 08:03

@SantosGuillamot SantosGuillamot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks good to me 🙂 It seems to solve the mentioned issues, and it matches the design shared here.

I just left a couple of minor comments.

Comment thread packages/block-library/src/image/interactivity.js Outdated
Comment thread packages/block-library/src/image/style.scss Outdated
@artemiomorales

Copy link
Copy Markdown
Contributor Author

@SantosGuillamot Thanks for the review! I removed the obsolete code 👍

@artemiomorales artemiomorales merged commit cfdbd85 into WordPress:trunk Jun 6, 2023
@github-actions github-actions Bot added this to the Gutenberg 16.0 milestone Jun 6, 2023
@ndiego ndiego added [Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Experimental Experimental feature or API. labels Jun 7, 2023
sethrubenstein pushed a commit to pewresearch/gutenberg that referenced this pull request Jul 13, 2023
…Press#51206)

* Revise CSS to contain images within overlay properly

* Set horizontal images to occupy space of container

* Make square images fit by height rather than expand to full width

* Revise so lightbox loads original image; remove padding and hide caption

The lightbox will now load the original image when opened;
the src attribute is set dynamically so it will not be
unnecessarily loaded by the browser.

In addition, removed the padding and hid the caption.

* Fix PHP spacing for linter

* Fix test; image src is now only set after lightbox opens

* Improve styles for lightbox close button

* Fix PHP spacing for linter

* Darken the scrim

* Remove obsolte code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Interactivity API API to add frontend interactivity to blocks. [Type] Experimental Experimental feature or API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image: Close button in the lightbox hard to see with dark images Image: Vertical image from URL cut when displayed in the lightbox

3 participants