Lightbox controls style fixes

This commit is contained in:
kvakazyambra 2023-11-23 00:31:51 +03:00
parent e716dd9304
commit 57a289e383
2 changed files with 37 additions and 13 deletions

View File

@ -4,7 +4,7 @@
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: rgb(0 0 0 / 80%); background-color: rgb(0 0 0 / 50%);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -13,10 +13,12 @@
.image { .image {
max-width: 90%; max-width: 90%;
max-height: 80%; max-height: 80%;
cursor: pointer; cursor: grab;
} }
.close { .close {
background: rgb(0 0 0 / 50%);
border-radius: 100%;
position: fixed; position: fixed;
z-index: 1001; z-index: 1001;
top: 20px; top: 20px;
@ -24,8 +26,16 @@
font-size: 30px; font-size: 30px;
color: white; color: white;
cursor: pointer; cursor: pointer;
width: 20px; width: 36px;
height: 20px; height: 36px;
.icon {
height: 20px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 20px;
}
} }
.zoomControls { .zoomControls {
@ -39,16 +49,26 @@
z-index: 1001; z-index: 1001;
.control { .control {
background-color: rgb(0 0 0 / 50%);
border-radius: 50%; border-radius: 50%;
width: 24px; width: 30px;
height: 24px; height: 30px;
font-size: 20px; font-size: 24px;
line-height: 1; line-height: 1;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border: 2px solid #fff; transition: background-color 0.3s;
color: #fff; color: #fff;
&:hover {
background-color: #000;
}
}
.controlDefault {
font-size: 1.2rem;
letter-spacing: 0.15em;
} }
} }
} }

View File

@ -28,6 +28,10 @@ export const Lightbox = (props: Props) => {
event.stopPropagation() event.stopPropagation()
setZoomLevel(zoomLevel() / ZOOM_STEP) setZoomLevel(zoomLevel() / ZOOM_STEP)
} }
const zoomReset = (event) => {
event.stopPropagation()
setZoomLevel(1)
}
const lightboxStyle = () => ({ const lightboxStyle = () => ({
transform: `scale(${zoomLevel()})`, transform: `scale(${zoomLevel()})`,
@ -39,17 +43,17 @@ export const Lightbox = (props: Props) => {
return ( return (
<div class={clsx(styles.Lightbox, props.class)} onClick={closeLightbox}> <div class={clsx(styles.Lightbox, props.class)} onClick={closeLightbox}>
<span class={styles.close} onClick={closeLightbox}> <span class={styles.close} onClick={closeLightbox}>
<Icon name="close-white" /> <Icon name="close-white" class={styles.icon} />
</span> </span>
<div class={styles.zoomControls}> <div class={styles.zoomControls}>
<button class={styles.control} onClick={(event) => zoomOut(event)}> <button class={styles.control} onClick={(event) => zoomOut(event)}>
<b>-</b> &minus;
</button> </button>
<button class={styles.control} onClick={() => setZoomLevel(1)}> <button class={clsx(styles.control, styles.controlDefault)} onClick={(event) => zoomReset(event)}>
<b style={{ 'font-size': '10px' }}>1:1</b> 1:1
</button> </button>
<button class={styles.control} onClick={(event) => zoomIn(event)}> <button class={styles.control} onClick={(event) => zoomIn(event)}>
<b>+</b> +
</button> </button>
</div> </div>
<img <img