0.1.13 • Published 5 years ago

@rubixibuc/with-styles v0.1.13

Weekly downloads
-
License
ISC
Repository
github
Last release
5 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

5 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago