Преглед изворни кода

Added close button for photo-viewer

master
jochen пре 1 година
родитељ
комит
6ae9bae8df
2 измењених фајлова са 33 додато и 5 уклоњено
  1. +13
    -5
      client/src/components/photo-viewer/photo-viewer.js
  2. +20
    -0
      client/src/components/photo-viewer/photo-viewer.scss

+ 13
- 5
client/src/components/photo-viewer/photo-viewer.js Прегледај датотеку

@@ -2,7 +2,7 @@ import * as React from "react";
import {createRef, useEffect, useState} from "react";

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";

export function PhotoViewer() {
@@ -36,6 +36,9 @@ export function PhotoViewer() {
setSelectedPhotoIndex(selectedPhotoIndex + 1);
}
}
const handleClose = () => {
setSelectedPhotoIndex(-1);
}
const handleKeyUp = (e) => {
switch (e.code) {
case "ArrowLeft":
@@ -103,10 +106,11 @@ export function PhotoViewer() {
{hasPrevious && <ArrowLeft/>}
</div>
<div id="photoSlider">
{hasPrevious && <div className="photo photo--placeholder photo--previous" style={previousPhotoStyle}>
<img src={`${selectedAlbum.photos[selectedPhotoIndex - 1].url}`}
alt={selectedAlbum.photos[selectedPhotoIndex - 1].name}/>
</div>}
{hasPrevious &&
<div className="photo photo--placeholder photo--previous" style={previousPhotoStyle}>
<img src={`${selectedAlbum.photos[selectedPhotoIndex - 1].url}`}
alt={selectedAlbum.photos[selectedPhotoIndex - 1].name}/>
</div>}
<div className="photo photo--invisible">
<img src={`${selectedAlbum.photos[selectedPhotoIndex].url}`}
alt={selectedAlbum.photos[selectedPhotoIndex].name}/>
@@ -123,6 +127,10 @@ export function PhotoViewer() {
<div className="goto-btn goto-btn--next" onClick={handleGoNext}>
{hasNext && <ArrowRight/>}
</div>

<div className="close-btn" onClick={handleClose}>
{hasNext && <Close/>}
</div>
</div> : null}
</>
}

+ 20
- 0
client/src/components/photo-viewer/photo-viewer.scss Прегледај датотеку

@@ -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 {
cursor: pointer;
flex: 1;


Loading…
Откажи
Сачувај