This commit is contained in:
@@ -2,7 +2,7 @@ import * as React from "react";
|
|||||||
import {createRef, useEffect, useState} from "react";
|
import {createRef, useEffect, useState} from "react";
|
||||||
|
|
||||||
import "./photo-viewer.scss"
|
import "./photo-viewer.scss"
|
||||||
import {ArrowLeft, ArrowRight} from "@mui/icons-material";
|
import {ArrowLeft, ArrowRight, Close} from "@mui/icons-material";
|
||||||
import {useCurrentInstance} from "../../services/current-instance/use-current-instance";
|
import {useCurrentInstance} from "../../services/current-instance/use-current-instance";
|
||||||
|
|
||||||
export function PhotoViewer() {
|
export function PhotoViewer() {
|
||||||
@@ -36,6 +36,9 @@ export function PhotoViewer() {
|
|||||||
setSelectedPhotoIndex(selectedPhotoIndex + 1);
|
setSelectedPhotoIndex(selectedPhotoIndex + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const handleClose = () => {
|
||||||
|
setSelectedPhotoIndex(-1);
|
||||||
|
}
|
||||||
const handleKeyUp = (e) => {
|
const handleKeyUp = (e) => {
|
||||||
switch (e.code) {
|
switch (e.code) {
|
||||||
case "ArrowLeft":
|
case "ArrowLeft":
|
||||||
@@ -103,10 +106,11 @@ export function PhotoViewer() {
|
|||||||
{hasPrevious && <ArrowLeft/>}
|
{hasPrevious && <ArrowLeft/>}
|
||||||
</div>
|
</div>
|
||||||
<div id="photoSlider">
|
<div id="photoSlider">
|
||||||
{hasPrevious && <div className="photo photo--placeholder photo--previous" style={previousPhotoStyle}>
|
{hasPrevious &&
|
||||||
<img src={`${selectedAlbum.photos[selectedPhotoIndex - 1].url}`}
|
<div className="photo photo--placeholder photo--previous" style={previousPhotoStyle}>
|
||||||
alt={selectedAlbum.photos[selectedPhotoIndex - 1].name}/>
|
<img src={`${selectedAlbum.photos[selectedPhotoIndex - 1].url}`}
|
||||||
</div>}
|
alt={selectedAlbum.photos[selectedPhotoIndex - 1].name}/>
|
||||||
|
</div>}
|
||||||
<div className="photo photo--invisible">
|
<div className="photo photo--invisible">
|
||||||
<img src={`${selectedAlbum.photos[selectedPhotoIndex].url}`}
|
<img src={`${selectedAlbum.photos[selectedPhotoIndex].url}`}
|
||||||
alt={selectedAlbum.photos[selectedPhotoIndex].name}/>
|
alt={selectedAlbum.photos[selectedPhotoIndex].name}/>
|
||||||
@@ -123,6 +127,10 @@ export function PhotoViewer() {
|
|||||||
<div className="goto-btn goto-btn--next" onClick={handleGoNext}>
|
<div className="goto-btn goto-btn--next" onClick={handleGoNext}>
|
||||||
{hasNext && <ArrowRight/>}
|
{hasNext && <ArrowRight/>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="close-btn" onClick={handleClose}>
|
||||||
|
{hasNext && <Close/>}
|
||||||
|
</div>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@@ -41,6 +41,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.close-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 15px;
|
||||||
|
right: 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
svg {
|
||||||
|
color: white;
|
||||||
|
opacity: 0.15;
|
||||||
|
width: 75px;
|
||||||
|
height: 75px;
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
width: 75px;
|
||||||
|
height: 75px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.goto-btn {
|
.goto-btn {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user