Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/benzhe/react-native-relative-units
https://github.com/benzhe/react-native-relative-units
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/benzhe/react-native-relative-units
- Owner: benzhe
- License: mit
- Created: 2015-09-09T07:20:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-23T08:20:44.000Z (over 7 years ago)
- Last Synced: 2024-04-14T06:06:28.778Z (about 2 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-react-native - react-native-relative-units ★9 - Relative units for React Native (Components / UI)
- awesome - react-native-relative-units ★9 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★9 - Relative units for React Native (Components / UI)
- awesome-react-native-master - react-native-relative-units ★2 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★8 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★9 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★8 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★9 - Relative units for React Native (Components / UI)
- awesome-react-native-ui - react-native-relative-units ★5 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★9 - Relative units for React Native (Components / UI)
- awesome-react-native - react-native-relative-units ★3 - Relative units for React Native (Components / UI)
README
# react-native-relative-units
An simplest relative units module for react native. Design for scale pages in different devices, NOT FOR RESPONSIVE DESIGN.
## Install
```
npm install react-native-relative-units --save
```## Using
```
var {bp, vw, vh} = require('react-native-relative-units')(/* Mockup page's width */);
```## Example
```
var {bp, vw, vh} = require('react-native-relative-units')(375);var styles = StyleSheet.create({
viewport: {
width: 375 * bp, // 100% device width, same as width: 100 * wh
height: 100 * vh, // 100% device height
marginTop: 20 * bp, // 20/375 device width
borderWidth: 1 // bp is not recommend in border
}
});
```