Skip to content

Commit 4b964d1

Browse files
authored
[readme] update features and caveats
1 parent 72e926c commit 4b964d1

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

README.md

+29-2
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,41 @@ export default class MyComponent extends React.Component {
8181
}
8282
```
8383

84+
Features:
85+
- lower-case classes are prefixed with the `ComponentName`:
86+
- `title` --> `ComponentName-title`
87+
- `content` --> `ComponentName-content`
88+
- `leftListItem` --> `ComponentName-leftListItem`
89+
- `root` is a treated as a special class name and will be replaces with the `ComponentName`:
90+
- `root` --> `ComponentName`
91+
- supports `className`s which have the value of either a string or a `{}` binding:
92+
```jsx
93+
className='title'
94+
className={`title ${this.props.className}`}
95+
className={"title " + this.props.className}
96+
```
97+
- within `{}` binding it also does the replacement if the `classnames` function is called (as `classnames` or as `c`):
98+
```jsx
99+
className={c('title', {'-active': true})}
100+
className={classnames(`title ${this.props.className}`, {
101+
'-active': true
102+
}}
103+
```
104+
84105
Ignores:
85106
- filenames that starts from not capital letter
86107
- modifiers (classes that starts from hyphen)
87108
- classes that starts from capital letter
88109
89110
Caveats:
90-
- searches for 'export default ComponentName' construction to find component name
91-
- prefixes only className fields that are set as string
111+
- the class name to replace be the very first class name within the `className` attribute.
112+
113+
For example, in `className='Form item'` the `item` won't get prefixed:
114+
- `className='Form item'` --> `className='Form item'`
115+
116+
If you want it to be prefixed, just place it first:
117+
- `className='item Form'` --> `className='MyComponent-item Form'`
118+
- searches for `export default ComponentName` or `export default class ComponentName` construction to find component name
92119
93120
## Installation
94121

0 commit comments

Comments
 (0)