Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pjjanak/react-native-nested-stylesheets

Extends React Native's StyleSheet Object to allow for nesting of styles
https://github.com/pjjanak/react-native-nested-stylesheets

Last synced: about 1 month ago
JSON representation

Extends React Native's StyleSheet Object to allow for nesting of styles

Awesome Lists containing this project

README

        

# react-native-nested-stylesheet

Nestable stylesheets for react-native.

## Installation
`npm install react-native-nested-stylesheet`

## Usage notes
This plugin will allow you to create styles of the following format:

```
...
namespace: {
styleA: {...},
styleB: {...},
},
...
```

With the plain `StyleSheet` API you can only create stylesheets with one level. It should noted that `NestedStyleSheet` does not create cascading selectors. This is merely to allow namespacing of styles (e.g. containing the styles for all items in a specific `ListView`).

Note: You are only allowed to include other objects within a nested style. You cannot define rules at the namespace level.

## Usage Example
```
var React = require('react-native');
var NestedStyleSheet = require('react-native-nested-stylesheet');

var {
View,
Text,
Image,
} = React;

var styles = NestedStyleSheet.create({
cells: {
container: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
},
thumbnail: {
width: 53,
height: 81,
},
content: {
flex: 1,
},
},
});

var Demo = React.createClass({
render: function() {
return (


...


);
},
});

module.exports = Demo;
```