Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kdn0325/react-native-dimensions-layout
Do you want to develop using consistent design in React Native? This library makes it easy to create
https://github.com/kdn0325/react-native-dimensions-layout
adobe-xd figma react-native react-native-dimentions
Last synced: 25 days ago
JSON representation
Do you want to develop using consistent design in React Native? This library makes it easy to create
- Host: GitHub
- URL: https://github.com/kdn0325/react-native-dimensions-layout
- Owner: kdn0325
- License: mit
- Created: 2024-03-09T12:08:57.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-03-15T16:29:44.000Z (8 months ago)
- Last Synced: 2024-10-05T19:20:11.524Z (about 1 month ago)
- Topics: adobe-xd, figma, react-native, react-native-dimentions
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/react-native-dimensions-layout
- Size: 1.63 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-dimensions-layout
react-native-dimensions-layout
- As a React Native developer, we need to determine the size of components with different display sizes for each device using the app
- Usually, when collaborating using Figma, calculating is annoying and there is a possibility of making mistakes. Even if it is modularized, it can be inaccurate sometimes. It is also difficult to cope with foldable phones or horizontal modes. And some components don't work with percentage
- The best recommendation is using `useWindowDimension` Hooks## Installation
```sh
npm install react-native-dimensions-layout
# or
yarn add react-native-dimensions-layout
```## Usage
### widthPercentage(width: number): number
Calculates the percentage value of the width relative to the screen width.```javascript
import { widthPercentage } from 'react-native-dimensions-layout';const screenWidth = 200; // Current screen width
const widthInPercentage = widthPercentage(screenWidth);
console.log(widthInPercentage); // Percentage value of the screen width
```heightPercentage(height: number): number
Calculates the percentage value of the height relative to the screen height.### heightPercentage(height: number): number
Calculates the percentage value of the height relative to the screen height.```javascript
import { heightPercentage } from 'react-native-dimensions-layout';const screenHeight = 400; // Current screen height
const heightInPercentage = heightPercentage(screenHeight);
console.log(heightInPercentage); // Percentage value of the screen height```
### fontPercentage(size: number): number
Calculates the percentage value of the font size```javascript
import { fontPercentage } from 'react-native-dimensions-layout';const fontSize = 20; // Font size
const fontSizeInPercentage = fontPercentage(fontSize);
console.log(fontSizeInPercentage); // Percentage value of the font size
```### horizontalScale(value: number): number
Scales the value provided based on the horizontal size of the screen.```javascript
import { fontPercentage } from 'react-native-dimensions-layout';const fontSize = 20; // Font size
const fontSizeInPercentage = fontPercentage(fontSize);
console.log(fontSizeInPercentage); // Percentage value of the font size
```### verticalScale(value: number): number
Scales the value provided based on the horizontal size of the screen.```javascript
import { horizontalScale, verticalScale } from 'react-native-dimensions-layout';const widthValue = 100; // Value to scale horizontally
const heightValue = 100; // Value to scale verticallyconst scaledWidth = horizontalScale(widthValue);
const scaledHeight = verticalScale(heightValue);console.log(scaledWidth); // Scaled width value
console.log(scaledHeight); // Scaled height value```
## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT
---
Made with [create-react-native-library](https://github.com/callstack/react-native-builder-bob)