Minor UI fixes for updated Lightbox

This commit is contained in:
Fedor Indutny 2023-03-07 09:32:00 -08:00 committed by GitHub
parent a9395ddecc
commit cd5ac544bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 60 deletions

View file

@ -3,7 +3,7 @@
.Lightbox { .Lightbox {
&__container { &__container {
background-color: $color-gray-90; background-color: $color-black;
bottom: 0; bottom: 0;
left: 0; left: 0;
position: absolute; position: absolute;
@ -52,6 +52,10 @@
} }
} }
&__thumbnails_placeholder {
height: 44px;
}
&__thumbnail { &__thumbnail {
@include button-reset; @include button-reset;
position: relative; position: relative;
@ -210,10 +214,11 @@
&__header { &__header {
align-items: center; align-items: center;
display: flex; display: flex;
height: 56px; height: 52px;
justify-content: space-between; justify-content: space-between;
margin-top: calc(12px + var(--title-bar-drag-area-height)); margin-top: var(--title-bar-drag-area-height);
min-height: 56px; margin-bottom: 16px;
min-height: 52px;
opacity: 1; opacity: 1;
padding: 0 16px; padding: 0 16px;
transition: opacity 150ms cubic-bezier(0.17, 0.17, 0, 1); transition: opacity 150ms cubic-bezier(0.17, 0.17, 0, 1);
@ -239,7 +244,7 @@
&__footer { &__footer {
opacity: 1; opacity: 1;
padding: 20px 16px; padding: 16px 16px 24px 16px;
transition: opacity 150ms cubic-bezier(0.17, 0.17, 0, 1); transition: opacity 150ms cubic-bezier(0.17, 0.17, 0, 1);
} }
@ -250,6 +255,17 @@
} }
} }
&__container--has-controls {
.Lightbox__nav-next,
.Lightbox__nav-prev {
// Give some room for <video/>'s controls.
$controls-height: 64px;
padding-top: $controls-height;
height: calc(100% - $controls-height);
}
}
&__controls { &__controls {
display: flex; display: flex;
gap: 32px; gap: 32px;

View file

@ -430,7 +430,7 @@ export function Lightbox({
const caption = attachment?.caption; const caption = attachment?.caption;
let content: JSX.Element; let content: JSX.Element;
let hasFooter = true; let hasControls = false;
if (!contentType) { if (!contentType) {
content = <>{children}</>; content = <>{children}</>;
} else { } else {
@ -498,7 +498,7 @@ export function Lightbox({
</video> </video>
); );
hasFooter = false; hasControls = true;
} else if (isUnsupportedImageType || isUnsupportedVideoType) { } else if (isUnsupportedImageType || isUnsupportedVideoType) {
content = ( content = (
<button <button
@ -536,6 +536,7 @@ export function Lightbox({
<div <div
className={classNames('Lightbox Lightbox__container', { className={classNames('Lightbox Lightbox__container', {
'Lightbox__container--zoom': isZoomed, 'Lightbox__container--zoom': isZoomed,
'Lightbox__container--has-controls': hasControls,
})} })}
onClick={(event: React.MouseEvent<HTMLDivElement>) => { onClick={(event: React.MouseEvent<HTMLDivElement>) => {
event.stopPropagation(); event.stopPropagation();
@ -633,7 +634,6 @@ export function Lightbox({
)} )}
</animated.div> </animated.div>
</div> </div>
{hasFooter ? (
<div className="Lightbox__footer"> <div className="Lightbox__footer">
{isViewOnce && videoTime ? ( {isViewOnce && videoTime ? (
<div className="Lightbox__timestamp"> <div className="Lightbox__timestamp">
@ -643,7 +643,7 @@ export function Lightbox({
{caption ? ( {caption ? (
<div className="Lightbox__caption">{caption}</div> <div className="Lightbox__caption">{caption}</div>
) : null} ) : null}
{media.length > 1 && ( {media.length > 1 ? (
<div className="Lightbox__thumbnails--container"> <div className="Lightbox__thumbnails--container">
<div <div
className="Lightbox__thumbnails" className="Lightbox__thumbnails"
@ -662,10 +662,7 @@ export function Lightbox({
key={item.thumbnailObjectUrl} key={item.thumbnailObjectUrl}
type="button" type="button"
onClick={( onClick={(
event: React.MouseEvent< event: React.MouseEvent<HTMLButtonElement, MouseEvent>
HTMLButtonElement,
MouseEvent
>
) => { ) => {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
@ -685,9 +682,10 @@ export function Lightbox({
))} ))}
</div> </div>
</div> </div>
) : (
<div className="Lightbox__thumbnails_placeholder" />
)} )}
</div> </div>
) : null}
</div> </div>
</div>, </div>,
root root