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-native-responsive-sizes

v2.0.4

Published

Simple & lightweight react-native package to help you make your mobile app look terrific on every screen size.

Downloads

161

Readme

📱 react-native-responsive-sizes

⚙️ Installation

  • You may use either npm or yarn to install this package.
npm install react-native-responsive-sizes
yarn add react-native-responsive-sizes

⚙️ Usage

import React from "react";
import { width, height, size, fontSize } from "react-native-responsive-sizes";
import { View, Text } from "react-native";

export const SampleComponent = () => {
  return (
    <View
      style={{
        width: width(90), // 90% of the screen's width
        height: size(600), // originally 600
        marginTop: size(10), // originally 10
        backgroundColor: "blue",
        alignSelf: "center",
      }}
    >
      {[
        "First",
        "Second",
        "Third",
        "Fourth",
        "Fifth",
        "Sixth",
        "Seventh",
        "Eigth",
        "Ninth",
        "Tenth",
      ].map((text, index) => (
        <View
          key={`${text} ${index}`}
          style={{
            backgroundColor: "red",
            justifyContent: "center",
            marginTop: size(10), // originally 10
            height: size(40), // originally 40
            marginHorizontal: size(10), // originally 10
          }}
        >
          <Text
            style={{
              fontSize: fontSize(14),
              textAlign: "center",
            }}
          >
            {text}
          </Text>
        </View>
      ))}
    </View>
  );
};

⚙️ Description

Simple & lightweight react-native package to help you make your mobile app look terrific on every screen size. You may use the following functions to make your app more responsive.

| Function Name | Input | Output | Example | | ------------------------------------- | ----------------------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | MOST POPULAR: responsive.size() | number of pixels | number of pixels proportional to screen's height/width | If you use responsive.size(10) then you will receive 10 pixels on iPhone 14 Pro, but slightly different number of pixels for other screen sizes, such as 8 pixels on a smaller iPhone SE or 12 pixels on a larger iPhone 12 Max | | responsive.width() | number from 0-100, which corresponds to the percentage of the screen's width | number of pixels equal to the percentage of the screen's width | If you use responsive.width(50) then you will receive a number of pixels equal to 50% of the screen's width | | responsive.height() | number from 0-100, which corresponds to the percentage of the screen's height | number of pixels equal to the percentage of the screen's height | If you use responsive.height(50) then you will receive a number of pixels equal to 50% of the screen's height | | responsive.fontSize() | font size number | font size that's more proportional to the size of the screen | If you pass it responsive.fontSize(32) then you will receive a 32-point font-size on an iPhone 14 Pro, but slightly smaller font-sizes on smaller devices |

⚙️ Before & After Video Demonstration

  • Video can be found below, but if you cannot see it, then please follow this link.
  • In the video below, you can see how the app looks before and after using react-native-responsive-sizes
  • In the BEFORE code, you can see that the styles use constant values, such as: height of 600, marginTop of 10, marginHorizontal of 10, etc.
  • But in the AFTER code, you can see some very simple changes were made: responsive.size(600), responsive.size(10), responsive.size(10), etc.
  • With those changes, the app looks much proportional on screens of different aspect ratios.

https://github.com/react-native-responsive-sizes/assets/assets/54771184/6978ed10-d535-48d5-9dcb-56fcd6f6546c