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

react-native-tstyles

v1.0.0-beta3

Published

Tachyons-like styles for React Native

Downloads

54

Readme

React Native Tachyons Styles

Tachyons-like styles for React Native

NPM version

Configuration

There are two possible options: using default styles or init with a custom config.

Default styles

/* View styles: {
  marginHorizontal: 16,
  flex: 1,
  flexDirection: 'row',
  justifyContent: 'flex-end',
} */

import s from 'react-native-tstyles'

function MyView() {
  return (
    <View style={s`mh16 f1 row jcfe`}>
      ...
    </View>
  )  
}

Init with custom config

ui/styles.js

import {createStyles} from 'react-native-tstyles'

export default createStyles({
  dimensions: [14], // extra, default in dimensions.js
  fontSizes: [56],  // extra, default 0-48
  indexes: [14],    // for zIndex and elevation; extra, default 0-10
  colors: {
    White: '#ffffff',
    Purple: '#6963d6',
    Yellow: '#FFFF00',
  },
  styles: { // custom extra styles
    paper: {
      elevation: 1,
      shadowOffset: {
        width: 1,
        height: 1,
      },
      shadowRadius: 1,
      shadowOpacity: 0.2,
      borderRadius: 2,
      backgroundColor: 'white', 
    },
  },
})

paper-with-text.js

/* View styles: {
  marginHorizontal: 14,
  flex: 1,
  alignItems: 'center',
  elevation: 1,
  shadowOffset: {
    width: 1,
    height: 1,
  },
  shadowRadius: 1,
  shadowOpacity: 0.2,
  borderRadius: 2,
  backgroundColor: 'white',
} */
  
/* Text styles: {
  fontSize: 56,
  color: '#6963d6',
} */

import s from 'ui/styles'

export default function PaperWithText({text, warn}) {
  return (
     <View style={s`mh14 f1 aic paper`}>
       <Text style={s(`fs56`, warn ? `yellow` : `purple`)}>
         {text}
       </Text>
     </View>
  )
}

Preventing extra rendering memo'ized and Pure- components

s take care result style property do not change if source styles are the same. Styles checked by the reference not by the value. So prevent using new js objects each render time like s('row', {height: 160}). If you need custom style than you should create it once and use as function argument s('row', heightStyle).

cn() helper: classname for ReactNative

You can use cn() helper for conditional styles.

s.cn(
  [flag1, onStyles1, offStyles1],
  [flag2, onStyles2, offStyles2],
  ...
)
import s from 'react-native-tstyles'

function SelectableText({
  enabled,
  selected,
  ...props
}) {
  const textStyle = s.cn(
    [enabled, 'fs16', 'fs14'], // if enabled than s.fs16 else s.fs14
    [selected, 'ttu b'],  // if selected than s.ttu and s.b
  )

  return (
    <Text {...props} style={textStyle}/>
  )
}