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

@artsy/detect-responsive-traits

v0.1.0

Published

Get responsive size traits from a user agent

Downloads

7,879

Readme

@artsy/detect-responsive-traits

This package provides information about devices, based on their reported user-agent, that gives insight into what responsive traits the device has. This can be used with a package such as @artsy/fresnel to only render markup on the server that the device actually supports and reduce the amount of bytes that need to be sent.

This package only cares about the viewport ‘width’ that the device supports, as that’s the only dimension that Artsy’s designs take into consideration.

Usage

The package exports a single findDevice function, which given a user-agent string finds the first entry from the exported Devices list that matches. The result has the following fields of interest:

{
    minWidth: number
    maxWidth: number
    resizable: boolean
    touch: boolean
}

In case resizing is supported, the device should be considered as being able to display at any size between minWidth and maxWidth. In case resizing is not supported, minWidth and maxWidth should be considered as the only two possible width values.

The touch value indicates if the device has a touch-screen.

Example

The react-responsive-media example app for a demonstration of how to use this with server-side rendered React.

Caveats

We only cover user-agents of which we’ve seen more than 1000 visits over the past 2 weeks on artsy.net. When new devices appear in that list we’ll add those to the existing coverage. Having said that, we very much appreciate additional coverage in the form of pull-requests!

In our current Android coverage we have many devices defined with a minWidth of 0, because we haven’t yet determined what the minimum width is on these devices that Chrome will display at when resizing the window. In case you own these devices, please visit a site that reports the viewport and test what the minimum width is both in portrait and landscape mode.

How do I work on this?

git clone https://github.com/artsy/detect-responsive-traits.git
cd detect-responsive-traits
yarn install

# Open VS Code with `code .`

# Run tests
yarn jest

How do I deploy this?

This project uses auto-release to automatically release on every PR. Every PR should have a label that matches one of the following

  • Version: Trivial
  • Version: Patch
  • Version: Minor
  • Version: Major

No release will happen on a Trivial update.