66[ ![ Windows Build Status] [ win-img ]] [ win-url ]
77[ ![ Support Chat] [ git-img ]] [ git-url ]
88
9- [ PostCSS Dir Pseudo Class] lets you use the ` :dir() ` pseudo-class to style by
10- directionality in CSS, following the [ Selectors Level 4 ] specification.
9+ [ PostCSS Dir Pseudo Class] lets you style by directionality using the ` :dir() `
10+ pseudo-class in CSS, following the [ Selectors] specification.
1111
12- ``` css
12+ ``` pcss
1313article h3:dir(rtl) {
1414 margin-right: 10px;
1515}
@@ -29,7 +29,7 @@ article h3:dir(ltr) {
2929}
3030```
3131
32- ### Maintain Specificity
32+ ### Maintaining Specificity
3333
3434Using [ PostCSS Dir Pseudo Class] will not impact selector weight, but it will
3535require having at least one ` [dir] ` attribute in your HTML. If you don’t have
@@ -60,7 +60,7 @@ Use [PostCSS Dir Pseudo Class] to process your CSS:
6060``` js
6161import postcssDirPseudoClass from ' postcss-dir-pseudo-class' ;
6262
63- postcssDirPseudoClass .process (YOUR_CSS );
63+ postcssDirPseudoClass .process (YOUR_CSS , /* processOptions */ , /* pluginOptions */ );
6464```
6565
6666#### PostCSS
@@ -78,7 +78,7 @@ import postcss from 'gulp-postcss';
7878import postcssDirPseudoClass from ' postcss-dir-pseudo-class' ;
7979
8080postcss ([
81- postcssDirPseudoClass ()
81+ postcssDirPseudoClass (/* pluginOptions */ )
8282]).process (YOUR_CSS );
8383```
8484
@@ -106,7 +106,7 @@ module.exports = {
106106 { loader: ' postcss-loader' , options: {
107107 ident: ' postcss' ,
108108 plugins : () => [
109- postcssDirPseudoClass (/* options */ )
109+ postcssDirPseudoClass (/* pluginOptions */ )
110110 ]
111111 } }
112112 ]
@@ -132,7 +132,7 @@ import postcssDirPseudoClass from 'postcss-dir-pseudo-class';
132132
133133gulp .task (' css' , () => gulp .src (' ./src/*.css' ).pipe (
134134 postcss ([
135- postcssDirPseudoClass (/* options */ )
135+ postcssDirPseudoClass (/* pluginOptions */ )
136136 ])
137137).pipe (
138138 gulp .dest (' .' )
@@ -158,7 +158,7 @@ grunt.initConfig({
158158 postcss: {
159159 options: {
160160 use: [
161- postcssDirPseudoClass (/* options */ )
161+ postcssDirPseudoClass (/* pluginOptions */ )
162162 ]
163163 },
164164 dist: {
@@ -180,12 +180,10 @@ Here’s an example of using the `dir` option to presume a left-to-right
180180direction:
181181
182182``` js
183- require (' postcss-dir-pseudo-class' )({
184- dir: ' ltr'
185- });
183+ postcssDirPseudoClass ({ dir: ' ltr' });
186184```
187185
188- ``` css
186+ ``` pcss
189187.example:dir(ltr) {
190188 margin-left: 10px;
191189}
@@ -208,22 +206,54 @@ html:not([dir="rtl"]) .example {
208206### preserve
209207
210208The ` preserve ` option determines whether the original ` :dir() ` rule should
211- remain in the CSS. By default, the rule is replaced by the fallback.
209+ remain in the CSS. By default, the original rule is not preserved.
210+
211+ ``` js
212+ postcssDirPseudoClass ({ preserve: true });
213+ ```
214+
215+ ``` pcss
216+ article h3:dir(rtl) {
217+ margin-right: 10px;
218+ }
219+
220+ article h3:dir(ltr) {
221+ margin-left: 10px;
222+ }
223+
224+ /* becomes */
225+
226+ [dir="rtl"] article h3 {
227+ margin-right: 10px;
228+ }
229+
230+ article h3:dir(rtl) {
231+ margin-right: 10px;
232+ }
233+
234+ [dir="ltr"] article h3 {
235+ margin-left: 10px;
236+ }
237+
238+ article h3:dir(ltr) {
239+ margin-left: 10px;
240+ }
241+ ```
212242
213- [ cli-url ] : https://travis-ci.org/jonathantneal/postcss-dir-pseudo-class
214243[ cli-img ] : https://img.shields.io/travis/jonathantneal/postcss-dir-pseudo-class.svg
244+ [ cli-url ] : https://travis-ci.org/jonathantneal/postcss-dir-pseudo-class
215245[ css-img ] : https://jonathantneal.github.io/cssdb/badge/dir-pseudo-class.svg
216246[ css-url ] : https://jonathantneal.github.io/cssdb/#dir-pseudo-class
217- [ git-url ] : https://gitter.im/postcss/postcss
218247[ git-img ] : https://img.shields.io/badge/support-chat-blue.svg
219- [ npm -url] : https://www.npmjs.com/package /postcss-dir-pseudo-class
248+ [ git -url] : https://gitter.im/postcss /postcss
220249[ npm-img ] : https://img.shields.io/npm/v/postcss-dir-pseudo-class.svg
221- [ win -url] : https://ci.appveyor .com/project/jonathantneal /postcss-dir-pseudo-class
250+ [ npm -url] : https://www.npmjs .com/package /postcss-dir-pseudo-class
222251[ win-img ] : https://img.shields.io/appveyor/ci/jonathantneal/postcss-dir-pseudo-class.svg
252+ [ win-url ] : https://ci.appveyor.com/project/jonathantneal/postcss-dir-pseudo-class
223253
224254[ Gulp PostCSS ] : https://github.com/postcss/gulp-postcss
225255[ Grunt PostCSS ] : https://github.com/nDmitry/grunt-postcss
226256[ PostCSS ] : https://github.com/postcss/postcss
227- [ PostCSS Dir Pseudo Class ] : https://github.com/jonathantneal/postcss-dir-pseudo-class
228257[ PostCSS Loader ] : https://github.com/postcss/postcss-loader
229- [ Selectors Level 4 ] : https://www.w3.org/TR/selectors-4/
258+ [ PostCSS Dir Pseudo Class ] : https://github.com/jonathantneal/postcss-dir-pseudo-class
259+ [ Selectors ] : https://www.w3.org/TR/selectors-4/#the-dir-pseudo
0 commit comments