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

rn-utility-style

v1.0.3

Published

Utility styles for React Native

Downloads

5

Readme

RN Utility Style

RN Utility Style is utility-first style framework for rapidly building React Native User interface.


hero

Documentation

For full documentation, visit https://ariona.github.io/rn-utility-style/.

This library adopt Tailwind CSS framework which is an utility-first CSS framework for rapidly building website. In fact, we cherry picked some configuration and naming convention from tailwind so if you love using tailwind you'll love using RN Utility style.

Usage

Import Core component from rn-utility-style

import RNUtilityStyle, { buildComponent, View, Text, Image, Colors, apply } from 'rn-utility-style'

Use utility class on className props just like on the web.

<View className="rounded-lg bg-white shadow-xs">
  <Image className="rounded-t-lg w-full size-16/9" source={{uri:'https://unsplash.it/600/400'}}/>
  <View className="p-5 w-full">
    <Text className="text-indigo-700 mb-2 bg-indigo-100 rounded-full px-4 py-1 font-bold self-start">Blog</Text>
    <Text className="font-primary-bold font-xl mb-4">How to use search engine optimization to drive sales</Text>
    <Text className="text-gray-600 mb-6 font-sm">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fuga a unde ad alias cumque vel, qui tenetur enim, ipsam, nobis quo. Cumque a maiores nam dolorum, dignissimos similique sit molestiae.</Text>
    <View className="flex-row items-center">
      <View className="mr-4">
        <Image className="rounded-full size-1/1" source={{uri:'https://unsplash.it/64'}} style={{width: 36}}/>
        <View className="bg-green-500 rounded-full absolute b-2 border-white right-0" style={{width: 15,height: 15}}></View>
      </View>
      <View>
        <Text className="font-bold">Brenna Goyette</Text>
        <Text className="text-gray-500 font-sm">Mar, 16, 2020 - 6 min read</Text>
      </View>
    </View>
  </View>
</View>

Override some style with style prop

<Image className="rounded-t-lg w-full size-16/9" style={{width:300, height: 300}}/>

Usage with StyleSheet

To use the utility style with StyleSheet, use apply function

import { StyleSheet } from 'react-native'
import { apply } from 'rn-utility-style'

const style = StyleSheet.create({
  tag: apply( "text-indigo-700 mb-2 bg-indigo-100 rounded-full px-4 py-1 font-bold self-start" ),
  card: {
    ...apply( "rounded-lg bg-white shadow-xs" ),
    width: 400,
    height: 500,
    backgroundColor: 'red'
  }
})

Custom configuration

Place your configuration at the root of your app e.g index.js or app.js

import RNUtilityStyle from 'rn-utility-style'

RNUtilityStyle.loadConfig({
  baseFontSize: 16,
  fontFamily: {
    primary: {
      regular : "inter-regular",
      bold    : "inter-bold"
    }
  }
})

Example

Below is expo based example code for creating UI in above screenshot

import React, { useState } from 'react';
import { AppLoading } from 'expo'
import * as Font from 'expo-font';
import { StyleSheet, ScrollView, SafeAreaView as SafeView, StatusBar } from 'react-native';

const fetchFonts = () => {
  return Font.loadAsync({
    'inter-bold'        : require('./assets/fonts/Inter-Bold.otf'),
    'inter-bold-italic' : require('./assets/fonts/Inter-BoldItalic.otf'),
    'inter-italic'      : require('./assets/fonts/Inter-Italic.otf'),
    'inter-regular'     : require('./assets/fonts/Inter-Regular.otf')
  });
};

import RNUtilityStyle, { buildComponent, View, Text, Image, Colors, apply } from 'rn-utility-style'

// Loading custom config
RNUtilityStyle.loadConfig({
  baseFontSize: 16,
  fontFamily: {
    primary: {
      regular : "inter-regular",
      bold    : "inter-bold"
    }
  }
})

// Creating unsupported component
const SafeAreaView = buildComponent(SafeView)

export default function App() {
  const [dataLoaded, setDataLoaded] = useState( false )

  if ( !dataLoaded ) {
    return (
      <AppLoading
        startAsync={fetchFonts}
        onFinish={ ()=>setDataLoaded(true) }
      />
    )
  }

  return (
    <SafeAreaView className="p-10 justify-center flex-1 bg-gray-100">
      <StatusBar/>
      <View className="rounded-lg bg-white shadow-xs">
        <Image className="rounded-t-lg w-full size-16/9" source={{uri:'https://unsplash.it/600/400'}}/>
        <View className="p-5 w-full">
          <Text className="text-indigo-700 mb-2 bg-indigo-100 rounded-full px-4 py-1 font-bold self-start">Blog</Text>
          <Text className="font-primary-bold font-xl mb-4">How to use search engine optimization to drive sales</Text>
          <Text className="text-gray-600 mb-6 font-sm">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fuga a unde ad alias cumque vel, qui tenetur enim, ipsam, nobis quo. Cumque a maiores nam dolorum, dignissimos similique sit molestiae.</Text>

          <View className="flex-row items-center">
            <View className="mr-4">
              <Image className="rounded-full size-1/1" source={{uri:'https://unsplash.it/64'}} style={{width: 36}}/>
              <View className="bg-green-500 rounded-full absolute b-2 border-white right-0" style={{width: 15,height: 15}}></View>
            </View>
            <View>
              <Text className="font-bold">Brenna Goyette</Text>
              <Text className="text-gray-500 font-sm">Mar, 16, 2020 - 6 min read</Text>
            </View>
          </View>
        </View>
      </View>
    </SafeAreaView>
  );
}