Skip to content

Commit 9c1f8a9

Browse files
crisbetojelbourn
authored andcommitted
fix(badge): incorrectly handling rtl (#10630)
* Fixes all of the RTL selectors being scoped to the badge itself, rather than a parent, which means that consumers would have to set `dir="rtl"` on each individual badge. * Fixes none of the `left`/`right` values being inverted.
1 parent 5df1af6 commit 9c1f8a9

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

src/lib/badge/_badge-theme.scss

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,53 +40,73 @@ $mat-badge-large-size: $mat-badge-default-size + 6;
4040
&.mat-badge-before {
4141
margin-left: $size;
4242

43-
&[dir='rtl'] {
44-
margin-left: 0;
45-
margin-right: $size;
43+
.mat-badge-content {
44+
left: -$size;
4645
}
46+
}
47+
48+
[dir='rtl'] &.mat-badge-before {
49+
margin-left: 0;
50+
margin-right: $size;
4751

4852
.mat-badge-content {
49-
left: -$size;
53+
left: auto;
54+
right: -$size;
5055
}
5156
}
5257

5358
&.mat-badge-after {
5459
margin-right: $size;
5560

56-
&[dir='rtl'] {
57-
margin-right: 0;
58-
margin-left: $size;
61+
.mat-badge-content {
62+
right: -$size;
5963
}
64+
}
65+
66+
[dir='rtl'] &.mat-badge-after {
67+
margin-right: 0;
68+
margin-left: $size;
6069

6170
.mat-badge-content {
62-
right: -$size;
71+
right: auto;
72+
left: -$size;
6373
}
6474
}
6575

6676
&.mat-badge-overlap {
6777
&.mat-badge-before {
6878
margin-left: $size / 2;
6979

70-
&[dir='rtl'] {
71-
margin-left: 0;
72-
margin-right: $size / 2;
80+
.mat-badge-content {
81+
left: -$size / 2;
7382
}
83+
}
84+
85+
[dir='rtl'] &.mat-badge-before {
86+
margin-left: 0;
87+
margin-right: $size / 2;
7488

7589
.mat-badge-content {
76-
left: -$size / 2;
90+
left: auto;
91+
right: -$size / 2;
7792
}
7893
}
7994

8095
&.mat-badge-after {
8196
margin-right: $size / 2;
8297

83-
&[dir='rtl'] {
84-
margin-right: 0;
85-
margin-left: $size;
98+
.mat-badge-content {
99+
right: -$size / 2;
86100
}
101+
}
102+
103+
[dir='rtl'] &.mat-badge-after {
104+
margin-right: 0;
105+
margin-left: $size;
87106

88107
.mat-badge-content {
89-
right: -$size / 2;
108+
right: auto;
109+
left: -$size / 2;
90110
}
91111
}
92112
}

0 commit comments

Comments
 (0)