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-style-parser

v0.7.0

Published

CLI transform css files to javascript object

Downloads

17

Readme

react-native-style-parser

node CI

Command line interface transform css files to javascript object

You want create a app react-native but write you style inside javascript object is not you enjoy ? Now you can convert css files to javascript object.

react-native-style-parser

installation

Can local or global install this package

> npm install --save-dev react-native-style-parser

or with yarn

> yard add react-native-style-parser -D

or global

> npm install --global react-native-style-parser

config

After installation from package.json add key script for access to command line

{
  "scripts": {
    "build-style": "react-native-style-parser"
  }
}

For check access to command try show version with --version option

> npm run build-style -- --version

file

Can config from JS or JSON file at root

module.exports = {

  // path to css files
  entry: "./styles/css/",

  // path to generate output js file
  output: "./styles/react/",

  options: {

    isEs6: true,
    isNoQuote: true,
    isWatch: true,
    isOptimize: false
  }

};

more informations on options

run from config file with

{
  "scripts": {
    "build-style": "react-native-style-parser ./config-file-name.js"
  }
}

Can generate a preset config file at root with

> react-native-style-parser init

usage

Usage of command line interface is easy and fast, react-native-style-parser convert class selectors from css files.

single file

Transform a single file with command line interface from relative path of css file.

> npm run build-style -- ./css/foobar.css to ./react-styles/

If not exists ./react-styles/foobar.js is auto append.

After below parse javascript object styles at: ./react-styles/foobar.js

directory

Can transform all css files from a folder with command line interface

> npm run build-style -- ./css/ to ./react-styles/

options

Can add behavior with options use --option-name

watch

Option watch allow auto parse after listen change inside a target file.

> npm run build-style -- ./css/ to ./react-styles/ --watch

es6

Option watch generate export with ES6 syntaxe.

Default behavior generate a export with nodejs syntaxe

> npm run build-style -- ./css/ to ./react-styles/ --es6

no-quote

Option no-quote generate property name with no quote. Default behavior generaye single quote.

> npm run build-style -- ./css/ to ./react-styles/ --no-quote

optimize

Option optimize generate a minimified styles for optimization run time, use before switch prod env.

> npm run build-style -- ./css/ to ./react-styles/ --optimize

annotations

Add behavior from pretty annotations

ignore

Skip specific css block


.container {

  flex: 1;
  margin: 3px 5px;
  z-index: 3;
}

.item {

  transform: rotate( 8deg ), translateX( -10px );
}

.container-web-view {
  /**
  * @CssParser/Ignore()
  */
  width: 65%;
  margin: auto;
}
export default {

  "container": {
    flex: 1,
    marginTop: 3,
    marginBottom: 3,
    marginLeft: 5,
    marginRight: 5,
    zIndex: 3
  },

  "item": {
    transform: [
      {
        rotate: "8deg"
      }, {
        translateX: -10
      }
    ]
  }
}

compose

Annotations compose is a approach of react-native compose


.text {

  color: rgb( 42,42,42 );
}

.title {
  font-size: 25px;
  letter-spacing: 9px;
}

.super-text {
  /**
  * @CssParser/Compose( "text", "title" )
  */

  cursor: pointer;
}

export default {
  "text": {
    color: "rgb( 42,42,42 )"
  },

  "title": {
    fontSize: 25,
    letterSpacing: 9
  },

  "super-text": {
    color: "rgb( 42,42,42 )",
    fontSize: 25,
    letterSpacing: 9,
    cursor: pointer
  }
}

other

For not use double dash option (--) , prepare command from package.json

"script": {
  "build-style": "react-native-style-parser ./css to ./react-styles/ --es6 --no-quote --watch",
  "build-style-prod": "react-native-style-parser ./css to ./react-styles/ --es6 --no-quote --optimize"
}

Please if you detect undetermined behavior open a issue