1.0.1 • Published 6 years ago

react-media-view v1.0.1

Weekly downloads
19
License
MIT
Repository
github
Last release
6 years ago

React Media View

A simple media view component for React.

Installation

The package can be installed via NPM:

npm install --save react-media-view

Examples

Basic Usage

You can basically use the library with an array of objects which have objects with src property.

import React, {Component} from 'react';
import ReactMediaView from "react-media-view";

class ReactMediaViewExample extends Component {
  constructor(props) {
    super(props);

    this.state = {
      media: [
        {
          src: "https://images.unsplash.com/photo-1531386450450-969f935bd522?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=b0e6037f0a7cd63b48cc1562e348eb3a&auto=format&fit=crop&w=750&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1518128958364-65859d70aa41?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=df90aec8aaec700a402790e4799d226e&auto=format&fit=crop&w=774&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1513836279014-a89f7a76ae86?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=d4147a2e4e3f79299e2f0c92b13db9ee&auto=format&fit=crop&w=668&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1510797215324-95aa89f43c33?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=f8dee688d0e8cbb8c6c99de58f22a7dc&auto=format&fit=crop&w=750&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1504511045-dc6e5c9bea25?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=a88ada821297d024419edbf111a244e7&auto=format&fit=crop&w=800&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1502083728181-687546e77613?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e11ef2edff62a7a7701cfbe89d020b19&auto=format&fit=crop&w=1650&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1489619243109-4e0ea59cfe10?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=974d4283fca93c49c75f8b19a4b6abbf&auto=format&fit=crop&w=1650&q=80"
        },
        {
          src: "https://images.unsplash.com/photo-1487622750296-6360190669a1?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=0966f85ba805ff53ab5c270e14548d6b&auto=format&fit=crop&w=800&q=80"
        }
      ]
    };
  }

  render() {
    return (
      <ReactMediaView media={this.state.media}/>
    );
  }
}

export default ReactMediaViewExample;

Property List

NameDescriptionIs RequiredTypeDefault ValueExpected Values
mediaArray of media objects that you want to displaytruearrayemptyAny array of objects (objects must require a src property)
classNameCustom class name that you want to describe for your media view componentfalsestringemptyAny CSS class name
columnCountColumn countfalsenumber3Any integer value
rowHeightRow heightfalsenumber200Any integer value (in pixels)
gapGap size between itemsfalsenumber1Any integer value (in pixels)
emptyStateCustom node that you want to show when there is no media elementfalsenodeThere is no media to show :(Any html value
stretchLastItemBoolean prop to define stretching the last item or notfalseboolfalsetrue or false
overlayTriggerEnum prop to define overlay showing triggerfalsestringemptymount, hover, click or toggle
overlayFunction to define overlay nodefalsefunctionemptyAny javascript function that returns html
imageFunction to define custom image nodefalsefunctionemptyAny javascript function that returns html
onMouseEnterFunction that you want to run when mouse entered on an elementfalsefunctionemptyAny javascript function
onMouseLeaveFunction that you want to run when mouse leaved from an elementfalsefunctionemptyAny javascript function
onClickFunction that you want to run when clicked on an elementfalsefunctionemptyAny javascript function

Lıcence

MIT ©

Support

Bedirhan Karadoğan | Patreon