Gathering detailed insights and metrics for itoldya-react-grid-gallery
Gathering detailed insights and metrics for itoldya-react-grid-gallery
Gathering detailed insights and metrics for itoldya-react-grid-gallery
Gathering detailed insights and metrics for itoldya-react-grid-gallery
npm install itoldya-react-grid-gallery
Typescript
Module System
Node Version
NPM Version
Total Downloads
4,302
Last Day
7
Last Week
26
Last Month
104
Last Year
473
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
itoldya-react-grid-gallery@1.0.1
Unpacked Size
205.62 kB
Size
45.34 kB
File Count
18
NPM Version
8.11.0
Node Version
16.16.0
Cumulative downloads
Total Downloads
Last day
0%
7
Compared to previous day
Last week
-29.7%
26
Compared to previous week
Last month
1,633.3%
104
Compared to previous month
Last year
-51.1%
473
Compared to previous year
1
28
Justified image gallery component for React inspired by Google Photos and based upon React Images.
As react-grid-gallery continues to gain popularity and provide value to many users (over a million downloads from NPM alone) it requires maintainers to take care of issues and pull requsts, and to progress the software. If you're getting value from using this component or if you're just interested in becoming a maintainer, please let me know.
A very big thankyou to Isaev Igor (@itoldya) for taking on a substantial amount of work in smoothing out some (of the many) rough edges, and for bringing react-grid-gallery up to date. I really appreciate the care taken. Check out his site at picryl.com (a great example of react-grid-gallery in use).
As of the release of v0.5.4 (2019-03-10) I will no longer be actively adding features and maintaining react-grid-gallery. My online behavioral experiment platform Psychstudio consumes all of my time and I am no longer capable of giving react-grid-gallery the attention it needs. A big thanks to everyone who has contributed over the last 5 years and thanks to everyone who has downloaded react-grid-gallery (hopefully it has been useful to you).
https://benhowell.github.io/react-grid-gallery/
Using npm:
npm install --save react-grid-gallery
1import React from 'react'; 2import { render } from 'react-dom'; 3import Gallery from 'react-grid-gallery'; 4 5const IMAGES = 6[{ 7 src: "https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_b.jpg", 8 thumbnail: "https://c2.staticflickr.com/9/8817/28973449265_07e3aa5d2e_n.jpg", 9 thumbnailWidth: 320, 10 thumbnailHeight: 174, 11 isSelected: true, 12 caption: "After Rain (Jeshu John - designerspics.com)" 13}, 14{ 15 src: "https://c2.staticflickr.com/9/8356/28897120681_3b2c0f43e0_b.jpg", 16 thumbnail: "https://c2.staticflickr.com/9/8356/28897120681_3b2c0f43e0_n.jpg", 17 thumbnailWidth: 320, 18 thumbnailHeight: 212, 19 tags: [{value: "Ocean", title: "Ocean"}, {value: "People", title: "People"}], 20 caption: "Boats (Jeshu John - designerspics.com)" 21}, 22 23{ 24 src: "https://c4.staticflickr.com/9/8887/28897124891_98c4fdd82b_b.jpg", 25 thumbnail: "https://c4.staticflickr.com/9/8887/28897124891_98c4fdd82b_n.jpg", 26 thumbnailWidth: 320, 27 thumbnailHeight: 212 28}] 29 30render( 31 <Gallery images={IMAGES}/>, 32 document.getElementById('example-0') 33);
Property | Type | Default | Description |
---|---|---|---|
src | string | undefined | Required. A string referring to any valid image resource (file, url, etc). |
thumbnail | string | undefined | Required. A string referring to any valid image resource (file, url, etc). |
thumbnailWidth | number | undefined | Required. Width of the thumbnail image. |
thumbnailHeight | number | undefined | Required. Height of the thumbnail image. |
nano | string:base64 | undefined | Optional. Thumbnail Base64 image will be injected to background under the main image. This provides a base64, 4x4 generated image whilst the image is beong loaded. |
alt | string | "" | Optional. Image alt attribute. |
tags | array | undefined | Optional. An array of objects containing tag attributes (value, title and key if value is element). e.g. {value: "foo", title: "bar"} or {value: <a href={tag.url}>{tag.name}</a>, title: tag.title, key: tag.key} |
isSelected | bool | undefined | Optional. The selected state of the image. |
caption | string|element | undefined | Optional. Image caption. |
customOverlay | element | undefined | Optional. A custom element to be rendered as a thumbnail overlay on hover. |
thumbnailCaption | string|element | undefined | Optional. A thumbnail caption shown below thumbnail. |
orientation | number | undefined | Optional. Orientation of the image. Many newer digital cameras (both dSLR and Point & Shoot digicams) have a built-in orientation sensor. The output of this sensor is used to set the EXIF orientation flag in the image file's metatdata to reflect the positioning of the camera with respect to the ground (See EXIF Orientation Page for more info). |
Property | Type | Default | Description |
---|---|---|---|
images | array | undefined | Required. An array of objects containing image properties (see Image Options above). |
id | string | "ReactGridGallery" | Optional. id attribute for <Gallery> tag. This prop may be useful for those who wish to discriminate between multiple galleries. |
enableImageSelection | bool | true | Optional. Allow images to be selectable. Setting this option to false whilst supplying images with isSelected: true will result in those images being permanently selected. |
onSelectImage | func | undefined | Optional. Function to execute when an image is selected. Allows access to image object using this (See Programmers notes for more info about implicit this ). Optional args: index (index of selected image in images array), image (the selected image). This function is only executable when enableImageSelection: true . |
rowHeight | number | 180 | Optional. The height of each row in the gallery. |
maxRows | number | undefined | Optional. The maximum number of rows to show in the gallery. |
margin | number | 2 | Optional. The margin around each image in the gallery. |
onClickThumbnail | func | undefined | Optional. Function to execute when gallery thumbnail clicked. Allows access to image object using this (See Programmers notes for more info about implicit this ). Optional args: index (index of selected image in images array), event (the click event). |
tagStyle | object | tagStyle | Optional. Style to pass to tag elements. Overrides internal tag style. |
tileViewportStyle | func | tileViewportStyle | Optional. Function to style the image tile viewport. Allows access to image object using this (See Programmers notes for more info about implicit this ). Overrides internal tileViewportStyle function. |
thumbnailStyle | func | thumbnailStyle | Optional. Function to style the image thumbnail. Allows access to image object using this (See Programmers notes for more info about implicit this ). Overrides internal thumbnailStyle function. |
thumbnailImageComponent | React component | undefined | Optional. Substitute in a React component that would get passed imageProps (the props that would have been passed to the <img> tag) and item (the original item in images ) to be used to render thumbnails; useful for lazy loading. |
defaultContainerWidth | number | 0 | Optional. Set default width for the container. This option is useful during server-side rendering when we want to generate an initial markup before we can detect the actual container width. |
react-grid-gallery is built for modern browsers and therefore IE support is limited to IE 11 and newer.
As the inspiration for this component comes from Google Photos, very small thumbnails may not be the most aesthetically pleasing due to the border size applied when selected. A sensible rowHeight default of 180px has been chosen, but rowHeights down to 100px are still reasonable.
Gallery width is determined by the containing element. Therefore your containing element must have a width (%, em, px, whatever) before the gallery is loaded!
Image Options: thumbnail
can point to the same resource as src
, bearing in mind the resultant data size of the gallery and page load cost. Thumbnails of whatever size will be scaled to match rowHeight
.
this
via Function.prototype.call() do not require you to declare or pass this
as a parameter. this
will be defined at the time the function is called.e.g.
1// somewhere in your code... 2function myTileViewportStyleFn() { 3 if (this.props.item.isSelected) 4 return { 5 // something stylish... 6 }; 7} 8 9<Gallery images={IMAGES} tileViewportStyle={myTileViewportStyleFn}/> 10 11 12// internally, within the react-grid-gallery component it will be called like so: 13myTileViewportStyleFn.call(this); // this now refers to the image to be styled 14
thumbnailWidth
and thumbnailHeight
values, you can find these out using any number of javascript hacks, bearing in mind the load penalty associated with these methods.All contributions to react-grid-gallery are very welcome. Feature requests, issue reports and pull requests are greatly appreciated. Please follow the contribution guidelines
React Grid Gallery is free to use for personal and commercial projects under the MIT License. Attribution is not required, but appreciated.
Visual design inspired by Google Photos.
Thumbnail viewport implementation inspired by GPlusGallery by Florian Maul.
Backend lightbox functionality via React Images by jossmac.
The following gallery functions were obtained from the React Images example demo: closeLightbox, gotoNext, gotoPrevious, handleClickImage, openLightbox.
ValYouW for lightboxWillOpen and lightBoxWillClose functionality PR 20 and customOverlay option: PR 22.
danalloway for theme pass-through prop PR 27
SimeonC for update thumbnails when maxRows changes PR 35 and resize on scrollbar presence change PR 40
jakub-tucek for thumbnailCaption functionality PR 42
ScottMRafferty for preloadNextImage not propagating to Lightbox fix PR 78
Approximator for currentImageWillChange (Function to execute before lightbox image change) PR 97.
pxpeterxu for adding functionality to inject a custom thumbnail image component (for lazy-loading) PR 104.
lryta for fixing crash when this.props.images.length - 1 < this.state.currentImage PR #111.
jimishf for lightBoxProps option to assign any prop directly to lightbox PR #121.
Demo stock photos:
No vulnerabilities found.
No security vulnerabilities found.