Skip to content

Commit

Permalink
Add image gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
blagoslav-mihaylov committed Mar 16, 2021
1 parent 856c80b commit 06722c6
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 4 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"build": "webpack --config webpack/build.config.js",
"serve": "webpack serve --env API_HOST=https://d1tapi.dabulgaria.bg --config webpack/serve.config.js"
"serve": "webpack serve --env API_HOST=https://api.tibroish.bg --config webpack/serve.config.js"
},
"author": "",
"dependencies": {
Expand All @@ -31,6 +31,7 @@
"normalize.css": "^8.0.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-image": "^4.0.3",
"react-reveal": "^1.2.2",
"react-router-dom": "^5.2.0",
"react-use-keypress": "^1.2.0",
Expand Down
114 changes: 111 additions & 3 deletions src/components/process_protocols/ProtocolPhotos.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useState, useEffect } from 'react';

import styled from 'styled-components';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faChevronLeft, faChevronRight } from '@fortawesome/free-solid-svg-icons';
import { faChevronLeft, faChevronRight, faTh } from '@fortawesome/free-solid-svg-icons';
import useKeypress from 'react-use-keypress';
import { SpinnerCircularFixed } from 'spinners-react';
import { Img } from 'react-image';

const PhotoSection = styled.div`
width: 50vw;
Expand Down Expand Up @@ -42,6 +44,56 @@ const PageNavButton = styled.button`
}
`;

const PhotoGallery = styled.div`
width: 50vw;
height: 100vh;
overflow-y: auto;
background-color: black;
position: absolute;
top: 0;
left: 0;
//img {
// width: calc(100% / 3);
// margin-top: 20px;
//}
`;

const GalleryButton = styled.button`
color: white;
position: absolute;
top: 10px;
left: 5px;
cursor: pointer;
background: none;
border: none;
font-size: 36px;
border-radius: 10px;
&:hover {
background-color: #333;
}
`;

const GalleryPhotoButton = styled.button`
width: calc(100% / 3);
cursor: pointer;
background: none;
border: none;
//margin: 5px;
padding: 5px;
img {
width: 100%;
}
&:hover {
img {
box-shadow: 0px 0px 20px yellow;
}
}
`;

export default props => {
const [page, setPage] = useState(0);

Expand Down Expand Up @@ -75,10 +127,66 @@ export default props => {
};

return(
page === null?
<PhotoGallery>
{props.protocol.pictures.map((picture, i) =>
<GalleryPhotoButton>
<Img
src={picture.url}
onClick={()=>setPage(i)}
loader={
<SpinnerCircularFixed
speed={400}
color={'#ddd'}
secondaryColor={'#aaa'}
thickness={70}
/>
}
/>
</GalleryPhotoButton>
)}
</PhotoGallery> :
<PhotoSection>
<GalleryButton onClick={() => setPage(null)}>
<FontAwesomeIcon icon={faTh}/>
</GalleryButton>
{pageNav()}
{props.protocol.pictures.map((picture, i) =>
<Img
style={page === i? {} : {display: 'none'}}
src={picture.url}
loader={
<SpinnerCircularFixed
speed={400}
color={'#ddd'}
secondaryColor={'#aaa'}
thickness={70}
/>
}
/>
)}
{pageNav()}
</PhotoSection>
);

/*return(
<PhotoSection>
{pageNav()}
<img src={props.protocol.pictures[page].url}/>
{props.protocol.pictures.map((picture, i) =>
<Img
style={page === i? {} : {display: 'none'}}
src={picture.url}
loader={
<SpinnerCircularFixed
speed={400}
color={'#ddd'}
secondaryColor={'#aaa'}
thickness={70}
/>
}
/>
)}
{pageNav()}
</PhotoSection>
);
);*/
};
1 change: 1 addition & 0 deletions static/loading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06722c6

Please sign in to comment.