All Projects → browniebroke → gatsby-image-gallery

browniebroke / gatsby-image-gallery

Licence: MIT license
Very basic gallery grid based on gatsby-image

Programming Languages

typescript
32286 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to gatsby-image-gallery

Baguettebox.js
⚡ Simple and easy to use lightbox script written in pure JavaScript
Stars: ✭ 2,252 (+1841.38%)
Mutual labels:  gallery, lightbox
DevIQ-gatsby
No description or website provided.
Stars: ✭ 21 (-81.9%)
Mutual labels:  gatsby, gatsbyjs
Silentbox
A lightbox inspired Vue.js component.
Stars: ✭ 196 (+68.97%)
Mutual labels:  gallery, lightbox
Natural Gallery Js
A lazy load, infinite scroll and natural layout list gallery
Stars: ✭ 93 (-19.83%)
Mutual labels:  gallery, lightbox
gatsby-starter-apple
🍎 Gatsby blog starter kit with beautiful responsive design
Stars: ✭ 88 (-24.14%)
Mutual labels:  gatsby, gatsbyjs
Vue Pure Lightbox
Very simple lightbox plugin (without any dependencies) for Vuejs 🌅
Stars: ✭ 142 (+22.41%)
Mutual labels:  gallery, lightbox
gatsby-drupal-kit
A Gatsby V2 starter kit designed to work with a new Drupal 8 site.
Stars: ✭ 23 (-80.17%)
Mutual labels:  gatsby, gatsbyjs
Lightgallery.js
Full featured JavaScript image & video gallery. No dependencies
Stars: ✭ 5,168 (+4355.17%)
Mutual labels:  gallery, lightbox
gatsby-graphcms-example
Example of Gatsby source plugin for GraphCMS
Stars: ✭ 32 (-72.41%)
Mutual labels:  gatsby, gatsbyjs
halo-lab
Website of the Halo lab: design and development agency
Stars: ✭ 32 (-72.41%)
Mutual labels:  gatsby, gatsbyjs
Spotlight
Web's most easy to integrate lightbox gallery library. Super-lightweight, outstanding performance, no dependencies.
Stars: ✭ 799 (+588.79%)
Mutual labels:  gallery, lightbox
gatsby-generator
🎰 Generate Gatsby Starters in Seconds
Stars: ✭ 23 (-80.17%)
Mutual labels:  gatsby, gatsbyjs
Glightbox
Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes
Stars: ✭ 702 (+505.17%)
Mutual labels:  gallery, lightbox
React Awesome Slider
React content transition slider. Awesome Slider is a 60fps, light weight, performant component that renders an animated set of production ready UI general purpose sliders with fullpage transition support for NextJS and GatsbyJS. 🖥️ 📱
Stars: ✭ 2,343 (+1919.83%)
Mutual labels:  gallery, gatsbyjs
React Grid Gallery
Justified image gallery component for React
Stars: ✭ 571 (+392.24%)
Mutual labels:  gallery, lightbox
fancybox
jQuery lightbox script for displaying images, videos and more. Touch enabled, responsive and fully customizable.
Stars: ✭ 7,261 (+6159.48%)
Mutual labels:  gallery, lightbox
Ngx Gallery
Angular Gallery, Carousel and Lightbox
Stars: ✭ 417 (+259.48%)
Mutual labels:  gallery, lightbox
Nanogallery2
a modern photo / video gallery and lightbox [JS library]
Stars: ✭ 488 (+320.69%)
Mutual labels:  gallery, lightbox
react-simple-image-viewer
Simple image viewer component for React
Stars: ✭ 44 (-62.07%)
Mutual labels:  gallery, lightbox
gatsby-typescript-emotion-storybook
Gatsby Starter: TypeScript + Emotion + Storybook + React Intl + SVGR + Jest
Stars: ✭ 63 (-45.69%)
Mutual labels:  gatsby, gatsbyjs

gatsby-image-gallery

CI status Current npm package version. Released under the MIT license. Total alerts

Very basic gallery grid based on gatsby-plugin-image and react-image-lightbox, styling powered by styled-components.

Install

npm install --save @browniebroke/gatsby-image-gallery

Compatibility

Please check the table below to choose the version of this library to use depending on your version of Gatsby:

Gatsby Image Gallery Gatsby Gatsby Plugin Image Gatsby Image
v5 v2 Not supported v3
v6 v3 v1 Not supported
v7 v4 v2 Not supported

Only the latest major version of Gatsby Image Gallery is supported (e.g. no further v5 releases).

Usage

This library provides a Gallery component, rendering as a grid of images that can be clicked to open in full size inside a lightbox. See below for a minimal example:

import { graphql } from 'gatsby'
import React from 'react'

import Gallery from '@browniebroke/gatsby-image-gallery'

const MyPage = ({ data }) => {
  const images = data.allFile.edges.map(({ node }) => node.childImageSharp)
  // `images` is an array of objects with `thumb` and `full`
  return <Gallery images={images} />
}

export const pageQuery = graphql`
  query ImagesForGallery {
    allFile {
      edges {
        node {
          childImageSharp {
            thumb: gatsbyImageData(
              width: 270
              height: 270
              placeholder: BLURRED
            )
            full: gatsbyImageData(layout: FULL_WIDTH)
          }
        }
      }
    }
  }
`

export default MyPage

The images prop

The images prop is an array of objects with 2 required properties: thumb and full that should each be a GatsbyImage compatible object.

In addition, images may have the following properties:

  • thumbAlt: (string) used to set the alt attribute on the thumbnail image
  • title: (node) passed to the Lightbox component as imageTitle.
  • caption: (node) passed to the Lightbox component as imageCaption.

Passing options to Lightbox

The <Gallery> component accepts an object in the lightboxOptions prop, which will be passed down directly to react-image-lightbox.

You can see the full list of options in their documentation.

Passing onClose callback to Lightbox

The <Gallery> component accepts a function in the onClose prop, which will be called when react-image-lightbox is closed by the user.

Customise columns

To customise the number of columns and the space between the images, you have several props:

  • colWidth: percentage of total width to use on small screens (1/3 by default).
  • mdColWidth: percentage of total width to use on medium and large screens (1/4 by default).
  • gutter: margin around each image (0.25rem by default).
  • rowMargin: horizontal margin on each side of the gallery (-15px by default)

Customise image styles

You may also inject your own image styles by passing a component as customWrapper prop. The given component will be passed a few props that you should handle:

  • a GatbsyImage as children, this is the small image
  • a callback as onClick, opening the Lightbox when the small image is clicked

A minimal example may look like this, but you're free to bind the onClick to another element or render the image otherwise:

const CustomWrapper = ({ children, onClick }) => (
  <div className="my-custom-image-wraper" onClick={onClick}>
    {children}
  </div>
)

const MyPage = ({ data }) => {
  return (
    <Gallery
      //... Other props omited for clarity
      customWrapper={CustomWrapper} // example of use
    />
  )
}

Example

For a full working example, there is one in the example folder which is deployed to Netlify.

Development

Releases

Releases are automated using semantic release. This library parses the commit log to detect which version number should be bumped.

License

MIT © browniebroke

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].