
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
react-photo-gallery
Advanced tools
A stateless responsive React photo gallery component that maintains the original aspect ratio of your photos and scales them responsively. Add your own routing, lightbox, and manage your own state.
To install:
npm install --save react-photo-gallery
http://neptunian.github.io/react-photo-gallery/
To build the examples locally, run:
npm install
npm start
Then open localhost:8000
in a browser.
import React from 'react';
import Gallery from 'react-photo-gallery';
export default class Sample extends React.Component {
render() {
return (
<Gallery photos={PHOTO_SET} onClickPhoto={this.openLightbox}/>
);
}
}
const PHOTO_SET = [
{
src: 'http://example.com/example/img1.jpg',
srcset: [
'http://example.com/example/img1_1024.jpg 1024w',
'http://example.com/example/img1_800.jpg 800w',
'http://example.com/example/img1_500.jpg 500w',
'http://example.com/example/img1_320.jpg 320w',
],
width: 681,
height: 1024,
caption: 'image 1',
},
{
src: 'http://example.com/example/img2.jpg',
srcset: [
'http://example.com/example/img2_1024.jpg 1024w',
'http://example.com/example/img2_800.jpg 800w',
'http://example.com/example/img2_500.jpg 500w',
'http://example.com/example/img2_320.jpg 320w',
],
width: 600,
height: 600,
caption: 'image 2',
}
];
Property | Type | Default | Description |
---|---|---|---|
photos | array | undefined | required; array of objects |
cols | number | 3 | optional; number of photos per row |
onClickPhoto | function | undefined | optional; do something when the user clicks a photo |
Property | Type | Default | Description |
---|---|---|---|
src | string | undefined | required; the src value of the gallery image |
width | number | undefined | required; original width of the gallery image (only used for calculating aspect ratio) |
height | number | undefined | required; original height of the gallery image (only used for calculating aspect ratio) |
alt | string | undefined | optional; alt text of the gallery image |
This component uses React Images for lightbox functionality in the example demo, but the component itself does not depend on it. PHOTO_SET obj in the example above is also being passed to lightbox which uses src, srcset, and caption props.
FAQs
Responsive Justified React Image Gallery Component
The npm package react-photo-gallery receives a total of 13,920 weekly downloads. As such, react-photo-gallery popularity was classified as popular.
We found that react-photo-gallery 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.