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-screen-scaler

v1.0.0

Published

Design Once, Render Everywhere: Screen-size agnostic React development for uniform environments

Downloads

10

Readme

WARNING: This library is a work in progress, it is not ready for production use.

React-ScreenScaler is a tool specifically designed for developers who build web applications targeting a specific user base with uniform screen resolutions. This library helps you create applications on a defined screen resolution and takes care of scaling, either by stretching or shrinking, to accommodate deviations.

Features

  • Automatically scales your React app to fit any screen size different than your target resolution.
  • Emulates a runtime environment where all your users always have the given screen resolution.
  • Overwrites the getDomRect() function to provide the size an element would have on your targeted screen resolution.

Limitations

  • This library only works with Single Page Applications (SPA) using React.
  • Server-side rendering is not supported. The use of "vh" and "vw" CSS properties is not supported because they can't be override.

## Usage

Make it so that your app is always rendered as if the user had a screen resolution width of 1920.

import { createScreenScaler } from "react-screen-scaler";

const { ScreenScaler } = createScreenScaler({
    // The zoom factor if for supporting when the use zooms in or out (ctrl + mouse wheel or ⌘ + '+' or ⌘ + '-') ...
    targetWindowInnerWidth: ({ zoomFactor }) => 1920 * zoomFactor

    // If you don't want to enable your user to zoom at all you can provide an absolute value
    //targetWindowInnerWidth: 1920
});

export function App() {
    return <ScreenScaler>{/* Your app here */}</ScreenScaler>;
}

Workaround for portrait mode

When your app is rendered in a device in portrait mode, if you haven't accommodated for this your app will appear very tiny at the top of the screen and most of the screen will be unused.

In this case, you have two options:

1: Implement a portrait mode version of your app. 2: Tell your user to rotate their device:

import { createScreenScaler } from "react-screen-scaler";

const { ScreenScaler } = createScreenScaler({
    targetWindowInnerWidth: ({ zoomFactor, isPortraitOrientation }) =>
        isPortraitOrientation ? undefined : 1920 * zoomFactor
});

export function App() {
    return <ScreenScaler fallback={<h1>Rotate your phone</h1>}>{/* Your app here */}</ScreenScaler>;
}

Contributing

git clone https://github.com/garronej/react-screen-scaler
cd react-screen-scaler
yarn

# Start the test app in watch mode
yarn start-test-app

# Link in an external project in watch mode
yarn link-in-app YOUR-APP # ../YOUR-APP is supposed to exist