mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
import Lightbox, { Image } from 'react-images';
|
|
|
|
interface ImageGalerieState {
|
|
selectedImage: number;
|
|
showLightbox: boolean;
|
|
}
|
|
|
|
class ImageGalerie extends React.Component<undefined, ImageGalerieState> {
|
|
constructor(props: undefined) {
|
|
super(props);
|
|
this.state = {selectedImage: 0, showLightbox: true};
|
|
}
|
|
|
|
render() {
|
|
const images: Image[] = [
|
|
{
|
|
src: "http://localhost:8080/img1.jpg",
|
|
alt: "Image 1",
|
|
caption: "Image 1",
|
|
},
|
|
{
|
|
src: "http://localhost:8080/img2.jpg",
|
|
alt: "Image 2",
|
|
caption: "Image 2",
|
|
}];
|
|
|
|
return <Lightbox
|
|
isOpen={this.state.showLightbox}
|
|
images={images}
|
|
onClose={() => this.setState({showLightbox: false})}
|
|
onClickImage={e => {}}
|
|
onClickNext={() => this.setState({selectedImage: (this.state.selectedImage + 1) % images.length})}
|
|
onClickPrev={() => this.setState({selectedImage: this.state.selectedImage === 0 ? images.length : this.state.selectedImage - 1})}
|
|
showThumbnails={true}
|
|
onClickThumbnail={(index) => this.setState({selectedImage: index})}
|
|
/>;
|
|
}
|
|
}
|