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

react-resp

v1.0.0

Published

Dynamically build responsive layouts in React

Downloads

6

Readme

react-resp

Dynamically build responsive layouts in React

react-resp is a React library that provides a set of utility components to dynamically build responsive layouts

🛠️ Install

Using npm

npm i react-resp

🔗 Usage

react-resp exports multiple components. These components have the name of the viewports they bind to, named <[Viewport]>, as well their inverse, named <Not[Viewport]>.

One such component is called <Mobile>, and it's inverse is <NotMobile>

Below are some examples to get you started:

Strict Viewports only

Using the syntax below, you can dynamically render specific components/elements for a given viewport, based on current viewport specified

import { Mobile, Tablet, Laptop } from 'react-resp'

const Navbar = () => {
  <nav className="navbar">
      <div className="navbar-description">
        <Mobile>Mobile: Short Description</Mobile>
        <Tablet>Tablet: Slightly longer description on a tablet screen</Tablet>
        <Laptop>
          Laptop: A very long description that is displayed on laptop screens and has a lot of words
        </Laptop>
      </div>
  </nav>
}

Strict and Exceptional "Not" Viewports

By using a combination of <[Viewport]> and <Not[Viewport]>, you can dynamically render specific components on a single viewport of your choice, and render something else on all other viewport except the one you've already targeted

import { Mobile, NotMobile } from 'react-resp'

const Navbar = () => {
  <nav className="navbar">
    <div className="navbar-description">
      <Mobile>Mobile: Short Description</Mobile>
      <NotMobile>
        Tablet and Laptop: A description that is displayed on all viewports except mobile
      </NotMobile>
    </div>
  </nav>
}

This approach could useful in various practical situations. For example, if you wanted to render all navbar links on tablet and laptop devices, but display a hamburger icon on mobile, you could this library to accomplish your task

🔮 API

<[Viewport]>

  • Available viewports

| Viewport | Targeted Breakpoints | | ---------- | -------------------- | | <Mobile> | x <= 640px | | <Tablet> | 640px <= x <= 1024px | | <Laptop> | x >= 1024px |

<Not[Viewport]>

  • Available viewports

| Viewport | Targeted Breakpoints | | ------------- | -------------------------- | | <NotMobile> | x >= 640px | | <NotTablet> | x <= 640px and x >= 1024px | | <NotLaptop> | x <= 1024px |

These breakpoints have been borrowed from Tailwind's Responsive Design docs`

Custom viewports coming soon

❤️ Support

You can support further development of this project by giving it a 🌟 and help me make even better stuff in the future by buying me a ☕

Also, if you liked this repo, consider checking out my other projects, that would be real cool!