# react-pic

> React component for progressive and responsive image loading.

Latest version **0.2.1** (published 2017-11-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-pic
pnpm add react-pic
yarn add react-pic
bun add react-pic
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2017-11-03 |
| First published | 2016-10-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Ben Budnevich |
| Maintainers | benox |
| Keywords | react, pic, picture, image, img, progressive, loading, responsive, universal |

## Links

- npm: https://www.npmjs.com/package/react-pic
- Repository: https://github.com/benox3/react-pic
- Issues: https://github.com/benox3/react-pic/issues
- npm.io page: https://npm.io/package/react-pic

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [rollup-plugin-replace](https://npm.io/package/rollup-plugin-replace.md) ^2.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2017-11-03
- 0.2.0 — 2017-11-02
- 0.1.3 — 2017-04-18
- 0.1.2 — 2017-04-14
- 0.1.1 — 2016-11-03
- 0.1.0 — 2016-10-27
- 0.0.14 — 2016-10-14
- 0.0.13 — 2016-10-12
- 0.0.12 — 2016-10-11
- 0.0.11 — 2016-10-11
- 0.0.10 — 2016-10-11
- 0.0.9 — 2016-10-11
- 0.0.8 — 2016-10-08
- 0.0.7 — 2016-10-07
- 0.0.6 — 2016-10-06
- … 6 more at https://npm.io/package/react-pic/versions

## README

# react-pic

[![NPM version](https://img.shields.io/npm/v/react-pic.svg)](https://www.npmjs.com/package/react-pic)
[![Build Status](https://travis-ci.org/benox3/react-pic.svg?branch=master)](https://travis-ci.org/benox3/react-pic)
[![Coverage Status](https://coveralls.io/repos/github/benox3/react-pic/badge.svg?branch=master)](https://coveralls.io/github/benox3/react-pic?branch=master)

React component for progressive and responsive image loading.

react-pic works universally. On the server-side, it works by setting a default image (usually something very small to reduce data). On the client-side, it will try to load the optimal image based on [prop data](#props).

## Installation

#### NPM:
```sh
npm install react-pic --save
```

#### CDN:
```html
<script src='https://unpkg.com/react-pic@latest/dist/react-pic.umd.js'></script>

<!-- or use minified -->
<script src='https://unpkg.com/react-pic@latest/dist/react-pic.umd.min.js'></script>
```

## Demo:
![demo-image](https://thumbs.gfycat.com/MajesticFinishedAlpinegoat-size_restricted.gif)

## Usage
```javascript
import React, { Component } from 'react';
import Pic from 'react-pic';

const images = [
  {
    width: 40,
    url: 'http://placehold.it/40?text=♥'
  },
  {
    width: 250,
    url: 'http://placehold.it/250?text=♥'
  }
];

export default class Example extends Component {
  render() {
    return <Pic images={images} />;
  }
}
```

## Props

| name         | default | required | type   | description                                                                                                                |
|--------------|----------|--------|----------|-----------------------------------------------------------------------------------------------------------------|
| images       | | true     | array  | The collection of images you would like to use as a source.                                                                |
| alt       | | false     | string  | Text equivalent of the image. https://www.w3.org/QA/Tips/altAttribute                                                                |
| defaultIndex |  0 | false    | number | The image object to use on initial render.                                                                                 |
| noscriptIndex | `images.length-1` | false    | number | The image object to use on noscript render.                                                                                 |
| baseStyle        | `{ position: 'relative', margin: '-5px', overflow: 'hidden' }` | false    | object | Override the container style object. |
| imgStyle        | `{ margin: '0 auto', maxWidth: '100%', width: '100%' }` | false    | object | Override the image style object. |
| shouldBlur        | false | false    | boolean | Determines if the image should be blurred before setting the optimal image. |
| blurAmount        | '20px' | false    | string | The amount of blur. Expected format: '10px' or '15%'. |
| renderOutOfView        | false | false    | boolean | Determines if the optimal image should be selected even if not in view |

## Special Thanks

- To [remarkablemark](https://github.com/remarkablemark) and [tdlm](https://github.com/tdlm) for their feedback and review.

## License

[MIT](https://github.com/benox3/react-pic/blob/master/LICENSE)

---
_Source: https://npm.io/package/react-pic · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
