blob: 169c5ec871f43cd81e98d3287f49f3f8ecb862b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import React, { Component } from 'react';
import 'ba-styles/vendors/image-lightbox/image-lightbox.css';
import images from 'ba-api/imgData';
import { ImageLightbox } from 'ba-components';
import { Button, Grid } from '@material-ui/core';
export default class ImagePopup extends Component {
constructor(props) {
super(props);
this.state = {
photoIndex: 0,
isOpen: false,
};
}
render() {
const { photoIndex, isOpen } = this.state;
return (
<Grid
container
alignItems="center"
justify="center"
direction="column"
>
<Button variant="contained" color="secondary" onClick={() => this.setState({ isOpen: true })}>
Open Image Lightbox
</Button>
{isOpen && (
<ImageLightbox
mainSrc={images[photoIndex].img}
nextSrc={images[(photoIndex + 1) % images.length].img}
prevSrc={images[(photoIndex + (images.length - 1)) % images.length].img}
onCloseRequest={() => this.setState({ isOpen: false })}
onMovePrevRequest={() => this.setState({
photoIndex: (photoIndex + (images.length - 1)) % images.length,
})
}
onMoveNextRequest={() => this.setState({
photoIndex: (photoIndex + 1) % images.length,
})
}
/>
)}
</Grid>
);
}
}
|