New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-styles-parser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-styles-parser

Parser for writing pretty styles in React Styles

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

React Styles Parser

The purpose of this package is to allow developers/designers to write styles for React Styles using syntax that they are familiar with. Using this parser, we can let anyone write styles as if they were writing scss.

For example:

// Style Examples
// You can even use variables in the template string.
// Just define/import the variables above and use them
// like background: ${backgroundColor} in the string.

module.exports = `
h1 {
    background: blue;

    minWidth {
        320 {
            background: lightblue
        }
    }
}

button {
    background: blue;
    border-radius: 15px;
    padding: 25px;

    .open {
        background: darkblue;

        minWidth {
            640 {
                margin: 15px;
            }
        }

        maxWidth {
            480 {
                margin: 30px;
            }
        }
    }
}`;

Here's how we would use these styles in a build step:

'use strict';

import Parser from './parser';
import styles from './styles';

Parser(styles);

// Output:
{
    h1: {
        'background': 'blue',
        'minWidth': { '320': { 'background': 'lightblue' } }
    },
    button: {
        'background': 'blue',
        'border-radius': '15px',
        'padding': '25px',
        '.open': {
            'background': 'darkblue',
            'minWidth': { '640': { 'margin': '15px' } },
            'maxWidth': { '480': { 'margin': '30px' } }
        }
    }
}

This output then can be passed through any transformations that you want, such as an autoprefixer step. Eventually these styles will be passed into React Components and will be used with React Styles and React Styles helpers.

FAQs

Package last updated on 02 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts