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

@tapston/react-native-styles

v1.1.1

Published

Make your styles very similar for any device screen

Downloads

30

Readme

@tapston/react-native-styles

Make your styles very similar for any device screen 📱

Installation

yarn add @tapston/react-native-styles

Usage

  • Import
import RNStyles from '@tapston/react-native-styles';
  • Initialize you config for RNStyles in index.js
// If you need your own config:
RNStyles.init({
  designWidth: 428, // default value is 428
  designHeight: 926, // default value is 926
  minimalFactor: 1, // default value is 1
});
// designWidth - Width of your design. Default value is 414 (iPhone 12 Pro Max).
// designHeight - Height of your design. Default value is 896 (iPhone 12 Pro Max).
// minimalFactor - Factor is the value all numeric styles are multiplied by. The default minimal factor is 1.

Create your styles

const myStyles = RNStyles.create({
  // Get a rectangle if the screen of your device is not square
  container: {
    width: 100,
    height: 100,
  },
  // Square with average relativity to width and height
  squareContainer: {
    square: 100,
  },
});

Static values

If you want your value to be static, use a string value instead of a number

{
  width: '100', // Width will be equal to 100 on all devices
  height: 100, //  Height will depend on the size of a device
}

screenHeight or screenWidth

If you want to use screenHeight or screenWidth in your project, please look at the example:

// In your global styles.js file:
const { width, height } = Dimensions.get('window');
export const screenWidth = width;
export const screenHeight = height;
// In your screen-view.js file:
import { screenWidth, screenHeight } from '../../styles';
...
{
  width: `${screenWidth / 2}`,
  height: `${screenHeight + 24}`,
}

Factor (multiplier)

If you want to change all the sizes of the entire project, change minimalFactor in the constructor

{
  ...,
  minimalFactor: 1.2, // To increase the size of all elements by 20%
}

Percents

  block: {
    width: '75%',
  },

Media queries

  block: {
    width: '75%',
    '@media (min-width: 375) and ios': {
      width: '50%',
      height: 36,
      borderRadius: '6',
    },
  },

Media queries can operate with the following values:

  • media type: ios/android
  • width, min-width, max-width
  • height, min-height, max-height
  • orientation (landscape/portrait)
  • aspect-ratio
  • direction (ltr/rtl)

Math operations

  container: {
    maxWidth: 4 * (192 + (96/2)),
  },

Q&A

If you have any troubles with 'react-native-extended-stylesheet', try this:

yarn add react-native-extended-stylesheet