-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(RTL): better RTL support #11121
Changes from all commits
5655f80
7541ec0
956e7c3
6aa6693
e4cacb4
cd01025
04bb57f
44d2577
0fbd8a8
89dc966
b8e690a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,18 +11,34 @@ | |
pointer-events: none; | ||
} | ||
|
||
[icon-left] ion-icon { | ||
[icon-left] ion-icon, | ||
[dir="ltr"] [icon-left] ion-icon { | ||
@include button-icon; | ||
|
||
padding-right: .3em; | ||
} | ||
|
||
[icon-right] ion-icon { | ||
[icon-right] ion-icon, | ||
[dir="ltr"] [icon-right] ion-icon { | ||
@include button-icon; | ||
|
||
padding-left: .4em; | ||
} | ||
|
||
[dir="rtl"] [icon-left] ion-icon { | ||
@include button-icon; | ||
|
||
padding-left: .4em; | ||
padding-right: initial; | ||
} | ||
|
||
[dir="rtl"] [icon-right] ion-icon { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same question as above with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's gonna be a problem.
It doesn't move the icon to the left, just adds some wrong padding. |
||
@include button-icon; | ||
|
||
padding-right: .3em; | ||
padding-left: initial; | ||
} | ||
|
||
.button[icon-only] { | ||
padding: 0; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ $ionicons-font-path: $font-path !default; | |
|
||
@import "ionicons-icons"; | ||
@import "ionicons-variables"; | ||
@import "~hail2u-scss-functions/string/_str-replace"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure about this for icons. I wonder if there is a better way to decide if the icon should or shouldn't be flipped on rtl. We're thinking maybe we could add some metadata to the icon itself and look at it that way? We need to discuss this more but maybe this could be split out from this PR for further discussion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.. ok |
||
|
||
|
||
@font-face { | ||
|
@@ -33,3 +34,58 @@ ion-icon { | |
text-transform: none; | ||
speak: none; | ||
} | ||
|
||
// RTL Support | ||
// -------------------------- | ||
|
||
@mixin notIn($attribute, $operator, $ignoreList...) { | ||
// If only a single value given | ||
@if (length($ignoreList) == 1) { | ||
// It is probably a list variable so set ignore list to the variable | ||
$ignoreList: nth($ignoreList, 1); | ||
} | ||
|
||
// Set up an empty $notOutput variable | ||
$notOutput: ''; | ||
// For each item in the list | ||
@each $not in $ignoreList { | ||
// Generate a :not([attribute='ignored_item']) segment for each item in the ignore list and put them back to back | ||
$notOutput: #{"#{$notOutput}:not([#{$attribute}#{$operator}='#{str-replace($not, '-', ' ')}'])"}; | ||
} | ||
//output the full :not() rule including all ignored items | ||
&#{$notOutput} { | ||
@content; | ||
} | ||
} | ||
|
||
[flip] { | ||
-moz-transform: scaleX(-1); | ||
-o-transform: scaleX(-1); | ||
-webkit-transform: scaleX(-1); | ||
transform: scaleX(-1); | ||
} | ||
|
||
$ltr-begin: "logo"; | ||
|
||
$ltr-icons: "at", "attach", | ||
"bluetooth", | ||
"checkbox", "checkbox-outline", "checkmark", "checkmark-circle", "checkmark-circle-outline", "chrome", | ||
"closed-captioning", | ||
// Adding cloud because of "cloud-done" & "thunderstorm" | ||
"cloud", "cloud-circle", "cloud-done", "cloud-download", "cloud-outline", "cloud-upload", "thunderstorm", | ||
"done-all", | ||
"help", "help-circle", | ||
"information", "information-circle", "ionic", | ||
"musical-note", "musical-notes", | ||
"no-smoking", | ||
"play", | ||
"timer", "trending-down", "trending-up", | ||
"volume-down", "volume-mute", "volume-off", "volume-up"; | ||
|
||
[dir="rtl"] ion-icon { | ||
@include notIn("aria-label", "^", $ltr-begin) { // Does not start with | ||
@include notIn("aria-label", "", $ltr-icons) { // Does not equal | ||
@extend [flip]; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do
pull-left
,pull-right
,pull-start
, andpull-end
here and make them work like thetext-*
attributes do? Or is there a reason not to?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, moved to a separate PR: #11214