# patternplate-transform-cssmodules

> patternplate transform creating css modules

Latest version **0.1.1** (published 2016-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install patternplate-transform-cssmodules
pnpm add patternplate-transform-cssmodules
yarn add patternplate-transform-cssmodules
bun add patternplate-transform-cssmodules
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2016-03-13 |
| First published | 2016-03-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Nerdlabs |
| Maintainers | marionebl, nerdlabs |
| Keywords | cssmodules, patternplate, transform, pattern |

## Links

- npm: https://www.npmjs.com/package/patternplate-transform-cssmodules
- Repository: https://github.com/nerdlabs/patternplate-transform-cssmodules
- Homepage: https://github.com/nerdlabs/patternplate-transform-cssmodules#readme
- Issues: https://github.com/nerdlabs/patternplate-transform-cssmodules/issues
- npm.io page: https://npm.io/package/patternplate-transform-cssmodules

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) 4.5.1
- [postcss-modules](https://npm.io/package/postcss-modules.md) 0.4.0
- [css-modules-loader-core](https://npm.io/package/css-modules-loader-core.md) 1.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2016-03-13
- 0.1.0 — 2016-03-13

## README

# patternplate-transform-cssmodules

[patternplate](/sinnerschrader/patternplate)
transform to enable usage of
[css modules](https://github.com/css-modules/css-modules).

:warning: **This transform is intended to be used in conjunction with
 [patternplate-transform-cssmodules-symbols](https://github.com/nerdlabs/patternplate-transform-cssmodules-symbols)
 to produce markup using the transformed css source**

See the [Configuration](#configuration) section for details.

## Installation

```shell
npm install --save patternplate-transform-cssmodules patternplate-transform-cssmodules-symbols
```

## Configuration

```javascript
// file: configuration/patternplate-server/patterns.js
module.exports = {
  formats: {
    css: {
      name: 'Style',
      transforms: ['cssmodules']
    },
    jsx: {
      name: 'Markup',
      transforms: ['cssmodules-symbols', 'react', 'react-to-markup']
    }
  }
};
```

```javascript
// file: configuration/patternplate-server/transforms.js
module.exports = {
  'cssmodules-symbols': {
    inFormat: 'jsx',
    outFormat: 'jsx'
  },
  cssmodules: {
    inFormat: 'css',
    outFormat: 'css'
  }
};
```

## Usage

### Sources

```javascript
// atoms/button/index.jsx
import styles from 'style://Pattern';
import cx from 'classnames';

const className = cx(styles.default, {
  [styles.disabled]: this.props.disabled
});

<button className={className}>
  {this.props.children}
</button>
```

```css
/* atoms/button/index.css */
.default {
  padding: 5px 10px;
  background: blue;
  color: white;
}
.disabled {
  background: grey;
}
```

### Transformed

```javascript
// <Button>Lorem Ipsum dolor si amnet</Button>
<button class="_button_4erg9ut2">
  Lorem Ipsum dolor si amnet
</button>

// <Button>Lorem Ipsum dolor si amnet</Button>
<button class="_button_4erg9ut2 _button_iert9832">
  Lorem Ipsum dolor si amnet
</button>
```

```css
/* atoms/button/index.css */
._button_4erg9ut2 {
  padding: 5px 10px;
  background: blue;
  color: white;
}
._button_iert9832 {
  background: grey;
}
```

---
_Source: https://npm.io/package/patternplate-transform-cssmodules · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
