Giter Site home page Giter Site logo

pedropalau / react-bnb-gallery Goto Github PK

View Code? Open in Web Editor NEW
212.0 6.0 84.0 15.61 MB

Simple react-based photo gallery inspired by Airbnb image gallery.

Home Page: https://peterpalau.github.io/react-bnb-gallery/

License: MIT License

HTML 0.31% JavaScript 65.04% CSS 0.54% SCSS 34.11%
reactjs javascript npm-package create-react-library rollup-js create-react-app photo-gallery react image-gallery

react-bnb-gallery's Introduction

react-bnb-gallery
Friendly, customizable and accessible-ready simple photo gallery based on React.

NPM Download Count Build Status Dependencies Dev Dependencie


Install

You can install react-bnb-gallery from npm.

# If you are using npm
npm install --save react-bnb-gallery

# If you prefer yarn
yarn add react-bnb-gallery

Live Demo

https://peterpalau.github.io/react-bnb-gallery/

Demo

Documentation

For full documentation, visit the demo website.

License

This package have been released under the MIT Licence.

Updates

If you are interested in view the main updates visit our CHANGELOG.md.

Contributing

If you're interested in contributing please read the contributing docs before submitting a pull request.

react-bnb-gallery's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-bnb-gallery's Issues

React 17.0.0 not working

Hi,
I just wanted to update the dependencies in my project and realized that the gallery does not allow React version 17.

Zoomable Images

Hi there, thank you so much for this package! My team is using the ReactBnbGallery but we have some tall and narrow images with text that need to be zoomed in on to be visible. It would be awesome to be able to pass a zoom option to GalleryPhoto. Alternatively, maybe Gallery could accept children and render a different image component instead of GalleryPhoto so that it could be zoomed?

Is there any way to disable full screen or add another div to the side

Hi, I'm trying to make a old facebooks photo and comment box.
For the image gallery react-bnb-gallery looks awesome but I can't figure out how to add another div box to image gallery.

For the comment section i'm considering simple-react-comment.
Does anyone have any idea how to do it?

Pinch-to-Zoom on mobile triggers next image load

Hello. First of all, thank you for this great lib!

I'm enctountering an issue on mobile devices (tested on safari - iOS). Whenever I perform Pinch-to-zoom gesture, to zoom into image, Gallery component automatically triggers next image loading.

Is there something I can do to prevent this behaviour?

Thanks.

Thumbnails on 2 rows

Hello!
When I use the gallery with more photos (around 20, 25) thumbnails goes to 2 rows and active thumbnail is not visible.

Image is missing alt

Hello.

First of all, thank you for this lib. I keep getting following error message in my console:

Warning: Failed prop type: The prop `alt` is marked as required in `Image`, but its value is `null`.
    in Image (created by Thumbnail)
    in Thumbnail (created by Caption)
    in li (created by Caption)

What can I do with it?
Thanks!

Allow theme implementation

This one is very important, because in today's frontend world everything is needed to be customizable.

Causes errors in browser Electron v59

This library is great! I'm excited to use it in my app, but I ran into a problem while running my end-to-end tests (via Cypress). These tests run my app in a headless browser, in this case, Electron (version 59). When I include this library, it crashes the app.

Any idea what might be going on?

Maybe random and unhelpful tidbits:

Here's the only error I get in my console logs when I have react-bnb-gallery on the page (the error goes away when I remove the component)
image

When clicking into the error link (VM296 main.js:40709) I get this:
image

I suspect it's actually from Sentry, but can't be sure right now. It's worth calling out that i'm using react-hot-loader

All the images are loaded at the same time

When the user open the gallery, all the thumbnails images are loaded at the same time.

I need to implement a way to load images dynamically without affecting the performance.

Separate CSS styles from the source code

This library is using an imported CSS file in the main JS file.

The idea is to separate the CSS file from the JS so that anyone can import it as a normal file.

TypeScript typings

๐Ÿ‘‹ Peter, I'm giving your lightbox another try. I noticed there were no TS typings out of the box so I added my own. Hope it's useful, and feel free to make any corrections:

