
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-modal-slideshow
Advanced tools
A simple React modal media slideshow with CSS powered animations
A simple React modal media slideshow with CSS powered animations.
$ npm install react-modal-slideshow
https://tiush.github.io/react-simple-modal-slideshow/
Or locally:
$ git clone https://github.com/null-none/react-modal-slideshow.git
$ cd react-modal-slideshow
$ npm install
$ npm run dev
import { Component } from 'react';
import SimpleModalSlideshow from 'react-modal-slideshow';
export default SomeComponent extends Component {
/* (...) */
render() {
return (
<SimpleModalSlideshow
slides={[{
title: (
<h2>Title</h2>
),
media: (
<img src="https://unsplash.it/600/400?image=0" />
),
content: (
<div>
Donec id elit non mi porta gravida at eget metus.
Sed posuere consectetur est at lobortis.
</div>
),
}, {
title: (
<h2>Title</h2>
),
media: (
<img src="https://unsplash.it/600/400?image=1" />
),
content: (
<div>
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Donec ullamcorper nulla non metus auctor fringilla.
Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
</div>
),
}]}
open={this.state.open}
currentSlide={this.state.currentSlide}
onClose={::this.handleClose}
onNext={::this.handleNext}
onPrev={::this.handlePrev}
/>
);
}
}
Then copy the lib/simple-modal-slideshow.css, and include it in your HTML page if you want to
use the default styling. Or you can directly import src/simple-modal-slideshow.scss from a SASS
file. See Styling for more informations.
required | Type: Array | Default: undefined
Each slide is represented by an object :
Type: Anything that can be rendered | Default: undefined
Optional content to be displayed with the title.
required | Type: Anything that can be rendered | Default: undefined
Media element of the slide.
Type: Anything that can be rendered | Default: undefined
Optional content to be displayed with the media.
Type: Boolean | Default: false
Whether the modal is opened.
Type: Integer | Default: 0
Index of the slide to display (if modal is opened).
Type: Boolean| Default: false
If set to true the public API will be enabled, and props open and currentSlide
will be ignored. See the API section for more informations. Warning: Please note
that this prop has been designed to be statically set (e.g. enableApi={true}), so updating
this value during the lifecycle of the component may lead to an unknown behaviour.
Type: String| Default: modal-slideshow
Every HTML class name in this component is prefix with this string (see Styling). You can set this prop for example if you want to style multiple slideshows differently.
Type: Boolean | Default: true
If set to true modal animations (opening and closing) will be enabled.
See the Animations section for more informations.
Type: Boolean | Default: true
If set to true slide animations (when updating current slide index) will be enabled.
See the Animations section for more informations.
Type: Integer | Default: 300
Modal enter CSS animation duration.
Type: Integer | Default: 300
Modal leave CSS animation duration.
Type: Integer | Default: 300
Slide enter CSS animation duration. Note that it will be the same for left and right
animations.
Type: Integer | Default: 300
Slide leave CSS animation duration. Note that it will be the same for left and right
animations.
Type: Function | Default: undefined
Function called when the user clicks on the a.modal-slideshow__close tag,
or when he hit the ESC key.
If enableApi is set to true and this prop is omitted the component will automatically
close the slideshow. Otherwise this function is responsible for closing the slideshow.
Type: Function | Default: undefined
Function called when the user clicks on the a.modal-slideshow__controls--prev tag,
or when he hit the left arrow key. The function is called with the previous slide index
as an argument.
If enableApi is set to true and this prop is omitted the component will automatically
go to the previous slide. Otherwise this function is responsible for updating the current
slide index.
Type: Function | Default: undefined
Function called when the user clicks on the a.modal-slideshow__controls--next tag,
or when he hit the right arrow key. The function is called with the next slide index
as an argument.
If enableApi is set to true and this prop is omitted the component will automatically
go to the next slide. Otherwise this function is responsible for updating the current
slide index.
When the API is enabled (using the enableApi prop), the props open and currentIndex
are ignored. This way we prevent any situation where the props may be inconsistent with the state
of the component.
Integer | Default: undefinedOpens the modal slideshow. Optionally you can specify a slide index to open to a specific slide.
Integer | Default: undefinedGoes to a specific slide index.
Goes to the next slide.
Goes to the previous slide.
Closes the modal slideshow.
The slideshow is fully custimizable through CSS, or even better with SASS. Here is the full HTML structure of the modal when opened :
<div class="modal-slideshow">
<a class="modal-slideshow__close">
Close
</a>
<div>
<div class="modal-slideshow__slide">
<div class="modal-slideshow__media">
<!-- slide.media -->
<div class="modal-slideshow__controls">
<a class="modal-slideshow__controls--prev">
Previous
</a>
<a class="modal-slideshow__controls--next">
Next
</a>
</div>
</div>
<div class="modal-slideshow__content">
<!-- slide.content -->
</div>
</div>
</div>
</div>
The slideshow is originally styled using SASS. Therefor you can directly import the default style
from the node_modules folder:
@import 'node_modules/react-simple-modal-slideshow/src/simple-modal-slideshow.scss';
// Your style
This SASS file also offers the possibility to customize the default styling using SASS variables:
Type: String | Default: modal-slideshow
Should correspond to the classNamePrefix prop from the component you want to style.
Type: [false|'fade'] | Default: fade
Animation used when opening/closing the modal. When set to false, default modal animations are disabled, so you can use your own.
Type: [false|'slide'|'zoom'] | Default: slide
Animation used when changing slides. When set to false, default slide animations are disabled so you can use your own.
Type: Integer | Default: 9999
$modal-slideshow-prefix: 'example-slideshow';
$modal-slideshow-slide-animation: 'zoom';
@import 'node_modules/react-modal-slideshow/src/simple-modal-slideshow.scss';
// Your style
You can copy the file lib/simple-modal-slideshow.css and simply include it in your HTML page
to use the default styling. Feel free to modify this file to fit your needs.
Modal and slides are animated using
ReactCSSTransitionGroup components on
.modal-slideshow and .modal-slideshow__slide elements. So you can easily create your own
animations with CSS, using these transitions:
.modal-slideshow__modal-enter / .modal-slideshow__modal-enter-active
When modal is opened.
.modal-slideshow__modal-leave / .modal-slideshow__modal-leave-active
When modal is closed.
.modal-slideshow__slide-enter-left / .modal-slideshow__slide-enter-left-active
When the next slide enters.
.modal-slideshow__slide-leave-left / .modal-slideshow__slide-leave-left-active
When the current slide is leaving for the next one.
.modal-slideshow__slide-enter-right / .modal-slideshow__slide-enter-right-active
When the previous slide enters.
.modal-slideshow__slide-leave-right / .modal-slideshow__slide-leave-right-active
When the current slide is leaving for the previous one.
MIT
FAQs
A simple React modal media slideshow with CSS powered animations
The npm package react-modal-slideshow receives a total of 19 weekly downloads. As such, react-modal-slideshow popularity was classified as not popular.
We found that react-modal-slideshow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.