npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

showif

v1.0.0

Published

![Build](https://img.shields.io/travis/hosein2398/showIf.svg) ![Dependencies](https://img.shields.io/david/hosein2398/showIf.svg) ![Devdependencies](https://img.shields.io/david/dev/hosein2398/showIf.svg) ![Greenkeeper badge](https://badges.greenkeeper.i

Downloads

3

Readme

ShowIf

Build Dependencies Devdependencies Greenkeeper badge

Conditionally show/hide elements on your page depending on what user's browser is.

##Installing

npm i showif --save

Usage

There are three approaches to use this library.

  • Show/hide an element based on type of user's browser.
  • Show/hide an element based on type and version of user's browser.
  • Add/remove a className based on type and version of user's browser.

So now lets try out each one with examples. For first one you need to add wanted className to the element for instance if you want to hide a element only on chrome you can write:

<div class="hide-if-chrome">not shown in Chrome</div>
<div class="hide-if-firefox">not shown in Firefox</div>

So they are obvious enough to understand.

For second approach which you can also define the browser's version here goes an example:

 <div class="show-if-firefox(>56) otherclass"> Lorem!.... </div>

This one will only be shown if the browser is Firefox and also if it's version is higher than 56. Let's check out another one:

<div class="show-if-firefox(=55)"> Say nothing </div>

This will only be represented in Firefox 55 ! Absolutely you can do contrary like :

<div class="hide-if-chrome(<55)"> Say nothing </div>

This will be hidden in Chrome with version less than 55 . (or shown in Chrome with v. higher than 55)

Now the third approach , which you can define your condition and also the class you want to be embedded when that condition goes right :

<p data-if-chrome="myclass"> Yeah </p>

So this will add class of myclass to this tag if user is in Chrome. Let's see another one:

 <div data-if-chrome="(>54) myclass bold-it"> Sunday </div>

So this will add the classes myclass and bold-it to this element if user's in Chrome and it's version is higher that 54. Now last one:

<p data-if-chrome="(=56) reddy"> Working on it </p>

This one will have reddy class only in Chrome 56.