Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilz5753/rnutils
Crafting seamless UI/UX in React Native with RNUtils 🚀 Passionate about bridging design and code Contributing to fluid mobile experiences one animation at a time 💫
https://github.com/ilz5753/rnutils
animation-library hooks react react-native react-native-module utility-library
Last synced: 24 days ago
JSON representation
Crafting seamless UI/UX in React Native with RNUtils 🚀 Passionate about bridging design and code Contributing to fluid mobile experiences one animation at a time 💫
- Host: GitHub
- URL: https://github.com/ilz5753/rnutils
- Owner: ilz5753
- License: mit
- Created: 2023-12-12T21:24:29.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-09T10:03:45.000Z (10 months ago)
- Last Synced: 2024-11-16T23:34:43.514Z (about 1 month ago)
- Topics: animation-library, hooks, react, react-native, react-native-module, utility-library
- Language: TypeScript
- Homepage:
- Size: 1.92 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
# RNUtils (@ilz5753/rnutils) Comprehensive React Native Styling, Animation & Utils Library
RNUtils is an all-encompassing library designed to provide React Native developers with an extensive suite of tools for creating dynamic styles, animations, and utility functions for an improved developer experience and efficient, clean codebases.
## Table of Contents
- [Features](#features)
- [Installation](#installation)
- [Animated Components](#animated-components)
- [Animated Components Usage](#animated-components-usage)
- [Hooks](#hooks)
- [Utility Functions](#utility-functions)
- [API Reference](#api-reference)
- [Types](#types)
- [Static Styles Functions](#static-styles-functions)
- [Platform-Specific Utilities](#platform-specific-utilities)
- [Platform-Specific Utilities Usage](#platform-specific-utilities-usage)
- [Extensibility](#extensibility)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgments](#acknowledgments)## Features
- A range of **Animated Components** for improved user experiences with smooth animations
- **Hooks** that tap into Reanimated 3(3.3.0) for fluid animations and gestures
- **Regular expressions** to identify numeric and percentage-based values
- **Utility functions** to streamline common style pattern generations
- **Type support** for TypeScript users to leverage strong typing throughout their styles## Installation
To install the library, run the following command in your React Native project:
```bash
npm install @ilz5753/rnutils
``````bash
yarn add @ilz5753/rnutils
```## Animated Components
The library wraps common React Native components, providing animated versions that can be used interchangeably to enhance your application.
```ts
import { ReView, ReText, ReTouchableOpacity } from '@ilz5753/rnutils';
```### Animated Components Usage
These components act as drop-in replacements for their React Native equivalents, now with support for animated styles generated by Reanimated:
```tsx
This is animated text within an animated view.
```
## Hooks
`RNUtils` provides a rich set of hooks for working with shared and derived values, easing the animation process with tools for color, dimension, and number interpolations.
**`useCacheShareValue`**
This hook manages a shared value for animations with a caching mechanism that memorizes the previous and current states to facilitate reversed or repeated animations.
**`useColors`**
Provides a suite of animated styles based on a single color value for different properties including `backgroundColor`, `borderColor`, and more.
**`useNumberSizes`**
Generate numeric size-based styles like `flex`, `borderRadius`, or `fontSize` that are animatable.
**`useDimensionSizes`**
Manipulate dimensions like `width`, `height`, `margin`, and `padding` with animated support for fluidly responsive designs.
## Utility Functions
The library includes numerous utility functions to aid in quick style generation, border radii control, color manipulations, shadow handling, and layout shortcuts, along with others that determine the current operating system for conditional styling logic.
**`getStyle`**
Retrieve predefined styles for common needs using design tokens:
```ts
const center = getStyle(['aic', 'jcc']); // Align items center, Justify content center
```## API Reference
For in-depth documentation on the API, including all methods, hooks, and components, please refer to the included API documentation in the package.
## Types
TypeScript users can employ RNUtils’ comprehensive types to enforce strict typing throughout their styling code. The library exports types for every provided function and utility, ensuring that errors can be caught at compile-time.
```ts
import type {
CustomDimensionValue,
StrNum,
DerivedColor,
DerivedDimension,
} from '@ilz5753/rnutils';
```**`CustomDimensionValue`**
Allows either a number or a string percentage value, supporting dynamic dimensions.
**`StrNum`**
A union type that embraces both string and number, facilitating flexible API design where both types are commonplace.
**`DerivedColor`**, **`DerivedDimension`**
Wrap Reanimated’s DerivedValue for specific use-cases like colors and dimensions, associating strong typing with animated values.
## Static Styles Functions
With a focus on flexibility, static functions are provided to create scalable styles with minimal code, perfect for a range of scenarios from theming to dynamic user-driven styles.
## Platform-Specific Utilities
Detect the current platform using booleans like `isAndroid` or `isIos`, or check for mobile environments in general with `isMobile`.
### Platform-Specific Utilities Usage
Import and use functions directly within your style definitions:
```ts
import { backgroundColor, flex, Layout } from '@ilz5753/rnutils';const styles = {
...backgroundColor('blue'),
...flex(1),
...Layout('50%', '25%'),
};
```## Extensibility
RNUtils is designed to be extensible, working alongside your existing solutions and third-party libraries, allowing for broad compatibility and comprehensive styling control within React Native.
## Contributing
We welcome contributions to make RNUtils better for everyone. If you’re looking to contribute, please follow the guidelines in [CONTRIBUTION.md](/CODE_OF_CONDUCT.md). Your proposals, bug reports, and pull requests are appreciated.
## License
RNUtils is licensed under the MIT License. See the [LICENSE](/LICENSE) file for more details.
## Acknowledgments
Special thanks to all the contributors and the open-source community for their ongoing support and inspiration.
---
For more detailed usage and API information, please refer to the individual files pertaining to components, hooks, and utilities you wish to employ.