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-styduce

v0.0.3

Published

A styling helper for react native projects

Downloads

3

Readme

react-native-styduce

A styling Helper for react native projects

installation

npm install --save react-native-styduce

Roadmap

  • an option to remove redundant or unusuded style in the resulted style object
  • writting test!
  • better source code (commenting etc) (sorry that for now it's cryptic)
  • more functionality

usage

styles.js

const styduce = require('react-native-styduce');
const { createStyle } = styduce;

const exampleStyle = {
  container: {
    backgroundColor: '#000',
    height: 70,
    __heading: {
      height: 20
    },
    $$subPage: {
      backgroundColor: '#fff'
    },
};

/*
  The above exampleStyle will translte to
  {
    container: {
      backgroundColor: '#000',
      height: 70
    },
    container__heading: {
      height: 20,
    },
    container$$subPage: {
      height: 70,
      backgroundColor: '#fff'
  },
*/
export default createStyle(exampleStyle);

Philosophy

What i'm trying to do here is to make styling more easy. for me it's easier if there are a single source of style in my react native project. but there are some problem as styling in web is different than styling in react native. in web we can have a multiple class in one DOM. but i have difficulties when i want to follow BEM naming conventions. this plugin try to accomodate BEM-like (because it's somehow different) style structuring in react native. this plugin also support nesting for the naming. for example

const exampleStyle = {
  container: {
    __heading: {
      __subHeading: {
      }
    }
  }
  
  createStyle(exampleStyle) 
  //will translate to
  container: {
  ...container style
  }
  container__heading{
  ...container heading style
  }
  container__heading__subheading{
  ...container subheading style
  }

NOTE that the container__heading doesnt inherit from the container. because it's a different block and seems illogical if it inherit from the container. for example, if a header have a margin of 5px, the logo block doesnt have to have a margin of 5px.

Convention

The plugin use two convention for styling. which is __ (doble underscore) for block. and $$ for modifier. there is a major difference between the two.

  1. Block doesnt inherit from the parent
  2. while $$ (modifier) inherit from the parent Example:
const style = {
  button: {
    height: 50
    $$active: {
      backgroundColor: '#FFF'
    }
  }
}

createStyle(style)
//will translated to
{
  button: {
    height: 50
  }
  button$$active: {
    height: 50,
    backgroundColor: '#fff',
  }
}

use in component

...
import { TouchableOpacity,Text ...} from 'react-native';
import styles from './styles.js'

const sample = ({}) => (
  <TouchableOpacity style={styles.button$$active} >
    <Text> Press Me </Text>
  </TouchableOpacity>
);

export default sample;

The downside of this styling approach is if all of our button is having modifier than the main button style become redundant to the styling object.