├── .eslintrc ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── examples ├── .babelrc ├── .eslintrc ├── .gitignore ├── README.md ├── index.html ├── package.json ├── server.js └── src │ ├── App.js │ └── index.js ├── lib ├── StylesRendererProvider.js ├── VStyleDOMComponent.js ├── index.js ├── stylesRendererShape.js └── withRenderStyles.js └── package.json /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "airbnb-base/legacy", 3 | "rules": { 4 | "no-underscore-dangle": 0, 5 | "no-trailing-spaces": 0, 6 | "no-param-reassign": 0, 7 | "func-names": 0, 8 | "vars-on-top": 0 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | bundle.js 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.tabSize": 2, 3 | "editor.detectIndentation": false, 4 | "eslint.enable": true 5 | } 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-vstyle 2 | 3 | > React bindings for [VStyle](https://github.com/fdecampredon/vstyle) 4 | 5 | 6 | ## Install 7 | You can install react-vstyle through npm: 8 | ``` 9 | npm install react-vstyle 10 | ``` 11 | 12 | ## Usage 13 | 14 | ### StylesRendererProvider 15 | 16 | react-vstyle let you inject a VStyle `StylesRenderer` in the react context with the `StylesRendererProvider` component: 17 | 18 | ```javascript 19 | import React from 'react'; 20 | import ReactDOM from 'react-dom'; 21 | import { createStylesRenderer } from 'vstyle'; 22 | import { StylesRendererProvider } from 'react-vstyle'; 23 | import MyComponent from './myComponent'; 24 | 25 | const stylesRenderer = createStylesRenderer(); 26 | stylesRenderer.attach(document.getElementById('style')); 27 | 28 | ReactDOM.render( 29 | 30 | 31 | , 32 | document.getElementById('root') 33 | ); 34 | ``` 35 | 36 | once you have injected your `StylesRenderer` into the context you can consume your styles in 2 ways : 37 | 38 | ## withRenderStyles 39 | 40 | `withRenderStyles` is an higher order component that will inject the `renderStyles` 41 | function of the `StylesRenderer` to the props of the wrapped component: 42 | 43 | ```javascript 44 | import React from 'react'; 45 | import { StyleSheet } from 'vstyle'; 46 | import { withRenderStyles } from 'react-vstyle'; 47 | 48 | const styles = StyleSheet.create({ 49 | button: { 50 | color: 'blue', 51 | }, 52 | }); 53 | 54 | function MyComponent({ renderStyles, styles: otherStyles }) { 55 | return