Git Product home page Git Product logo

react-native-sizer's Introduction

React-Native-Sizer πŸ“

This is actually the standard code I use for the Intermediary app. Over time, almost all of my react-native projects use this code. So I think that making this package, will make it easier for me in the future.

P.S: I just made my first react-native package, please help to fix if anything wrong✌😁

API

Function Description
sizer(size, type) size: number
type: width or height

Usage

import RNSizer from 'react-native-sizer';

// Iphone X default dimension
const rns = new RNSizer();

console.log(`Height: ${rns.sizer(100, 'height')}`);
console.log(`Width: ${rns.sizer(50, 'width')}`);

Sample

height: 896px and width: 414px

So you can write like this:

import RNSizer from 'react-native-sizer';

const rns = new RNSizer(896, 414);

If you want to make a button like this:

You can write the full code like this:

import {View} from 'react-native';
import RNSizer from 'react-native-sizer';

const App = () => {
    const rns = new RNSizer(896, 414);
    
    return (
        <View style={{ height: rns.sizer(63), width: rns.sizer(374, 'w') }} />
    );
};

Credit: Meditation App Design

react-native-sizer's People

Contributors

craftalpian avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.