Skip to content

Commit 0e73350

Browse files
committed
refactor: update reflect function
1 parent 1034910 commit 0e73350

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

scss/mixins/_ltr-rtl.scss

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
}
1616

1717
@function reflect($element) {
18-
@if type-of($element) == string {
19-
@if str-index($element, "left") {
20-
@return str-replace($element, "left", "right");
21-
}
22-
@if str-index($element, "right") {
23-
@return str-replace($element, "right", "left");
24-
}
18+
$string: #{$element};
19+
@if str-index($string, "left") {
20+
@return str-replace($string, "left", "right");
21+
}
22+
@if str-index($string, "right") {
23+
@return str-replace($string, "right", "left");
2524
}
2625

27-
@return $element;
26+
@return unquote($string);
2827
}
2928

3029
@mixin ltr-rtl($property, $value, $property-rtl: null, $value-rtl: null, $important: null) {
@@ -59,22 +58,29 @@
5958
}
6059
}
6160

62-
@mixin ltr-rtl-value-only($property, $value, $value-rtl, $important: null) {
61+
@mixin ltr-rtl-value-only($property, $value, $value-rtl: null, $important: null) {
6362
$value-reflected: reflect($value);
6463

6564
@if $enable-ltr and $enable-rtl {
6665
@include ltr() {
6766
#{$property}: $value $important;
6867
}
6968
@include rtl() {
70-
#{$property}: $value-rtl $important;
69+
@if $value-rtl {
70+
#{$property}: $value-rtl $important;
71+
} @else {
72+
#{$property}: $value-reflected $important;
73+
}
7174
}
7275
}
7376
@else {
7477
@if $enable-rtl {
75-
#{$property}: $value-rtl $important;
76-
}
77-
@else {
78+
@if $value-rtl {
79+
#{$property}: $value-rtl $important;
80+
} @else {
81+
#{$property}: $value-reflected $important;
82+
}
83+
} @else {
7884
#{$property}: $value $important;
7985
}
8086
}

0 commit comments

Comments
 (0)