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-pixel-perfect

v1.0.2

Published

helps you create pixel perfect apps by design

Downloads

23,007

Readme

react-native-pixel-perfect

helps you create pixel perfect apps by design, no matter the screen

About

This module was created for developers who create react-native apps from design and wants to keep their app pixel perfect across all devices, quickly and easily.

All you require to use this module is a design for an app, using one type of size units, for example pixels.

Then you need to measure the screen size in the design and use the create function to genrate a function to compute the correct size for the current device, see more info below.

This method is in use in production in more than a few apps both for android and for ios, works perfectly both for layout and font sizes, as long as the font sizes in the design uses the same type of size unit.

NOW ALL YOU NEED TO DO IS TO PLUG THE MESAUREMENTS YOU TAKE FROM YOUR DESIGN inside the perfectSize function and your app will look great on ALL DEVICES

The module comes with predefined resolutions for Apple devices, see more info below.

Installation

yarn add react-native-pixel-perfect

or with npm

npm install react-native-pixel-perfect --save

link to npm page

Usage

import

import { create } from 'react-native-pixel-perfect'

or

import { create, PREDEF_RES } from 'react-native-pixel-perfect'

in case you want to use one of the presets screen resolutions, see table down below

Basic Usage - custom screen size

Important: you can enter what kind of size you want and always use the same unit type. (for example: px,dp,dpi,etc.)

const designResolution = {
    width: 1125,
    height: 2436
} //this size is the size that your design is made for (screen size)
const perfectSize = create(designResolution)

perfectSize(50)// returns the actual size needed to make 50 fit the screen perfectly according to original design

Basic Usage - predefined screen size (pixels)

import { create, PREDEF_RES } from 'react-native-pixel-perfect'

const perfectSize = create(PREDEF_RES.iphoneX.px)

perfectSize(50)// returns the actual size needed to make 50 fit the screen perfectly according to original design

Basic Usage - predefined screen size (points)

import { create, PREDEF_RES } from 'react-native-pixel-perfect'

const perfectSize = create(PREDEF_RES.iphoneX.dp)

perfectSize(50)// returns the actual size needed to make 50 fit the screen perfectly according to original design

Availble Predefined Resolutions

Device | Key | pixels | points ------------------------------------|-------------|-------------|------------ iPhone X |iphoneX | 1125 x 2436 | 375 x 812 | iPhone 8 Plus |iphone8P | 1080 x 1920 | 414 x 736 | iPhone 8 |iphone8 | 750 x 1334 | 375 x 667 | iPhone 7 Plus |iphone7P | 1080 x 1920 | 414 x 736 | iPhone 6s Plus |iphone6sP | 1080 x 1920 | 375 x 667 | iPhone 6 Plus |iphone6P | 1080 x 1920 | 375 x 667 | iPhone 7 |iphone7 | 750 x 1334 | 375 x 667 | iPhone 6s |iphone6s | 750 x 1334 | 375 x 667 | iPhone 6 |iphone6 | 750 x 1334 | 375 x 667 | iPhone SE |iphoneSE | 640 x 1136 | 320 x 568 |

How to access predefined resolution

All you need to do is look at the table above and then use the imported BASE_RES object like so:

for pixels:

PREDEF_RES.key.px

or

PREDEF_RES[key].px

for points:

PREDEF_RES.key.dp

or

PREDEF_RES[key].dp

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License