0.1.3 • Published 5 years ago

@james-wiens/react-components-image v0.1.3

Weekly downloads
4
License
-
Repository
github
Last release
5 years ago

@james-wiens/react-components-image

React image component with all of the bells & whistles Image loading is one of the most common impacts on performance.

  • generates base64 small low quality placeholders on the server
  • used IntersectionObserver to load images only when scrolled to
  • update the URL to pass params based on the container elements size to fit the screen
  • accessible and semantic, using picture and srcset (it can also generate a media srcset list from a single src url string input)
  • on slow network, it will not automatically download the images, instead it will show click to download with the respective icon
  • if the loading errors, it show the error icon and text accordingly
  • when the user goes offline, if it is not already downloaded, it will show the offline icon until they go online again
  • when loading, loading icon shows overlayed on the image
  • on the server, measures the size of the image to get the width and height (as required by amp, and html built in lazy loading attribute) and puts into a rehydratable ssr script
  • support for AMP
  • has support for older browsers using an XHR request that is cancellable and can be configured with props for a max timeout before making it click to download though this is excluded by default since it's a fair bit of code size and only needed for older browsers
  • material icons for offline, download, warning, loading, etc (available in the ImageComponentWithDefaults, or as a render prop)
  • runs puppeteer to determine which images are above the fold, saves to JSON, then that JSON is used on the server to render the image always above the fold (show the src) this part is not finished yet but WIP
  • caching & persistence using OneStorage (universal interface for storage on server and browser using file system, local storage, indexdb, in memory, and any additional adapters) as it's own package, optional, comes with ImageComponentWithDefaults
  • custom minimal ssr (with hooks and context) as it's own package, optional, comes with ImageComponentWithDefaults

  • all typescript typings

  • storybook
  • gzip size ~4kb, 75% test coverage

https://jameswiens.dev

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago