1
|
|
|
import React, { useState, useCallback } from 'react' |
2
|
|
|
import { Translate } from 'react-localize-redux' |
3
|
|
|
import Container from '~/modules/home/components/project/Container' |
4
|
|
|
import Header from '~/modules/home/components/common/section/Header' |
5
|
|
|
import Content from '~/modules/home/components/project/Content' |
6
|
|
|
import SelectedImage from '~/modules/home/components/project/SelectedImage' |
7
|
|
|
import { PROJECTS } from '~/modules/home/consts/pages' |
8
|
|
|
import Anchor from '~/modules/home/components/common/Anchor' |
9
|
|
|
import Gallery from 'react-photo-gallery' |
10
|
|
|
import Carousel, { Modal, ModalGateway } from 'react-images' |
11
|
|
|
import { photos } from '~/modules/home/consts/photos.js' |
12
|
|
|
import useWindowDimensions from '~/modules/core/utils/useWindowDimensions' |
13
|
|
|
|
14
|
1 |
|
const Project = () => { |
15
|
1 |
|
const { width } = useWindowDimensions() |
16
|
1 |
|
const [currentImage, setCurrentImage] = useState(0) |
17
|
1 |
|
const [viewerIsOpen, setViewerIsOpen] = useState(false) |
18
|
|
|
|
19
|
1 |
|
const openLightbox = useCallback(index => { |
20
|
|
|
setCurrentImage(index) |
21
|
|
|
setViewerIsOpen(true) |
22
|
|
|
}, []) |
23
|
|
|
|
24
|
1 |
|
const closeLightbox = () => { |
25
|
|
|
setCurrentImage(0) |
26
|
|
|
setViewerIsOpen(false) |
27
|
|
|
} |
28
|
1 |
|
const imageRenderer = useCallback(({ index, key, photo }) => ( |
29
|
|
|
<SelectedImage |
30
|
|
|
key={key} |
31
|
|
|
margin={'2px'} |
32
|
|
|
index={index} |
33
|
|
|
photo={photo} |
34
|
|
|
onClick={openLightbox} |
35
|
|
|
/> |
36
|
|
|
)) |
37
|
|
|
|
38
|
1 |
|
return ( |
39
|
|
|
<Container> |
40
|
|
|
<Anchor id={PROJECTS} top={-125} /> |
41
|
|
|
<Header> |
42
|
|
|
<h2> |
43
|
|
|
<Translate id="Project: Title" /> |
44
|
|
|
</h2> |
45
|
|
|
<h4> |
46
|
|
|
<Translate id="Project: SubTitle" /> |
47
|
|
|
</h4> |
48
|
|
|
</Header> |
49
|
|
|
<Content> |
50
|
|
|
<Gallery |
51
|
|
|
photos={photos} |
52
|
|
|
direction={width < 768 ? 'column' : 'row'} |
53
|
|
|
renderImage={imageRenderer} |
54
|
|
|
/> |
55
|
|
|
<ModalGateway> |
56
|
|
|
{viewerIsOpen ? ( |
57
|
|
|
<Modal onClose={closeLightbox}> |
58
|
|
|
<Carousel |
59
|
|
|
currentIndex={currentImage} |
60
|
|
|
views={photos.map(x => ({ |
61
|
|
|
...x, |
62
|
|
|
src: `${x.src}.jpg`, |
63
|
|
|
srcSet: `${x.src}.jpg`, |
64
|
|
|
caption: x.title |
65
|
|
|
}))} |
66
|
|
|
/> |
67
|
|
|
</Modal> |
68
|
|
|
) : null} |
69
|
|
|
</ModalGateway> |
70
|
|
|
</Content> |
71
|
|
|
</Container> |
72
|
|
|
) |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
export default Project |
76
|
|
|
|