Skip to content

Commit 3d474ec

Browse files
authoredMay 26, 2021
fix(title): large title scale animation is now correct in rtl mode (#23372)
resolves #23371
1 parent 2933531 commit 3d474ec

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed
 

‎.github/COMPONENT-GUIDE.md

+37
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [Example Components](#example-components-1)
1717
* [Component Structure](#component-structure-1)
1818
- [Converting Scoped to Shadow](#converting-scoped-to-shadow)
19+
- [RTL](#rtl)
1920

2021
## Button States
2122

@@ -703,3 +704,39 @@ There will be some CSS issues when converting to shadow. Below are some of the d
703704
/* IN SHADOW*/
704705
:host-context(ion-toolbar:not(.ion-color)):host(:not(.ion-color)) ::slotted(ion-segment-button) {
705706
```
707+
708+
## RTL
709+
710+
When you need to support both LTR and RTL modes, try to avoid using values such as `left` and `right`. For certain CSS properties, you can use the appropriate mixin to have this handled for you automatically.
711+
712+
For example, if you wanted `transform-origin` to be RTL-aware, you would use the `transform-origin` mixin:
713+
714+
```css
715+
@include transform-origin(start, center);
716+
```
717+
718+
This would output `transform-origin: left center` in LTR mode and `transform-origin: right center` in RTL mode.
719+
720+
These mixins depend on the `:host-context` pseudo-class when used inside of shadow components, which is not supported in WebKit. As a result, these mixins will not work in Safari for macOS and iOS when applied to shadow components.
721+
722+
To work around this, you should set an RTL class on the host of your component and set your RTL styles by targeting that class:
723+
724+
```tsx
725+
<Host
726+
class={{
727+
'my-cmp-rtl': document.dir === 'rtl'
728+
})
729+
>
730+
...
731+
</Host>
732+
```
733+
734+
```css
735+
:host {
736+
transform-origin: left center;
737+
}
738+
739+
:host(.my-cmp-rtl) {
740+
transform-origin: right center;
741+
}
742+
```

‎core/src/components/title/title.ios.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
:host(.title-large) {
4343
@include padding(0, 16px);
44-
@include transform-origin(start, center);
44+
@include transform-origin(left, center);
4545

4646
bottom: 0;
4747

@@ -57,6 +57,10 @@
5757
text-align: start;
5858
}
5959

60+
:host(.title-large.title-rtl) {
61+
@include transform-origin(right, center);
62+
}
63+
6064
:host(.title-large.ion-cloned-element) {
6165
--color: #{$text-color};
6266
}

‎core/src/components/title/title.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class ToolbarTitle implements ComponentInterface {
6464
class={createColorClasses(this.color, {
6565
[mode]: true,
6666
[`title-${size}`]: true,
67+
'title-rtl': document.dir === 'rtl'
6768
})}
6869
>
6970
<div class="toolbar-title">

0 commit comments

Comments
 (0)
Please sign in to comment.