1.0.12 • Published 6 years ago

react-stylepack v1.0.12

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

npm.io

Installation

npm install react-stylepack

Usage

Step 1 ) Pack your styles:

Button.css

.button {
  padding: 8px 16px;

  cursor: pointer;

  color: white;
  border: none;
}

.button--disabled {
  cursor: not-allowed;

  background-color: '#e3e3e3';
}

Button.js

import stylepack from '../../../lib/index.js'
import classes from './Button.css'

const colors = {
  primary: '#EA7B4C',
  success: '#38B570',
  danger: '#EA4C4C'
}

const stylesheets = stylepack()
  /* - CSS Modules - */
  .use(classes)
  /* - Inline Style - */
  .use({
    button: {
      backgroundColor: props => props.disabled || colors[props.type] || colors.primary
    }
  })

Step 2 ) Select your style from stylesheets created by stylepack:

const styled = stylesheets.select('button button--disabled~[disabled]')

Step 3 ) Create styled component:

const Button = styled.button

Step 4 ) Finally, use your styled component like this:

<Button type="primary" />
<Button type="success" />
<Button type="danger" />
<Button disabled />
1.0.12

6 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago