@shelf/image-preview-overlay
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Installation

Note: uses styled-components

Install the library using npm:

$ npm install styled-components
$ npm install @shelf/image-preview-overlay

Install the library using yarn:

$ yarn add styled-components
$ yarn add @shelf/image-preview-overlay

Props

Prop Name Type Description
getImages function (optional) A function that can be used to modify preview images list. Signature: (event: ElementMouseEvent) => {src: string; alt?: string}[] | undefined
getInitialPreviewImageIndex function (optional) A function to customly choose the initial image from the list to be shown when fullview is opened
startPreviewFromTargetImage boolean (optional) Default false (always opens first image from the list). If set to true - will try to open the target image (if it is present in the list returned by getImages)
triggerProps, portalWrapperProps, imageOverlayProps HTMLAttributes<HTMLDivElement> (optional) HTML attributes passed to the corresponding elements
imageProps HTMLAttributes<HTMLImageElement> (optional) HTML attributes passed to the fullview image element

Usage

ImagePreviewOverlay

ImagePreviewOverlay is a wrapper that renders full image preview on child image tag click

import {ImagePreviewOverlay} from '@shelf/image-preview-overlay';

// Simple usage
const Component = () => (
  <ImagePreviewOverlay>
    <span>
      Shelf.io
      <p>
        <img src={'shelf.io'} />
      </p>
    </span>
  </ImagePreviewOverlay>
);

// Custom getImages prop and multiple images
const Component = () => {
  const getImages = _event => [
    {
      src: 'source-1',
      alt: 'source 1 alt',
    },
    {
      src: 'source-2',
    },
  ];

  return (
    <ImagePreviewOverlay getImages={getImages}>
      <img src={'image-snippet-src'} />
    </ImagePreviewOverlay>
  );
};

Publish

$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags

License

MIT © Shelf

Package Sidebar

Install

npm i @shelf/image-preview-overlay

Weekly Downloads

141

Version

1.3.0

License

MIT

Unpacked Size

14.8 kB

Total Files

19

Last publish

Collaborators

  • ksenia_holovko
  • petro.bodnarchuk
  • kateryna-kochina
  • maksym.tarnavskyi
  • andrii-nastenko
  • mykhailo.yatsko
  • ahavrysh
  • nikita_shelf
  • maciej.orlowski
  • monopotan
  • andrew214
  • bogdan.kolesnyk
  • andrii.batutin
  • kristina.zhak
  • anton-russo
  • mmazurowski
  • toms-shelf
  • mateuszgajdashelf
  • kchlon
  • dmytro.harazdovskiy
  • duch0416
  • i5adovyi
  • olesiamuller
  • mykola.khytra
  • yuliiakovalchuk
  • el_scrambone
  • bodyaflesh
  • slavammellnikov
  • andriisermiahin
  • mpushkin
  • batovpavlo
  • domovoj
  • vozemer
  • oleksii.dymnich
  • dima-bond
  • maksym.hayovets
  • oles.zadorozhnyy
  • ss1l
  • gemshelf
  • hartzler
  • vladgolubev
  • hmelenok
  • knupman
  • maaraanas
  • terret
  • chapelskyi.slavik
  • pihorb
  • irynah
  • diana.kryskuv
  • andy.raven
  • rafler
  • sskalp88
  • demiansua
  • yuriil
  • ktv18
  • drews_abuse
  • rostyslav-horytskyi
  • whodeen