Skip to content

Commit

Permalink
Fix lightbox trigger styles (#55859)
Browse files Browse the repository at this point in the history
* Update icons

* Update styles

* Tweak offset values to 16
  • Loading branch information
richtabor authored and mikachan committed Nov 5, 2023
1 parent 6fcbf00 commit 25e9300
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
7 changes: 3 additions & 4 deletions packages/block-library/src/image/index.php
Expand Up @@ -242,10 +242,9 @@ class="lightbox-trigger"
data-wp-on--click="actions.core.image.showLightbox"
data-wp-style--right="context.core.image.imageButtonRight"
data-wp-style--top="context.core.image.imageButtonTop"
style="background: #000"
>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" aria-hidden="true" focusable="false">
<Path stroke="#FFFFFF" d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none" viewBox="0 0 12 12">
<path fill="#fff" d="M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z" />
</svg>
</button>';

Expand Down Expand Up @@ -303,7 +302,7 @@ class="lightbox-trigger"
}
}

$close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
$close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
$close_button_label = esc_attr__( 'Close' );

$lightbox_html = <<<HTML
Expand Down
25 changes: 15 additions & 10 deletions packages/block-library/src/image/style.scss
Expand Up @@ -168,22 +168,27 @@
button {
opacity: 0;
border: none;
background: #000;
background-color: rgb(90 90 90 / 25%);
backdrop-filter: blur($grid-unit-20) saturate(180%);
cursor: zoom-in;
width: 24px;
height: 24px;
display: flex;
justify-content: center;
align-items: center;
width: 20px;
height: 20px;
position: absolute;
z-index: 100;
top: 10px;
right: 10px;
top: 16px;
right: 16px;
text-align: center;
padding: 0;
border-radius: 10%;
border-radius: 4px;
transition: opacity 0.2s ease;

&:focus-visible {
outline: 5px auto #212121;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: 5px;
outline: 3px auto rgb(90 90 90 / 25%);
outline: 3px auto -webkit-focus-ring-color;
outline-offset: 3px;
}

&:hover {
Expand All @@ -198,7 +203,7 @@
&:hover,
&:focus,
&:not(:hover):not(:active):not(.has-background) {
background: #000;
background-color: rgb(90 90 90 / 25%);
border: none;
}
}
Expand Down
12 changes: 6 additions & 6 deletions packages/block-library/src/image/view.js
Expand Up @@ -340,26 +340,26 @@ store(
context.core.image.imageButtonTop =
( offsetHeight - referenceHeight ) / 2 +
buttonOffsetTop +
10;
16;
context.core.image.imageButtonRight =
buttonOffsetRight + 10;
buttonOffsetRight + 16;
} else {
// If it reaches the height first, keep
// the height and compute the width.
const referenceWidth =
offsetHeight * naturalRatio;
context.core.image.imageButtonTop =
buttonOffsetTop + 10;
buttonOffsetTop + 16;
context.core.image.imageButtonRight =
( offsetWidth - referenceWidth ) / 2 +
buttonOffsetRight +
10;
16;
}
} else {
context.core.image.imageButtonTop =
buttonOffsetTop + 10;
buttonOffsetTop + 16;
context.core.image.imageButtonRight =
buttonOffsetRight + 10;
buttonOffsetRight + 16;
}
},
setStylesOnResize: ( { state, context, ref } ) => {
Expand Down

0 comments on commit 25e9300

Please sign in to comment.