Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit ca018a7

Browse files
authored
feat(rtl): Make mdc-rtl-reflexive sass mixin public (#2823)
1 parent 9e35b1e commit ca018a7

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

packages/mdc-rtl/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Both `mdc-rtl-reflexive-property` and `mdc-rtl-reflexive-box` work with one base
4040
| `mdc-rtl-reflexive-box($base-property, $default-direction, $value, $root-selector)` | Applies the value to the `#{$base-property}-#{$default-direction}` property in a LTR context, and flips the direction in an RTL context. **This mixin zeros out the original value in an RTL context.** |
4141
| `mdc-rtl-reflexive-property($base-property, $left-value, $right-value, $root-selector)` | Emits rules that assign `#{$base-property}`-left to `#{left-value}` and `#{base-property}`-right to `#{right-value}` in a LTR context, and vice versa in a RTL context. **Basically it flips values between a LTR and RTL context.** |
4242
| `mdc-rtl-reflexive-position($position-property, $value, $root-selector)` | Applies the value to the specified position in a LTR context, and flips the direction in an RTL context. `$position-property` is a horizontal position, either "left" or "right". |
43+
| `mdc-rtl-reflexive($left-property, $left-value, $right-property, $right-value, $root-selector)` | Applies the pair of property values to the specified position in a LTR context, and flips the direction in an RTL context. |
4344

4445
**A note about [dir="rtl"]**: `mdc-rtl($root-selector)` checks for `[dir="rtl"]` on the ancestor element. This works in most cases, it will sometimes lead to false negatives for more complex layouts, e.g.
4546

packages/mdc-rtl/_mixins.scss

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
$prop-left: #{$base-property}-left;
169169
$prop-right: #{$base-property}-right;
170170

171-
@include mdc-rtl-reflexive_($prop-left, $left-value, $prop-right, $right-value, $root-selector);
171+
@include mdc-rtl-reflexive($prop-left, $left-value, $prop-right, $right-value, $root-selector);
172172
}
173173

174174
// Takes an argument specifying a horizontal position property (either "left" or "right") as well
@@ -209,10 +209,34 @@
209209
$left-value: initial;
210210
}
211211

212-
@include mdc-rtl-reflexive_(left, $left-value, right, $right-value, $root-selector);
212+
@include mdc-rtl-reflexive(left, $left-value, right, $right-value, $root-selector);
213213
}
214214

215-
@mixin mdc-rtl-reflexive_(
215+
// Takes pair of properties with values as arguments and flips it in RTL context.
216+
// For example:
217+
//
218+
// ```scss
219+
// .mdc-foo {
220+
// @include mdc-rtl-reflexive(left, 2px, right, 5px);
221+
// position: absolute;
222+
// }
223+
// ```
224+
// is equivalent to:
225+
//
226+
// ```scss
227+
// .mdc-foo {
228+
// position: absolute;
229+
// left: 2px;
230+
// right: 5px;
231+
//
232+
// @include mdc-rtl {
233+
// right: 2px;
234+
// left: 5px;
235+
// }
236+
// }
237+
// ```
238+
// An optional fifth $root-selector argument may also be given, which is passed to `mdc-rtl`.
239+
@mixin mdc-rtl-reflexive(
216240
$left-property,
217241
$left-value,
218242
$right-property,

packages/mdc-top-app-bar/_mixins.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
}
4747

4848
@mixin mdc-top-app-bar-short-border-radius($border-radius: $mdc-top-app-bar-short-collapsed-border-radius) {
49-
@include mdc-rtl-reflexive_(border-bottom-left-radius, 0, border-bottom-right-radius, $border-radius);
49+
@include mdc-rtl-reflexive(border-bottom-left-radius, 0, border-bottom-right-radius, $border-radius);
5050
}
5151

5252
@mixin mdc-top-app-bar-mobile-breakpoint_($mobile-breakpoint: $mdc-top-app-bar-mobile-breakpoint) {

0 commit comments

Comments
 (0)