Code Monkey home page Code Monkey logo

react-picture's Introduction

react-picture

Build Status

React component for rendering responsive images. Attempts to implement <img srcset=...> support in non-compliant browsers, otherwize renders the native <img srcset>. Will eventually support Picture & Source elements.

How to use

npm install react-picture

Then use in your react app like so:

var Img = require('react-picture').Image;
...
   render: function() {
   	  var imgs = '//placebacon.net/200/150 600w, //placebacon.net/300/300 800w';

      return (
      	<Img alt='Your picture description' srcSet={imgs} extra={{className:'myImg'}}/>
      );
   }
...

The following properties can be passed to the Image component:

  • alt - Required and describes your picture
  • srcSet - Required and consists of a string formated like srcset
  • extra - Optional object which contains properties that will be put on img tag

Features

  • Use <img srcset> when supported
  • Implement srcset support for browsers that do not have it, using javascript. Currently missing sizes implementation.

Roadmap

0.1.0

  • Implement sizes attribute

1.0

  • Stable API
  • Correct implementation of match method
  • Verify srcset feature detection
  • ie8 & up browser support (w/React polyfills only)
  • Performance optimizations
  • Ismorphic support
  • 100% test coverage
  • Travis CI

To be discussed

  • PictureContainer
  • Karma tests

2.0

  • Picture element
  • Source element

References

Alternative libraries

Acknowledgements

  • React's excellent library & documentation
  • Ryan Florence's components on github which were stolen to start up (webpack setup, browserify, scripts)
  • This excellent article

react-picture's People

Contributors

benox3 avatar ldesplat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.