Skip to content

Commit 80c4e01

Browse files
committed
Merge pull request #1 from marionebl/docs/expand-usage-documentation
docs(system): add usage documentation
2 parents efb65b8 + 9b0469b commit 80c4e01

File tree

2 files changed

+81
-6
lines changed

2 files changed

+81
-6
lines changed

license.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 SinnerSchrader Deutschland GmbH and [contributors](./graphs/contributors)
3+
Copyright (c) 2016 nerdLabs and [contributors](./graphs/contributors)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -19,6 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-
23-
---
24-
Copyright 2016 by [SinnerSchrader Deutschland GmbH](https://github.com/sinnerschrader) and [contributors](./graphs/contributors). Released under the [MIT license]('./license.md').

readme.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,105 @@
11
# patternplate-transform-cssmodules
2-
[patternplate](/sinnerschrader/patternplate) transform to enable usage of [css modules](/css-modules/css-modules).
2+
3+
[patternplate](/sinnerschrader/patternplate)
4+
transform to enable usage of
5+
[css modules](https://github.com/css-modules/css-modules).
6+
7+
:warning: **This transform is intended to be used in conjunction with
8+
[patternplate-transform-cssmodules-symbols](https://github.com/nerdlabs/patternplate-transform-cssmodules-symbols)
9+
to produce markup using the transformed css source**
10+
11+
See the [Configuration](#configuration) section for details.
312

413
## Installation
14+
515
```shell
6-
npm install --save patternplate-transform-cssmodules
16+
npm install --save patternplate-transform-cssmodules patternplate-transform-cssmodules-symbols
717
```
18+
819
## Configuration
20+
921
```javascript
1022
// file: configuration/patternplate-server/patterns.js
1123
module.exports = {
1224
formats: {
1325
css: {
1426
name: 'Style',
1527
transforms: ['cssmodules']
28+
},
29+
jsx: {
30+
name: 'Markup',
31+
transforms: ['cssmodules-symbols', 'react', 'react-to-markup']
1632
}
1733
}
1834
};
35+
```
1936

37+
```javascript
2038
// file: configuration/patternplate-server/transforms.js
2139
module.exports = {
40+
'cssmodules-symbols': {
41+
inFormat: 'jsx',
42+
outFormat: 'jsx'
43+
},
2244
cssmodules: {
2345
inFormat: 'css',
2446
outFormat: 'css'
2547
}
2648
};
2749
```
50+
51+
## Usage
52+
53+
### Sources
54+
55+
```javascript
56+
// atoms/button/index.jsx
57+
import styles from 'style://Pattern';
58+
import cx from 'classnames';
59+
60+
const className = cx(styles.default, {
61+
[styles.disabled]: this.props.disabled
62+
});
63+
64+
<button className={className}>
65+
{this.props.children}
66+
</button>
67+
```
68+
69+
```css
70+
/* atoms/button/index.css */
71+
.default {
72+
padding: 5px 10px;
73+
background: blue;
74+
color: white;
75+
}
76+
.disabled {
77+
background: grey;
78+
}
79+
```
80+
81+
### Transformed
82+
83+
```javascript
84+
// <Button>Lorem Ipsum dolor si amnet</Button>
85+
<button class="_button_4erg9ut2">
86+
Lorem Ipsum dolor si amnet
87+
</button>
88+
89+
// <Button>Lorem Ipsum dolor si amnet</Button>
90+
<button class="_button_4erg9ut2 _button_iert9832">
91+
Lorem Ipsum dolor si amnet
92+
</button>
93+
```
94+
95+
```css
96+
/* atoms/button/index.css */
97+
._button_4erg9ut2 {
98+
padding: 5px 10px;
99+
background: blue;
100+
color: white;
101+
}
102+
._button_iert9832 {
103+
background: grey;
104+
}
105+
```

0 commit comments

Comments
 (0)