Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit 498b63a

Browse files
committed
Update documentation
1 parent 41366b2 commit 498b63a

File tree

1 file changed

+82
-10
lines changed

1 file changed

+82
-10
lines changed

README.md

Lines changed: 82 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,62 @@
99
[PostCSS Logical Properties] lets you use Logical Properties and Values in
1010
CSS, following the [CSS Logical Properties and Values] specification.
1111

12-
```css
12+
```pcss
1313
.banner {
1414
color: #222222;
1515
inset: logical 0 5px 10px;
1616
padding-inline: 20px 40px;
1717
resize: block;
18+
transition: color 200ms;
1819
}
1920
20-
/* used alongside postcss-nesting, postcss-dir-pseudo-class */
21+
/* becomes */
2122
2223
.banner {
2324
color: #222222;
2425
top: 0; left: 5px; bottom: 10px; right: 5px;
25-
}
2626
27-
[dir="ltr"] .banner {
28-
padding-left: 20px; padding-right: 40px;
29-
}
27+
&:dir(ltr) {
28+
padding-left: 20px; padding-right: 40px;
29+
}
30+
31+
&:dir(rtl) {
32+
padding-right: 20px; padding-left: 40px;
33+
}
3034
31-
[dir="rtl"] .banner {
32-
padding-right: 20px; padding-left: 40px;
35+
resize: vertical;
36+
transition: color 200ms;
3337
}
3438
39+
/* or, when used with { dir: 'ltr' } */
40+
3541
.banner {
42+
color: #222222;
43+
top: 0; left: 5px; bottom: 10px; right: 5px;
44+
padding-left: 20px; padding-right: 40px;
3645
resize: vertical;
46+
transition: color 200ms;
3747
}
3848
39-
/* used with { dir: 'ltr' } option */
49+
/* or, when used with { preserve: true } */
4050
4151
.banner {
4252
color: #222222;
4353
top: 0; left: 5px; bottom: 10px; right: 5px;
44-
padding-left: 20px; padding-right: 40px;
54+
55+
&:dir(ltr) {
56+
padding-left: 20px; padding-right: 40px;
57+
}
58+
59+
&:dir(rtl) {
60+
padding-right: 20px; padding-left: 40px;
61+
}
62+
63+
inset: logical 0 5px 10px;
64+
padding-inline: 20px 40px;
65+
resize: block;
4566
resize: vertical;
67+
transition: color 200ms;
4668
}
4769
```
4870

@@ -146,6 +168,38 @@ postcss([
146168
]).process(YOUR_CSS);
147169
```
148170

171+
#### Webpack
172+
173+
Add [PostCSS Loader] to your build tool:
174+
175+
```bash
176+
npm install postcss-loader --save-dev
177+
```
178+
179+
Use [PostCSS Logical Properties] in your Webpack.config.js:
180+
181+
```js
182+
import ${idCamelCase} from '${id}';
183+
184+
module.exports = {
185+
module: {
186+
rules: [
187+
{
188+
test: /\.css$/,
189+
use: [
190+
'style-loader',
191+
{ loader: 'css-loader', options: { importLoaders: 1 } },
192+
{ loader: 'postcss-loader', options: {
193+
ident: 'postcss',
194+
plugins: () => [ ${idCamelCase}() ]
195+
} }
196+
]
197+
}
198+
]
199+
}
200+
}
201+
```
202+
149203
#### Gulp
150204

151205
Add [Gulp PostCSS] to your build tool:
@@ -197,6 +251,23 @@ grunt.initConfig({
197251
});
198252
```
199253

254+
## Options
255+
256+
### dir
257+
258+
The `dir` option determines how directional fallbacks should be added to CSS.
259+
By default, fallbacks replace the logical declaration with nested `:dir`
260+
pseudo-classes. If `dir` is defined as `ltr` or `rtl` then only the left or
261+
right directional fallbacks will replace the logical declarations. If
262+
`preserve` is defined as `true`, then the `dir` option will be ignored.
263+
264+
### preserve
265+
266+
The `preserve` option determines whether directional fallbacks should be added
267+
before logical declarations without replacing them. By default, directional
268+
fallbacks replace logical declaration. If `preserve` is defined as `true`, then
269+
the `dir` option will be ignored.
270+
200271
[cli-url]: https://travis-ci.org/jonathantneal/postcss-logical-properties
201272
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-logical-properties.svg
202273
[css-img]: https://jonathantneal.github.io/css-db/badge/css-logical.svg
@@ -212,4 +283,5 @@ grunt.initConfig({
212283
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
213284
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
214285
[PostCSS]: https://github.com/postcss/postcss
286+
[PostCSS Loader]: https://github.com/postcss/postcss-loader
215287
[PostCSS Logical Properties]: https://github.com/jonathantneal/postcss-logical-properties

0 commit comments

Comments
 (0)