@@ -81,14 +81,41 @@ export default class MyComponent extends React.Component {
81
81
}
82
82
```
83
83
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
+
84
105
Ignores:
85
106
- filenames that starts from not capital letter
86
107
- modifiers (classes that starts from hyphen)
87
108
- classes that starts from capital letter
88
109
89
110
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
92
119
93
120
## Installation
94
121
0 commit comments