0.1.0 • Published 7 years ago

react-bilde v0.1.0

Weekly downloads
1
License
CC0-1.0
Repository
github
Last release
7 years ago

react-bilde

Latest npm version Build Status JavaScript Style Guide

JavaScript Style Guide

A universal react component for displaying images. [Updated fork of React Universal Image, prepared for React 16.]

Features

  • Lazy load
  • Placeholder
  • Progressive image loading (as on Medium.com)
  • Image error fallback

Installation

npm install react-bilde --save

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import Image from 'react-bilde';

const App = () => {

    return (
        <div>
            <image
                src="img-400x200.jpg"
                srcSet="img-400x200.jpg 400w, img-800x400.jpg 800w"
                placeholder="img-20x10.jpg"
                ratio={2}
                fallback="image-not-found.jpg"
                className="post-image"
            />
        </div>
    );
};

ReactDOM.render(<App />, document.body);

Props

PropDescriptionTypeDefault
srcSets the src attribute of an image (required)stringundefined
srcSetSets the srcset attribute of an image.stringundefined
placeholderSpecify a placeholder image URL or Component for lazy loaded image.string/nodeundefined
blurSpecify a blur level of a placeholder image. Set 0 to disable blurring. NOTE Works only if placeholder was defined as image URLnumber3
ratioImage ascpect ratio.numberundefined
debounceDebounce Value.number200
animationSpeedAnimation Speed (in ms)number400
fallbackFallback image src.stringundefined
maxWidthImage maximum witdthnumber / stringundefined
inlineImage inline or notboolfalse
idImage identifierstringundefined
classNameImage class name.stringundefined
altSets the alt attribute of an image and placeholder.stringundefined
crossOriginSets the crossorigin attribute of an image and placeholder.stringundefined
sizesSets the sizes attribute of an image.stringundefined

Contributing

See the contribution guidelines before creating a pull request.

Polyfills