• Stars
    star
    159
  • Rank 228,518 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React library to render browser specific content

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

More Repositories

1

dev-landing-page

Minimal landing page for developers
HTML
1,220
star
2

react-redux-boilerplate

A minimal React-Redux boilerplate with all the best practices
JavaScript
780
star
3

react-socks

πŸŽ‰ React library to render components only on specific viewports πŸ”₯
JavaScript
427
star
4

npm-module-boilerplate

Boilerplate for npm modules with ES6 features and all the best practices
JavaScript
387
star
5

blogster

A collection of beautiful, accessible and performant Astro blog templates.
Astro
310
star
6

typy

Minimal JavaScript type checking library
JavaScript
226
star
7

browser-or-node

Check where your code is running. In the browser or in node.js environment.
JavaScript
195
star
8

cache-busting-example

JavaScript
101
star
9

tweet-fancy

πŸš€ Tweet with bold, italics and strikethough text
CSS
42
star
10

design-system-boilerplate

A design system boilerplate monorepo with opinionated principles, theming and token setup to build your own design system.
TypeScript
40
star
11

gatsby-boilerplate

CSS
31
star
12

progressive-rendering-react

Example setup to progressively render a React app from the server
JavaScript
30
star
13

progressive-rendering

Demo β€” Stream portions of a webpage as chunks from the server
HTML
27
star
14

testing-hooks

Code examples to test custom React hooks with Enzyme
JavaScript
24
star
15

react-npm-package-boilerplate

Boilerplate code for building a React NPM library
JavaScript
24
star
16

code-cheatsheet

Quick reference code snippets curated from various sources
TypeScript
19
star
17

axios-retry-interceptor

Configurable Axios Interceptor to retry failed http calls.
JavaScript
18
star
18

keystone-static-blog

Starter template to statically generate blog websites with Next.js and Keystone
TypeScript
13
star
19

apollo-graphql-playbook

Notes and guides on using apollo client's APIs
12
star
20

portfolio

JavaScript
9
star
21

react-monorepo

Monorepo starter template to build React applications
TypeScript
9
star
22

babel-plugin-render-logger

βš™οΈ Babel plugin that automatically adds a console statement to React components and makes debugging easier
JavaScript
7
star
23

all-my-writeups

Curation of all my writeups πŸŽ‰
6
star
24

fahid-jokes

https://fahidjokes.netlify.com πŸ˜‚
JavaScript
5
star
25

git-handbook

Handbook on how to use git commands and strategies that make life easier
4
star
26

keystone-in-next

Moved to https://github.com/keystonejs/keystone/tree/main/examples/nextjs-keystone
TypeScript
3
star
27

happy-birthday-bhat

Bhat turns 25 - http://happybirthdaybhat.dkbox.in ⚑️
CSS
3
star
28

dineshpandiyan.com

Astro
3
star
29

keystone-docker

TypeScript
3
star
30

next-batch

A promise batching utility mostly used in GraphQL resolvers to avoid N + 1 data fetching
TypeScript
2
star
31

awesome-saas-stack

A curation of SaaS tools to build modern web applications.
2
star
32

node-express-boilerplate

JavaScript
2
star
33

cloudflare-pothos-boilerplate

Boilerplate to get started with Pothos in Cloudflare workers
TypeScript
2
star
34

keystone-template

Starter template to kickstart a Keystone project
TypeScript
1
star
35

next-multi-zone

1
star
36

v1.dineshpandiyan.com

v1 of dineshpandiyan.com
CSS
1
star
37

index

πŸ‘‹ Repos grouped together for quicker navigation.
1
star
38

outstatic-example

CSS
1
star
39

del-key

Delete keys from deeply nested objects in JavaScript
JavaScript
1
star
40

scrabble-game

Command line based scrabble game with in-built dictionary and alphabet scores
Java
1
star
41

parcel-react-starter

Starter template to build React applications. Tailwind + TypeScript.
TypeScript
1
star
42

react-ssr-parcel

This repo is an example setup to server render a React app
JavaScript
1
star
43

hook-diary

πŸš€ Open collection of custom react hooks
JavaScript
1
star
44

global-package-version

Library to check any npm module's version from browser console
JavaScript
1
star
45

v2.dineshpandiyan.com

v2 of dineshpandiyan.com
JavaScript
1
star
46

dontannoyme

Chrome Extension to block FB posts based on provided keywords
JavaScript
1
star
47

eventmanagement-front-end

JavaScript
1
star
48

v4.dineshpandiyan.com

v4 of dineshpandiyan.com
HTML
1
star
49

v3.dineshpandiyan.com

v3 of dineshpandiyan.com
HTML
1
star
50

parcel-extract-vendor-bundle

Example repo to extract vendors into a separate bundle using parcel shared bundles concept
TypeScript
1
star
51

spectacle-template-nextjs

A spectable template that doesn't work very well
TypeScript
1
star
52

yoga-pothos

Template to build a GraphQL API using graphql-yoga and pothos
TypeScript
1
star
53

git-rebase-vs-merge

Example repo to demonstrate how rebase vs merge works
JavaScript
1
star
54

react-devtools-demo

Demo project for React Devtools talk at React Sydney Sep 2019
JavaScript
1
star
55

parcel-react-package

React package template with parcel build setup
JavaScript
1
star
56

next13-edge-cache-bug

TypeScript
1
star
57

parcel-react-bare-minimum

Bare minimum parcel react web app boilerplate I use as a template to open issues in Parcel repo. TypeScript + Emotion
HTML
1
star