Skip to content

Commit 84cc954

Browse files
committed
refactor: improve RTL direction handling
1 parent 684066a commit 84cc954

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

scss/_button-group.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// Prevent double borders when buttons are next to each other
4040
> :not(.btn-check:first-child) + .btn,
4141
> .btn-group:not(:first-child) {
42-
margin-left: calc(#{$btn-border-width} * -1); // stylelint-disable-line function-disallowed-list
42+
@include ltr-rtl("margin-left", calc(#{$btn-border-width} * -1));
4343
}
4444

4545
// Reset rounded corners
@@ -79,11 +79,11 @@
7979
&::after,
8080
.dropup &::after,
8181
.dropend &::after {
82-
margin-left: 0;
82+
@include ltr-rtl("margin-left", 0);
8383
}
8484

8585
.dropstart &::before {
86-
margin-right: 0;
86+
@include ltr-rtl("margin-right", 0);
8787
}
8888
}
8989

scss/_card.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
}
9696

9797
+ .card-link {
98-
margin-left: var(--#{$prefix}card-spacer-x);
98+
@include ltr-rtl("margin-left", var(--#{$prefix}card-spacer-x));
9999
}
100100
}
101101

@@ -198,8 +198,8 @@
198198
margin-bottom: 0;
199199

200200
+ .card {
201-
margin-left: 0;
202-
border-left: 0;
201+
@include ltr-rtl("margin-left", 0);
202+
@include ltr-rtl("border-left", 0);
203203
}
204204

205205
// Handle rounded corners

scss/_dropdown.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@
9393
--cui-position: start;
9494

9595
&[data-coreui-popper] {
96-
right: auto;
97-
left: 0;
96+
@include ltr-rtl("right", auto);
97+
@include ltr-rtl("left", 0);
9898
}
9999
}
100100

101101
.dropdown-menu#{$infix}-end {
102102
--cui-position: end;
103103

104104
&[data-coreui-popper] {
105-
right: 0;
106-
left: auto;
105+
@include ltr-rtl("right", 0);
106+
@include ltr-rtl("left", auto);
107107
}
108108
}
109109
}

scss/_nav.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
display: flex;
1818
flex-wrap: wrap;
19-
padding-left: 0;
19+
@include ltr-rtl("padding-left", 0);
2020
margin-bottom: 0;
2121
list-style: none;
2222
}

scss/_type.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
display: inline-block;
7070

7171
&:not(:last-child) {
72-
margin-right: $list-inline-padding;
72+
@include ltr-rtl("margin-right", $list-inline-padding);
7373
}
7474
}
7575

scss/forms/_floating-labels.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
> label {
1313
position: absolute;
1414
top: 0;
15-
left: 0;
15+
@include ltr-rtl("left", 0);
1616
z-index: 2;
1717
height: 100%; // allow textareas
1818
padding: $form-floating-padding-y $form-floating-padding-x;

scss/forms/_form-check.scss

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
}
1616

1717
.form-check-reverse {
18-
padding-right: $form-check-padding-start;
19-
padding-left: 0;
20-
text-align: right;
18+
@include ltr-rtl("padding-right", $form-check-padding-start);
19+
@include ltr-rtl("padding-left", 0);
20+
@include ltr-rtl("text-align", right);
2121

2222
.form-check-input {
23-
float: right;
24-
margin-right: $form-check-padding-start * -1;
25-
margin-left: 0;
23+
@include ltr-rtl("float", right);
24+
@include ltr-rtl("margin-right", $form-check-padding-start * -1);
25+
@include ltr-rtl("margin-left", 0);
2626
}
2727
}
2828

@@ -127,7 +127,7 @@
127127
--#{$prefix}form-switch-bg: #{escape-svg($form-switch-bg-image)};
128128

129129
width: $form-switch-width;
130-
margin-left: $form-switch-padding-start * -1;
130+
@include ltr-rtl("margin-left", $form-switch-padding-start * -1);
131131
background-image: var(--#{$prefix}form-switch-bg);
132132
background-position: left center;
133133
@include border-radius($form-switch-border-radius);
@@ -149,12 +149,12 @@
149149
}
150150

151151
&.form-check-reverse {
152-
padding-right: $form-switch-padding-start;
153-
padding-left: 0;
152+
@include ltr-rtl("padding-right", $form-check-padding-start);
153+
@include ltr-rtl("padding-left", 0);
154154

155155
.form-check-input {
156-
margin-right: $form-switch-padding-start * -1;
157-
margin-left: 0;
156+
@include ltr-rtl("margin-right", $form-check-padding-start * -1);
157+
@include ltr-rtl("margin-left", 0);
158158
}
159159
}
160160
}

scss/mixins/_caret.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@if $enable-caret {
3636
&::after {
3737
display: inline-block;
38-
margin-left: $spacing;
38+
@include ltr-rtl("margin-left", $spacing);
3939
vertical-align: $vertical-align;
4040
content: "";
4141
@if $direction == down {
@@ -54,15 +54,15 @@
5454

5555
&::before {
5656
display: inline-block;
57-
margin-right: $spacing;
57+
@include ltr-rtl("margin-right", $spacing);
5858
vertical-align: $vertical-align;
5959
content: "";
6060
@include caret-start($width);
6161
}
6262
}
6363

6464
&:empty::after {
65-
margin-left: 0;
65+
@include ltr-rtl("margin-left", 0);
6666
}
6767
}
6868
}

0 commit comments

Comments
 (0)