0.1.13 • Published 6 years ago

@rubixibuc/with-styles v0.1.13

Weekly downloads
-
License
ISC
Repository
github
Last release
6 years ago

Build Status Coverage Status

with-styles

React style HOC. Supports both plain style objects and style objects computed from passed props.

Getting Started

Installing

npm i @rubixibuc/with-styles

Usage

without props

import React from 'react';
import withStyles from '@rubixibuc/with-styles';

const MyComponent = ({styles}) => <div style={styles.myDiv}/>;

export default withStyles({
  myDiv: {
    height: 500,
    width: 500
  }
})(MyComponent);

with props

import React from 'react';
import withStyles from '@rubixibuc/with-styles';

const MyComponent = ({styles}) => <div style={styles.myDiv}/>;

export default withStyles(({someProp}) => ({
  myDiv: {
    height: someProp.height,
    width: someProp.width
  }
}))(MyComponent);

with recompose

import React from 'react';
import withStyles from '@rubixibuc/with-styles';
import { compose } from 'recompose';

export const enhance = compose(
  withState('backgroundColor', 'updateBackgroundColor', '#fff'),
  withStyles(({backgroundColor}) => ({
    myDiv: {
      backgroundColor
    }
  }))
)
0.1.13

6 years ago

0.1.12

7 years ago

0.1.11

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago