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

@ilz5753/rnutils

v0.2.3

Published

React Native Utils

Downloads

8

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

  • 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:

npm install @ilz5753/rnutils
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.

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:

<ReView>
  <ReText>This is animated text within an animated view.</ReText>
</ReView>

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:

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.

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:

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. Your proposals, bug reports, and pull requests are appreciated.

License

RNUtils is licensed under the MIT License. See the 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.