Skip to content

Conversation

elchininet
Copy link
Owner

@elchininet elchininet commented Dec 13, 2024

This pull request implements new directives for freezing rules or delcrations.

Directive Description
/*rtl:freeze*/ Freezes the rule or declaration in the current direction
but does nothing with the counterpart direction
if there are flippable declarations
/*rtl:begin:freeze*/ Starts a freeze block
/*rtl:end:freeze*/ Ends a freeze block

/*rtl:freeze*/

Expand

[!IMPORTANT]
This directive only works in combined mode. If you use it in override or diff mode it will be ignored.

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.

input
/*rtl:freeze*/
.test1, .test2 {
    color: red;
    text-align: left;
    left: 10px;
}

.test3 {
    /*rtl:freeze*/
    text-align: center;
    /*rtl:freeze*/
    padding: 10px 20px 30px 40px;
    margin: 1px 2px 3px 4px;
}
output
[dir="ltr"] .test1, [dir="ltr"] .test2 {
    color: red;
    text-align: left;
    left: 10px;
}

[dir="ltr"] .test3 {
    text-align: center;
    padding: 10px 40px 30px 20px;
    margin: 1px 4px 3px 2px;
}

[dir="rtl"] .test3 {
    margin: 1px 4px 3px 2px;
}


/*rtl:begin:freeze*/ and /*rtl:end:freeze*/

Expand

[!IMPORTANT]
This directive only works in combined mode. If you use it in override or diff mode it will be ignored.

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.

Freezing multiple rules:

input
/*rtl:begin:freeze*/
.test1, .test2 {
    color: #FFF;
    left: 10px;
    text-align: left;
}

.test3 {
    padding: 1px 2px 3px 4px;
}
/*rtl:end:freeze*/
output
[dir="ltr"] .test1, [dir="ltr"] .test2 {
    color: #FFF;
    left: 10px;
    text-align: left;
}

[dir="ltr"] .test3 {
    padding: 1px 2px 3px 4px;
}

Freezing multiple declarations:

input
.test1, .test2 {
    color: red;
    left: 10px;
    /*rtl:begin:freeze*/
    margin-left: 4em;
    padding: 1px 2px 3px 4px;
    /*rtl:end:freeze*/
    text-align: left;
}
output
.test1, .test2 {
    color: red;
}

[dir="ltr"] .test1, [dir="ltr"] .test2 {
    left: 10px;
    margin-left: 4em;
    padding: 1px 2px 3px 4px;
    text-align: left;
}

[dir="rtl"] .test1, [dir="rtl"] .test2 {
    right: 10px;
    text-align: right;
}

@elchininet elchininet added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 13, 2024
@coveralls
Copy link

coveralls commented Dec 13, 2024

Coverage Status

coverage: 100.0%. remained the same
when pulling 0a8d8bb on implement_freeze_directive
into 34b6d93 on master.

@elchininet elchininet force-pushed the implement_freeze_directive branch from 6274d58 to 2521408 Compare December 13, 2024 01:37
@elchininet elchininet force-pushed the implement_freeze_directive branch from 0b5a7cd to 0a8d8bb Compare December 13, 2024 19:19
@elchininet elchininet merged commit 08ca0f5 into master Dec 13, 2024
2 checks passed
@elchininet elchininet deleted the implement_freeze_directive branch December 13, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants