Code Monkey home page Code Monkey logo

react-photo-gallery's Introduction

Join the chat at https://gitter.im/react-photo-gallery/Lobby npm version Build Status Coverage Status

  • Stateless, responsive, accessible, and highly customizable
  • Maintains the original aspect ratio of your photos
  • Uses actual image elements, optionally pass in srcSet and sizes attributes
  • Supports passing in a custom image component for implementation of things like image selection, favorites, captions, or whatever your little heart desires!

Preview

Documentation and Examples

http://neptunian.github.io/react-photo-gallery/

Direct CodeSandbox Links with Examples and Use Cases

To build some examples locally, run:

npm install
npm start

Then open localhost:8000 in a browser.

Installation

To install:

npm install --save react-photo-gallery

Use

import Gallery from 'react-photo-gallery';

export default class Sample extends React.Component {
    render() {
	return (
	    <Gallery photos={PHOTO_SET} />
	);
    }
}
const PHOTO_SET = [
  {
    src: 'http://example.com/example/img1.jpg',
    width: 4,
    height: 3
  },
  {
    src: 'http://example.com/example/img2.jpg',
    width: 1,
    height: 1
  }
];

Gallery properties

Property Type Default Description
photos array undefined required; array of objects
columns number 3 optional; number of photos per row
onClick function undefined optional; do something when the user clicks a photo; receives arguments event and an object containing the index, photo obj originally sent and the next and previous photos in the gallery if they exist
margin number 2 optional; number of margin pixels around each entire image
ImageComponent function default component optional; use a different image component than the default provided to display your photo

Photos array item properties (passed into Gallery's photos property)

Property Type Default Description
src string undefined required; the img src attribute value of the image
srcSet array undefined optional; array of strings for the srcSet attribute of the image
sizes array undefined optional; array of strings for the sizes attribute of the 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

react-photo-gallery's People

Contributors

brianrc avatar dmr avatar fusillicode avatar gitter-badger avatar hedleysmith avatar imerica avatar infacq avatar jorrit avatar kvermeille avatar lotharschulz avatar neptunian avatar timiscoding avatar

Watchers

 avatar  avatar

Forkers

aellivon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.