2.1.2 • Published 6 years ago

@jay./react-progressive-bg-image v2.1.2

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

react-progressive-bg-image

Medium style progressive background image for React based on Styled-components.

Travis Codecov Status npm package npm downloads node

Dependency Status devDependency Status peerDependency Status

Greenkeeper badge prettier license

Demo

DEMO

Further Reading:

Installation

$ npm i react-progressive-bg-image styled-components --save
// or
$ yarn add react-progressive-bg-image styled-components

Requirements

  • node >= 8.6.0
  • npm >= 5.3.0
  • yarn >= 1.1.0

  • react ^15.0.0 || ^16.0.0,

  • styled-components ^2.0.0

Usage

Case 1: Inline-style

Remind: May need to setup autoprefixer in your project.

import ProgressiveImage from 'react-progressive-bg-image';

<ProgressiveImage
  src={image1}
  placeholder={image1X60}
  style={{
    height: 600,
    backgroundSize: 'contain',
    backgroundPosition: 'center center',
  }}
/>

Case 2: With Styled-components

import styled from 'styled-components';
import ProgressiveImage from 'react-progressive-bg-image';

const StyledProgressiveImage = styled(ProgressiveImage)`
  height: 600px;
  background-size: contain;
  background-position: center center;
`;

<StyledProgressiveImage
  src={IMAGE}
  placeholder={IMAGEX60}
  transition="all 1s linear"
/>;

Property

PropTypeRequiredDescription
srcstringyesOrigin image
placeholderstringyesSmall image (Suggest inline base64)
opacitynumberdefault: 0.5
blurnumberdefault: 20
scalenumberdefault: 1
transitionstringdefault: 'opacity 0.3s linear'
componentstringdefault: 'div'

Test

$ yarn run format
$ yarn run eslint
$ yarn run test:watch

Github release / NPM release

$ npm version patch
$ git push

Inspiration

CONTRIBUTING

  • ⇄ Pull requests and ★ Stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ yarn run test).

CHANGELOG

LICENSE

MIT: http://michaelhsu.mit-license.org