Giter VIP home page Giter VIP logo

react-render-in-browser's Introduction

React Render In Browser Component

Build Status npm version License: MIT

A React component that helps you render browser specific content.

Why? start with why

Ever wanted to put up a banner for all your IE users and ask them to try your site in Chrome/Firefox?

With RenderInBrowser component you can render content specific to browsers. ๐ŸŽ‰

<RenderInBrowser ie only>
  <div>All the magic tricks in this site work best in Chrome/Firefox!</div>
</RenderInBrowser>

Install

$ npm install --save react-render-in-browser

Usage

import RenderInBrowser from 'react-render-in-browser';

const Example = () => {
  return (
    <div>
      <RenderInBrowser ie only>
        <div>Ugh, our super duper animation won't work in IE</div>
      </RenderInBrowser>
      <RenderInBrowser except firefox safari>
        <div>Why don't you use Firefox or Safari?</div>
      </RenderInBrowser>
      <RenderInBrowser chrome firefox only>
        <div>I like Chrome and Firefox</div>
      </RenderInBrowser>
    </div>
  );
};

The div Ugh, our super duper animation won't work in IE will be rendered only in IE.

The div Why don't you use Firefox or Safari? will be rendered in all browsers except Firefox and Safari.

The div I like Chrome and Firefox will be rendered only in Chrome or Firefox.

API

Browsers

The following browsers are supported as prop types and they are case-sensitive.

  1. chrome
  2. firefox
  3. safari
  4. opera
  5. ie
  6. edge
  7. mobile

Note that mobile is a type of browser. Desktop chrome and mobile chrome are not the same although they share the same name. They are built independent of each other and what necessarily works in Desktop Chrome might not necessarily work in mobile Chrome. Most mobile browsers behave the same and identifying them apart is a bit tricky and thus we're grouping all mobile browsers into one.

Conditions

The following conditions are supported as prop types and they are case-sensitive.

only

When only is used, the children will render only in browsers passed as props.

<RenderInBrowser ie edge only>
  <div>Renderded only in IE and Edge</div>
</RenderInBrowser>

except

When except is used, the children will render in all browsers except those that are passed as props.

<RenderInBrowser except safari>
  <div>Rendered in all except safari</div>
</RenderInBrowser>

License

MIT ยฉ Dinesh Pandiyan

react-render-in-browser's People

Contributors

flexdinesh 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.