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

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

Merged

Conversation

artemiomorales
Copy link
Contributor

@artemiomorales artemiomorales commented Jun 2, 2023

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
Copy link
Contributor

@SantosGuillamot SantosGuillamot left a comment

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.

packages/block-library/src/image/interactivity.js Outdated Show resolved Hide resolved
packages/block-library/src/image/style.scss Outdated Show resolved Hide resolved
@artemiomorales
Copy link
Contributor Author

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

@artemiomorales artemiomorales merged commit cfdbd85 into WordPress:trunk Jun 6, 2023
48 checks passed
@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
3 participants