{"_id":"@alloc/react-progressive-image","_rev":"1-19a924aa3f69c1c4cec90166828d503b","name":"@alloc/react-progressive-image","dist-tags":{"latest":"0.6.0"},"versions":{"0.6.0":{"name":"@alloc/react-progressive-image","version":"0.6.0","description":"Progressive image loading for React","main":"dist/index.js","module":"dist/index.mjs","typings":"dist/index.d.ts","scripts":{"build":"rollup -c","test":"jest","prepare":"yarn build"},"keywords":["react","progressive","images","loading"],"repository":{"type":"git","url":"git+https://github.com/FormidableLabs/react-progressive-image.git"},"author":{"name":"Brandon Dail","email":"brandon.dail@formidable.com"},"license":"MIT","devDependencies":{"@types/react":"^16.9.46","@types/react-dom":"^16.9.8","enzyme":"^3.6.0","enzyme-adapter-react-16":"^1.5.0","esbuild":"^0.6.19","jest":"^23.6.0","prettier":"^1.14.2","raf":"^3.4.0","react":"^16.5.1","react-dom":"^16.5.1","react-test-renderer":"^16.5.1","rollup":"^2.23.1","rollup-plugin-dts":"^1.4.10","rollup-plugin-esbuild":"^2.4.2","typescript":"^3.9.7"},"peerDependencies":{"react":"^15.0.0-0 || ^16.0.0-0","react-dom":"^15.0.0-0 || ^16.0.0-0"},"sideEffects":false,"gitHead":"3991c87c3630b44a7e96dc63f69bea79048ee1a1","bugs":{"url":"https://github.com/FormidableLabs/react-progressive-image/issues"},"homepage":"https://github.com/FormidableLabs/react-progressive-image#readme","_id":"@alloc/react-progressive-image@0.6.0","_nodeVersion":"12.13.0","_npmVersion":"6.12.0","dist":{"integrity":"sha512-A2YD2MLj0Asn+v8ON/2BGZARhlRKwKzNwIvyCLT5zGEZo+ig0rfuCDPfEUAOwGM0jOJ7Dj/9VpC+dHgTzDJykQ==","shasum":"85cdaeefb7099b76dbb974838a4b6d154ccf2851","tarball":"https://registry.npmjs.org/@alloc/react-progressive-image/-/react-progressive-image-0.6.0.tgz","fileCount":8,"unpackedSize":25671,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMZvCCRA9TVsSAnZWagAApBoP/0Ho172p2otB5ZDISpDr\nSn9wOzkLnMSuKajeLu/BiuFz41WQXiAeMTLD3W+wEtFN4koWfytYRMV/0GLH\nCpnE68r7uv5801BNBfdS4cwvSF6+l+tqDzTaNoT5kMU++I8RUGUkNn0bDen/\n7OGydSyKdK4weT4frSDGNfZRlss4AL4DwmSxUBQSKoF5/N8fPtqJyBepyS2H\nK6iAllV8a0qrFcQvK7yVyRErFCuKaJKrnIdid5QWn4WXDMRhez1dCyPtr/Ht\n+ndx9uepi3d54bfQ8+giRf8P3qpT6Jx4HeJLhKm8QDPiRjlbPICgYdHPggYW\nLcUkNQtToefs1cP4X/yTvAh2HpDxhIFK722lWYh3zqJ9v2D0KdpTyYSXhD22\noBRakFLfSI4OY5SRF8+LgdeEcaCRHCUejtpRKhbZ1Sk5K1o9Qoqrl65/O8dx\nTlokuxA9/0bGiFVnFl8tl3gtMx2Mxt8MdGzvz128+TFpxZkpY9qFwSVuzuXy\nqziQTu1oTGI70mJafvWx4p2p71oDSIuD/NukXpxo5dd+9OeEJhFGUouCosOI\ng5SnGyRmPdTfXW587hmA4sFxYKxYBOomWiBcHxTU0xFU8WfnWbswtZj+sJ8M\nGmbx3I/k1G5ep66vdvvh5L3rp/VdpP9OYUopd+s41OaMN+WkT9eSBAqKiJTG\nQ1f6\r\n=YkYn\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCj/BiGTRumkg9L+GdjYJati1MxOA+WdsNLFU4vwNxN3AIhAMro8gc4ms9UiAAN/ckmc6E78+NFR1Eg46pLcODzoe0f"}]},"maintainers":[{"name":"aleclarson","email":"aleclarson@protonmail.com"}],"_npmUser":{"name":"aleclarson","email":"aleclarson@protonmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-progressive-image_0.6.0_1597086657608_0.15578543333800998"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-10T19:10:57.427Z","0.6.0":"2020-08-10T19:10:57.716Z","modified":"2022-04-04T13:33:41.536Z"},"maintainers":[{"name":"aleclarson","email":"aleclarson@protonmail.com"}],"description":"Progressive image loading for React","homepage":"https://github.com/FormidableLabs/react-progressive-image#readme","keywords":["react","progressive","images","loading"],"repository":{"type":"git","url":"git+https://github.com/FormidableLabs/react-progressive-image.git"},"author":{"name":"Brandon Dail","email":"brandon.dail@formidable.com"},"bugs":{"url":"https://github.com/FormidableLabs/react-progressive-image/issues"},"license":"MIT","readme":"# React Progressive Image\n\n[![npm](https://img.shields.io/npm/v/@alloc/react-progressive-image.svg)](https://www.npmjs.com/package/@alloc/react-progressive-image)\n[![Maintenance Status][maintenance-image]](#maintenance-status)\n\nFork of [`react-progressive-image`][1] with ESM bundle.\n\n[1]: https://github.com/FormidableLabs/react-progressive-image\n\n### Install\n\n```bash\n$ yarn add @alloc/react-progressive-image\n```\n\n### Examples\n\n```js\nimport { ProgressiveImage } from '@alloc/react-progressive-image'\n```\n\n#### Simple\n\n```jsx\n<ProgressiveImage src=\"large-image.jpg\" placeholder=\"tiny-image.jpg\">\n  {src => <img src={src} alt=\"an image\" />}\n</ProgressiveImage>\n```\n\n#### With Delay\n\n```jsx\n<ProgressiveImage\n  delay={3000}\n  src=\"large-image.jpg\"\n  placeholder=\"tiny-image.jpg\"\n>\n  {src => <img src={src} alt=\"an image\" />}\n</ProgressiveImage>\n```\n\n#### With loading argument\n\n```jsx\n<ProgressiveImage src=\"large-image.jpg\" placeholder=\"tiny-image.jpg\">\n  {(src, loading) => (\n    <img style={{ opacity: loading ? 0.5 : 1 }} src={src} alt=\"an image\" />\n  )}\n</ProgressiveImage>\n```\n\n#### With srcSet\n\n```jsx\n<ProgressiveImage\n  src=\"medium.jpg\"\n  srcSetData={{\n    srcSet: 'small.jpg 320w, medium.jpg 700w, large.jpg 2000w',\n    sizes: '(max-width: 2000px) 100vw, 2000px'\n  }}\n  placeholder=\"tiny-image.jpg\"\n>\n  {(src, _loading, srcSetData) => (\n    <img\n      src={src}\n      srcSet={srcSetData.srcSet}\n      sizes={srcSetData.sizes}\n      alt=\"an image\"\n    />\n  )}\n</ProgressiveImage>\n```\n\n#### Component As Placeholder\n\nIf you want to use a component, such as a loading spinner, as a placeholder, you can make use of the `loading` argument in the render callback. It will be true while the main image is loading and false once it has fully loaded. Keep in mind that the `placeholder` props is `required`, so you will need to explicitly declare an empty string as it's value if you plan on using a component in the render callback.\n\n```jsx\nconst dominantImageColor = '#86356B';\nconst placeholder = (\n  <div\n    style={{ backgroundColor: dominantImageColor, height: 300, width: 500 }}\n  />\n);\n\n<ProgressiveImage src=\"large-image.jpg\" placeholder=\"\">\n  {(src, loading) => {\n    return loading ? placeholder : <img src={src} alt=\"an image\" />;\n  }}\n</ProgressiveImage>;\n```\n\n#### Progressive Enhancement and No JavaScript\n\nSince this component relies on JavaScript to replace the placeholder src with the full image src, you should use a fallback image if your application supports environments that do not have JavaScript enabled or is progressively enhanced.\n\nYou can do this by adding the fallback image inside of a `<noscript>` tag in the render callback you provide as the `ProgressiveImage` component's child.\n\n```jsx\n<ProgressiveImage src=\"large-image.jpg\" placeholder=\"tiny-image.jpg\">\n  {src => {\n    return (\n      <div>\n        <img className=\"progressive-image\" src={src} />\n        <noscript>\n          <img className=\"progressive-image no-script\" src=\"large-image.jpg\" />\n        </noscript>\n      </div>\n    );\n  }}\n</ProgressiveImage>\n```\n\n### Props\n\n| Name        | Type                                   | Required | Description                                     |\n| ----------- | -------------------------------------- | -------- | ----------------------------------------------- |\n| children    | `function`                             | `true`   | returns `src`, `loading`, and `srcSetData`      |\n| delay       | `number`                               | `false`  | time in milliseconds before src image is loaded |\n| onError     | `function`                             | `false`  | returns error event                             |\n| placeholder | `string`                               | `true`   | the src of the placeholder image                |\n| src         | `string`                               | `true`   | the src of the main image                       |\n| srcSetData  | `{srcSet: \"string\", sizes: \"string\" }` | `false`  | srcset and sizes to be applied to the image     |\n\n## Maintenance Status\n\n **Stable:** Formidable is not planning to develop any new features for this project. We are still responding to bug reports and security concerns. We are still welcoming PRs for this project, but PRs that include new features should be small and easy to integrate and should not include breaking changes.\n\n[maintenance-image]: https://img.shields.io/badge/maintenance-stable-blue.svg\n","readmeFilename":"README.md"}