You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-12Lines changed: 48 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
# PostCSS RTLCSS
2
2
3
-
[PostCSS] plugin to build Cascading Style Sheets (CSS) with Left-To-Right (LTR) and Right-To-Left (RTL) rules using [RTLCSS]
3
+
[PostCSS] plugin to build Cascading Style Sheets (CSS) with Left-To-Right (LTR) and Right-To-Left (RTL) rules using [RTLCSS]. RTLCSS allows one to flip an entire CSS file with the intention of using the original CSS for one direction and the new generated one for the other. What PostcCSS RTLCSS does, is to create a single CSS file with both directions or to create a minimal CSS file only with the flipped rules with the intention of overriding the main one.
This is the recommended method, it will generate more CSS code but each direction will have their specific CSS declarations and there is not need to override properties.
134
+
This is the recommended method, it will generate more CSS code but each direction will have their specific CSS declarations and there is no need of overriding properties.
135
135
136
136
```css
137
137
.test1, .test2 {
@@ -172,7 +172,7 @@ This is the recommended method, it will generate more CSS code but each directio
172
172
173
173
#### Output using the override mode
174
174
175
-
This is the alternative method, it will generate less code because it lets the main rule intact and generates a shorter specific rule to override the properties that are affected by the direction of the text.
175
+
This is one of the alternative methods to override. It will generate less code because it lets the main rule intact and generates a shorter specific rule to override the properties that are affected by the direction of the text.
176
176
177
177
```css
178
178
.test1, .test2 {
@@ -206,12 +206,30 @@ This is the alternative method, it will generate less code because it lets the m
206
206
}
207
207
```
208
208
209
-
But this method has a disadvantage:
209
+
#### Output using the diff mode
210
210
211
-
<details><summary>Disadvantage of the override method</summary>
211
+
This is the second alternative method to override. It generates the minimum amount of code because it only outputs the rules that have been flipped and without prefixing them. The intention of this method is to generate a separate stylesheet file that will be loaded on top of the original one to override those rules that need to be flipped in certain direction.
212
+
213
+
```css
214
+
.test1, .test2 {
215
+
border-radius: 2px08px0;
216
+
padding-right: 0;
217
+
padding-left: 20px;
218
+
text-align: right;
219
+
transform: translate(50%, 50%);
220
+
}
221
+
222
+
.test3 {
223
+
direction: rtl;
224
+
}
225
+
```
226
+
227
+
But the two methods to override have a disadvantage:
228
+
229
+
<details><summary>Disadvantage of the methods to override</summary>
212
230
<p>
213
231
214
-
Use this method carefully. It can override a property that is coming from another class if multiple classes are used at the same time. Take a look at the next `HTML` and `CSS` codes:
232
+
Use these methods carefully. They can override a property that is coming from another class if multiple classes are used at the same time. Take a look at the next `HTML` and `CSS` codes:
215
233
216
234
```html
217
235
<divclass="test1 test2">
@@ -231,7 +249,7 @@ Use this method carefully. It can override a property that is coming from anothe
231
249
}
232
250
```
233
251
234
-
Using the combined method, the generated code will be the next one:
252
+
Using the `combined` method, the generated code will be the next one:
235
253
236
254
```css
237
255
.test1 {
@@ -249,9 +267,9 @@ Using the combined method, the generated code will be the next one:
249
267
}
250
268
```
251
269
252
-
So, the `div` will have a padding of `20px 10px 20px 20px` in `LTR` and `20px 20px 20px 10px` in `RTL`.
270
+
So, the `div` will have a padding of `20px 10px 20px 20px` in `LTR` and `20px 20px 20px 10px` in `RTL`. Everything will work as expected here.
253
271
254
-
However, using the override method the generated code will be the next one:
272
+
However, using the `override` method the generated code will be the next one:
255
273
256
274
```css
257
275
.test1 {
@@ -270,7 +288,16 @@ However, using the override method the generated code will be the next one:
270
288
}
271
289
```
272
290
273
-
Now the `div` has a padding of `20px 10px 20px 20px` in `LTR` and `20px 0 20px 10px` in `RTL`, because the override of the class `test2` doesn't take into account that this class could be used with `test1` having the same properties. The solution, in this case, is to provide the property that has been inherited:
291
+
And using the `diff` method the generated code will be the next one:
292
+
293
+
```css
294
+
.test2 {
295
+
padding-right: 0;
296
+
padding-left: 10px;
297
+
}
298
+
```
299
+
300
+
Now the `div` has a padding of `20px 10px 20px 20px` in `LTR` and `20px 0 20px 10px` in `RTL`, because when the class `test2` is overriden, it is not taken into account that it could be used with `test1` having the same properties. The solution, in this case, is to provide the property that has been inherited:
274
301
275
302
```css
276
303
.test1 {
@@ -285,7 +312,7 @@ Now the `div` has a padding of `20px 10px 20px 20px` in `LTR` and `20px 0 20px 1
285
312
}
286
313
```
287
314
288
-
So, the generated code will be:
315
+
So, using the `override` method the generated code will be:
289
316
290
317
```css
291
318
.test1 {
@@ -305,6 +332,15 @@ So, the generated code will be:
305
332
}
306
333
```
307
334
335
+
And using the `diff` method the generated code will be:
0 commit comments