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
+161-7Lines changed: 161 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,7 +144,7 @@ Examples
144
144
}
145
145
```
146
146
147
-
#### Output using the combined mode (default)
147
+
#### Output using the combined mode (default and recommended)
148
148
149
149
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.
150
150
@@ -187,6 +187,9 @@ This is the recommended method, it will generate more CSS code but each directio
187
187
188
188
#### Output using the override mode
189
189
190
+
>[!IMPORTANT]
191
+
>This method is not recommended, check below why
192
+
190
193
This is one of the alternative methods to override. It will generate less code because it lets the main rule intact most of the time and generates shorter specific rules to override the properties that are affected by the direction of the text.
191
194
192
195
```css
@@ -223,6 +226,9 @@ This is one of the alternative methods to override. It will generate less code b
223
226
224
227
#### Output using the diff mode
225
228
229
+
>[!IMPORTANT]
230
+
>This method is not recommended, check below why
231
+
226
232
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.
227
233
228
234
```css
@@ -239,12 +245,16 @@ This is the second alternative method to override. It generates the minimum amou
239
245
}
240
246
```
241
247
242
-
But the two methods to override have a disadvantage:
248
+
>[!IMPORTANT]
249
+
>But the two methods to override have disadvantages:
243
250
244
-
<details><summary>Disadvantage of the override methods</summary>
251
+
<details><summary>Disadvantages of the override methods</summary>
245
252
<p>
246
253
247
-
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:
254
+
The methods to override are discouraged because:
255
+
256
+
1. Some directives as `/*rtl:freeze*/`, `/*rtl:begin:freeze*/` and `/*rtl:end:freeze*/` do not work with these methods
257
+
2. 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:
248
258
249
259
```html
250
260
<divclass="test1 test2">
@@ -312,7 +322,7 @@ And using the `diff` method the generated code will be the next one:
312
322
}
313
323
```
314
324
315
-
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:
325
+
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 workaround, in this case, is to provide the property that has been inherited:
316
326
317
327
```css
318
328
.test1 {
@@ -1516,9 +1526,12 @@ Control directives are placed between rules or declarations. They can target a s
1516
1526
|`/*rtl:ignore*/`| Ignores processing of the following rule or declaration |
1517
1527
|`/*rtl:begin:ignore*/`| Starts an ignoring block |
1518
1528
|`/*rtl:end:ignore*/`| Ends an ignoring block |
1529
+
|`/*rtl:freeze*/`| Freezes the rule or declaration in the current direction but does nothing with the counterpart direction if there are flippable declarations |
1530
+
|`/*rtl:begin:freeze*/`| Starts a freeze block |
1531
+
|`/*rtl:end:freeze*/`| Ends a freeze block |
1519
1532
|`/*rtl:urls*/`| This directive set the `processUrls` option to `true` in the next declaration or in the declarations of the next rule no mattering the value of the global `processUrls` option |
1520
-
|`/*rtl:begin:urls*/`| Starts a `processUrls` block block |
1521
-
|`/*rtl:end:urls*/`| Ends a `processUrls` block block |
1533
+
|`/*rtl:begin:urls*/`| Starts a `processUrls` block block |
1534
+
|`/*rtl:end:urls*/`| Ends a `processUrls` block block |
1522
1535
|`/*rtl:rules*/`| This directive set the `processRuleNames` option to `true` in the next rule no mattering the value of the global `processRuleNames` option |
1523
1536
|`/*rtl:begin:rules*/`| Starts a `processRuleNames` block block |
1524
1537
|`/*rtl:end:rules*/`| Ends a `processRuleNames` block block |
>1. This directive only works in `combined` mode. If you use it in `override` or `diff` mode it will be ignored.
1691
+
>2. If you use this directive with declarations that are not affected by page direction, it is recommended that you set the [safeBothPrefix](#safebothprefix) option in `true`.
1692
+
1693
+
This directive freezes the rule or declaration in the current direction but does nothing with the counterpart direction if there are flippable declarations. When used with a rule, it will freeze it in the current direction even if it is doesn't contain flippable declarations. When it is used in a declration, it will freeze the declaration in the current direction even if it is not flippable.
1694
+
1695
+
##### input
1696
+
1697
+
```css
1698
+
/*rtl:freeze*/
1699
+
.test1, .test2 {
1700
+
color: red;
1701
+
text-align: left;
1702
+
left: 10px;
1703
+
}
1704
+
1705
+
.test3 {
1706
+
/*rtl:freeze*/
1707
+
text-align: center;
1708
+
/*rtl:freeze*/
1709
+
padding: 10px20px30px40px;
1710
+
margin: 1px2px3px4px;
1711
+
}
1712
+
```
1713
+
1714
+
##### output
1715
+
1716
+
```css
1717
+
[dir="ltr"] .test1, [dir="ltr"] .test2 {
1718
+
color: red;
1719
+
text-align: left;
1720
+
left: 10px;
1721
+
}
1722
+
1723
+
[dir="ltr"] .test3 {
1724
+
text-align: center;
1725
+
padding: 10px40px30px20px;
1726
+
margin: 1px4px3px2px;
1727
+
}
1728
+
1729
+
[dir="rtl"] .test3 {
1730
+
margin: 1px4px3px2px;
1731
+
}
1732
+
```
1733
+
1734
+
</p>
1735
+
1736
+
</details>
1737
+
1738
+
---
1739
+
1740
+
#### `/*rtl:begin:freeze*/` and `/*rtl:end:freeze*/`
1741
+
1742
+
<details><summary>Expand</summary>
1743
+
<p>
1744
+
1745
+
>[!IMPORTANT]
1746
+
>1. This directive only works in `combined` mode. If you use it in `override` or `diff` mode it will be ignored.
1747
+
>2. If you use these directives with declarations that are not affected by page direction, it is recommended that you set the [safeBothPrefix](#safebothprefix) option in `true`.
1748
+
1749
+
These directives should be used together, they will provide the beginning and the end for freezing rules or declarations. The rules or delclarations between these blocks, will be frozen in the current direction even if there are no flippable declarations involved.
0 commit comments