Skip to content

Commit 48fd9bd

Browse files
committed
add a multiple namespaces example to the README
1 parent ac4ff19 commit 48fd9bd

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

+45
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,51 @@ h1 {
6565
}
6666
```
6767

68+
## Multiple Namespaces
69+
70+
This plugin also supports using multiple namespaces.
71+
72+
```javascript
73+
var postcss = require('postcss')
74+
var selectorNamespace = require('postcss-selector-namespace')
75+
76+
var output = postcss()
77+
.use(selectorNamespace({ selfSelector: ':--component', namespace: '.foo, .bar' }))
78+
.process(require('fs').readFileSync('input.css', 'utf8'))
79+
.css
80+
```
81+
82+
`input.css`
83+
```css
84+
:--component {
85+
color: black;
86+
}
87+
88+
:--component.danger {
89+
color: red;
90+
}
91+
92+
h1, .h1 {
93+
font-weight: bold;
94+
}
95+
```
96+
97+
will output the following css:
98+
99+
```css
100+
.foo, .bar {
101+
color: black;
102+
}
103+
104+
.foo.danger, .bar.danger {
105+
color: red;
106+
}
107+
108+
.foo h1, .bar .h1 {
109+
font-weight: bold;
110+
}
111+
```
112+
68113
## SCSS support
69114

70115
This plugin can also process scss files and output scss again using the

0 commit comments

Comments
 (0)