declare module 'react-bnb-gallery' {
  import ReactBnbGallery from 'react-bnb-gallery'

  declare interface Props {
    // Initial photo index to show.
    activePhotoIndex: number
    // Called when a photo is pressed.
    activePhotoPressed: () => void
    // Called when left key of the keyboard is pressed.
    leftKeyPressed: () => void
    // Called when next control button is pressed.
    nextButtonPressed: () => void
    // Called when the gallery modal is going to close.
    onClose: () => void
    // The number of photos to preload on gallery initialization.
    preloadSize: number
    // Called when previous control button is pressed.
    prevButtonPressed: () => void
    // Array of photos. It can be an array of photos URLs or an array of objects. See the [photo object] props bellow.
    photos: Photo[] | string[]
    phrases?: object
    // Called when right key of the keyboard is pressed.
    rightKeyPressed?: () => void
    // Shows the modal when initialized.
    show?: boolean
    // Whether the gallery should show thumbnails.
    showThumbnails?: boolean
    // Whether the gallery should react to keyboard events.
    keyboard?: boolean
    // Whether the gallery should cycle continuously or have hard stops.
    wrap?: boolean
    // Sets the opacity level for the component.
    opacity?: number
    // Sets the background color of the gallery component.
    backgroundColor?: string
    // Specifies the stack order of the component.
    zIndex?: number
  }

  declare interface Photo {
    // The src attribute value of the image.
    photo: string
    // The current number of the photo.
    number?: number
    // Photo description.
    caption?: string
    // Photo secondary description, like the photo author or the name of the place where it was taken.
    subcaption?: string
    // The url of the photo thumbnail. The preferred size for each thumbnail is 100x67.
    thumbnail?: string
  }
}

Does not work with TypeScript

I think forbidExtraProps is interfering with TypeScript

Type checking in progress...
/Users/fang/choice-kittens/node_modules/airbnb-prop-types/src/forbidExtraProps.js:1
(function (exports, require, module, __filename, __dirname) { import forbidExtraProps from 'prop-types-exact';
                                                                     ^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier
    at new Script (vm.js:84:7)
    at createScript (vm.js:264:10)
    at Object.runInThisContext (vm.js:312:10)
    at Module._compile (internal/modules/cjs/loader.js:684:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Module.require (internal/modules/cjs/loader.js:657:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/fang/choice-kittens/node_modules/react-bnb-gallery/dist/react-bnb-gallery.js:5:40)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
/Users/fang/choice-kittens/node_modules/airbnb-prop-types/src/forbidExtraProps.js:1
(function (exports, require, module, __filename, __dirname) { import forbidExtraProps from 'prop-types-exact';

activePhotoPressed not working in firefox

Hello,

I found a bug with firefox when click on the active image :
The event is not fired.
It is because the event is attached into the <button /> but on firefox it has a 0px x 0px size.
It come from here https://github.com/peterpalau/react-bnb-gallery/blob/ebb11378048450ab9f75484847ac892fbfc9c35e/src/components/Image/Image.js#L144
You put a div element into a button, it's not allowed by the specs :
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button

Permitted content | Phrasing content but there must be no Interactive content https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content

So the size flow is broken here, and when we click on the image, the event is not fire on the button but on the parent element li

Support for locale

Maybe this is more a question than an issue report. But docs are not clear when locale is nedded.

There are some labes such as
image

Is there any way to support other languages options?

Integration with i18next will be so nice!

Thanks in advance

"wrap" option misleading

https://peterpalau.github.io/react-bnb-gallery/#/options currently states the following:

Name Type Default Description
wrap boolean false Whether the gallery should cycle continuously or have hard stops.

My understanding would be, that wrap=false would not show a previous-button on the first image. I would further expect, that wrap=true would show a previous-button on the first image.

Currently the opposite is true: With wrap=true no previous-button is shown on the first image.

I would either change the description or change the implementation.

Improve documentation

Add some new demos of how-to and check is something is missing in the documentation.

unable to open Clicked image.

when I clicked on any image of the slider, every time 1st image of the array is opened.
how to pass the current image or clicked image id to open that specific image.

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.