2.4.0 • Published 6 years ago

super-image v2.4.0

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

SuperImage

Greenkeeper badge Build Status devDependency Status peerDependency Status codecov

React component that render <img> with nicer interface

Install

$ npm install --save super-image

This package use Object.assign(), so you may need to polyfill via object.assign.

Usage

<SuperImage
  src="image.png"
  width="160"
  height="90"
  alt="super-image"
  fit="contain"
/>

Use <picture> element

Set sources property.

<SuperImage
  src="image.png"
  sources={[{
    srcSet : 'image.webp',
    type   : 'image/webp'
  }]}
  width="160"
  height="90"
  alt="super-image"
  fit="contain"
/>

Use object-fit fallback

Set fitFallback property true.

<SuperImage
  fitFallback
  src="image.png"
  width="160"
  height="90"
  alt="super-image"
  fit="contain"
/>

Config

PropertyTypeDescriptionDefault valueRequired
srcStringImage url-Yes
sourcesArraySets of <source> attributes: srcSet, sizes, media and type[]No
widthDOMStringImage width-No
heightDOMStringImage height-No
altStringAlternative text for <img>""No
roleStringWAI-ARIA for <img>-No
classNameStringclassName property for component""No
flexibleBooleanMake component fluidfalseNo
fitStringCSS object-fit property for <img> (contain or cover)-No
fitFallbackBooleanForce component to use background-imagefalseNo

License

MIT © FRESH!

2.4.0

6 years ago

2.3.0

6 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.1.0

7 years ago