4.0.0 • Published 3 months ago

react-ikusi v4.0.0

Weekly downloads
57
License
ISC
Repository
github
Last release
3 months ago

See on NPM   See on NPM

See on Storybook   See on Storybook

A lightweight React responsive masonry component to display images. Built with CSS Flexbox:

  • Supports row direction layout
  • Configurable for different screen sizes
  • Responsive
  • Combined with a lightbox to display each image

:bulb: The word ikusi from the package name react-ikusi means see in Basque language. Click here for more information.

Getting started

You can download react-ikusi from the NPM registry via npm or yarn

yarn add react-ikusi
npm install react-ikusi --save

Demo

See react-ikusi Storybook

Example

Customizable configurations for different screen sizes | | | | ---------------------------------------------------------------------------------- | :------------------------------------------------------------------------------: | | | |

Usage

Here's the minimal setup example:

import Gallery from 'react-ikusi';

const photos = [
    {
        id: 'id-11111',
        title: 'Example image 1',
        src: 'http://example.com/example/img1.jpg',
        width: 4,
        height: 3,
    },
    {
        id: 'id-0033',
        title: 'Example image 2',
        src: 'http://example.com/example/img2.jpg',
        width: 1,
        height: 1,
    },
];


<Gallery photos={photos} />;

With additional props

const configurations = [
    { maxWidth: 340, cols: 2, margin: 1 },
    { maxWidth: 1024, cols: 3, margin: 1 },
    { minWidth: 1025, cols: 5, margin: 2 },
  ];

const handleClick: (photo) => {
    // do something...
}

const lightboxProps = {
    isEnabled: true,
    onClose?: () => {
        // do something...
    },
    onNext?: (photo) => {
        // do something...
    },     
    onPrev?: (photo) => {
        // do something...
    }
};

<Gallery photos={photos} configurations={configurations} onClickPhoto={handleClick} lightboxProps={lightboxProps} />;

Props

Gallery

NameDescriptionTypeRequired
photosAn array of photos to renderPhotoProps[]true
configurationsConfigurations to use for different screen sizesConfigurationProps[]true
onClickPhotoClick photo handlerfunctionfalse
lightboxPropsProps for lightbox renderingLightboxPropsfalse
withLightboxUsed to enable Lightbox rendering. @deprecated: Use lightboxProps insteadbooleanfalse

\ PhotoProps

NameDescriptionTypeRequired
idUnique identifier of the photostringtrue
srcUrl source of the photostringtrue
titleTitle of the photostringfalse
widthOriginal width of the photo in pixelsnumbertrue
heightOriginal height of the photo in pixelsnumbertrue
bigSrcUrl source of the photo in big size (for Lightbox displaying)stringfalse

\ ConfigurationProps

It contains data for photo rendering in different screen sizes.

It determines the number of elements to be displayed per row and their margin.

NameDescriptionTypeRequired
colsNumber of elements per rownumbertrue
marginSpace around each element of the Gallery (px)numbertrue
minWidthMinimum width for the current configuration (px)numberfalse
maxWidthMaximum width for the current configuration (px)numberfalse

\ LightboxProps

Additional props for lightbox rendering.

NameDescriptionTypeRequired
isEnabledWhether lightbox is present in Gallerybooleantrue
onCloseClose lightbox handlerfunctionfalse
onPrevClick on previous button handlerfunctionfalse
onNextClick on previous button handlerfunctionfalse

\ \ An example of Gallery layout :

3.1.7

3 months ago

4.0.0

3 months ago

3.1.6

10 months ago

3.1.5

11 months ago

3.1.4

11 months ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.0.2

2 years ago

3.1.0

1 year ago

3.0.1

2 years ago

3.0.0

2 years ago

2.4.0

2 years ago

2.3.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.3

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago