material_components_web-sass 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +97 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/material_components_web-sass.rb +52 -0
- data/lib/material_components_web/sass/engine.rb +18 -0
- data/lib/material_components_web/sass/version.rb +5 -0
- data/material_components_web-sass.gemspec +32 -0
- data/vendor/assets/fonts/material-icons/LICENSE +202 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.eot +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ttf +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff2 +0 -0
- data/vendor/assets/fonts/roboto/LICENSE.txt +202 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/vendor/assets/javascripts/material-components-web.js +5492 -0
- data/vendor/assets/stylesheets/@material/animation/_functions.scss +25 -0
- data/vendor/assets/stylesheets/@material/animation/_mixins.scss +29 -0
- data/vendor/assets/stylesheets/@material/animation/_variables.scss +19 -0
- data/vendor/assets/stylesheets/@material/animation/mdc-animation.scss +31 -0
- data/vendor/assets/stylesheets/@material/button/mdc-button.scss +199 -0
- data/vendor/assets/stylesheets/@material/card/mdc-card.scss +179 -0
- data/vendor/assets/stylesheets/@material/checkbox/_keyframes.scss +180 -0
- data/vendor/assets/stylesheets/@material/checkbox/_variables.scss +31 -0
- data/vendor/assets/stylesheets/@material/checkbox/mdc-checkbox.scss +310 -0
- data/vendor/assets/stylesheets/@material/drawer/_mixins.scss +145 -0
- data/vendor/assets/stylesheets/@material/drawer/mdc-drawer.scss +18 -0
- data/vendor/assets/stylesheets/@material/drawer/permanent/mdc-permanent-drawer.scss +54 -0
- data/vendor/assets/stylesheets/@material/drawer/temporary/mdc-temporary-drawer.scss +134 -0
- data/vendor/assets/stylesheets/@material/elevation/_mixins.scss +68 -0
- data/vendor/assets/stylesheets/@material/elevation/_variables.scss +122 -0
- data/vendor/assets/stylesheets/@material/elevation/mdc-elevation.scss +27 -0
- data/vendor/assets/stylesheets/@material/fab/mdc-fab.scss +122 -0
- data/vendor/assets/stylesheets/@material/fonts/material-icons.scss +36 -0
- data/vendor/assets/stylesheets/@material/fonts/roboto.scss +45 -0
- data/vendor/assets/stylesheets/@material/form-field/mdc-form-field.scss +64 -0
- data/vendor/assets/stylesheets/@material/icon-toggle/mdc-icon-toggle.scss +133 -0
- data/vendor/assets/stylesheets/@material/list/mdc-list.scss +207 -0
- data/vendor/assets/stylesheets/@material/menu/mdc-menu.scss +22 -0
- data/vendor/assets/stylesheets/@material/menu/simple/mdc-simple-menu.scss +194 -0
- data/vendor/assets/stylesheets/@material/radio/mdc-radio.scss +198 -0
- data/vendor/assets/stylesheets/@material/ripple/_keyframes.scss +61 -0
- data/vendor/assets/stylesheets/@material/ripple/_mixins.scss +196 -0
- data/vendor/assets/stylesheets/@material/ripple/_variables.scss +17 -0
- data/vendor/assets/stylesheets/@material/ripple/mdc-ripple.scss +80 -0
- data/vendor/assets/stylesheets/@material/rtl/_mixins.scss +251 -0
- data/vendor/assets/stylesheets/@material/select/mdc-select.scss +174 -0
- data/vendor/assets/stylesheets/@material/snackbar/_variables.scss +22 -0
- data/vendor/assets/stylesheets/@material/snackbar/mdc-snackbar.scss +126 -0
- data/vendor/assets/stylesheets/@material/textfield/mdc-textfield.scss +512 -0
- data/vendor/assets/stylesheets/@material/theme/_constants.scss +285 -0
- data/vendor/assets/stylesheets/@material/theme/_functions.scss +64 -0
- data/vendor/assets/stylesheets/@material/theme/_mixins.scss +104 -0
- data/vendor/assets/stylesheets/@material/theme/_variables.scss +80 -0
- data/vendor/assets/stylesheets/@material/theme/mdc-theme.scss +43 -0
- data/vendor/assets/stylesheets/@material/typography/_mixins.scss +45 -0
- data/vendor/assets/stylesheets/@material/typography/_variables.scss +109 -0
- data/vendor/assets/stylesheets/@material/typography/mdc-typography.scss +32 -0
- data/vendor/assets/stylesheets/_material-components-web.scss +36 -0
- metadata +195 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2016 Google Inc. All Rights Reserved.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
@import "@material/theme/variables";
|
18
|
+
@import "./keyframes";
|
19
|
+
@import "./variables";
|
20
|
+
|
21
|
+
@function mdc-ripple-default-config_() {
|
22
|
+
@return (
|
23
|
+
pseudo: null,
|
24
|
+
radius: 100%,
|
25
|
+
base-color: black,
|
26
|
+
opacity: .06,
|
27
|
+
theme-style: null
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
31
|
+
@mixin mdc-ripple-base() {
|
32
|
+
--mdc-ripple-left: 0;
|
33
|
+
--mdc-ripple-top: 0;
|
34
|
+
--mdc-ripple-fg-size: 0;
|
35
|
+
--mdc-ripple-surface-height: 0;
|
36
|
+
--mdc-ripple-surface-width: 0;
|
37
|
+
--mdc-ripple-fg-unbounded-transform-duration: 0ms;
|
38
|
+
--mdc-ripple-xfo-x: center;
|
39
|
+
--mdc-ripple-xfo-y: center;
|
40
|
+
--mdc-ripple-fg-unbounded-opacity-duration: 0ms;
|
41
|
+
--mdc-ripple-fg-unbounded-transform-duration: 0ms;
|
42
|
+
--mdc-ripple-fg-approx-xf: 0;
|
43
|
+
|
44
|
+
will-change: transition, opacity;
|
45
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
46
|
+
}
|
47
|
+
|
48
|
+
@mixin mdc-ripple-color_($config) {
|
49
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
50
|
+
$base-color: map-get($config, base-color);
|
51
|
+
$opacity: map-get($config, opacity);
|
52
|
+
$theme-style: map-get($config, theme-style);
|
53
|
+
|
54
|
+
/* stylelint-disable at-rule-empty-line-before, block-closing-brace-newline-after */
|
55
|
+
@if ($theme-style) {
|
56
|
+
$theme-value: map-get($mdc-theme-property-values, $theme-style);
|
57
|
+
$css-var: var(--mdc-theme-#{$theme-style}, $theme-value);
|
58
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
59
|
+
|
60
|
+
background-color: rgba($theme-value, $opacity);
|
61
|
+
|
62
|
+
// See: https://drafts.csswg.org/css-color/#modifying-colors
|
63
|
+
// While this is currently unsupported as of now, it will begin to work by default as browsers
|
64
|
+
// begin to implement the CSS 4 color spec.
|
65
|
+
@supports (background-color: color(green a(10%))) {
|
66
|
+
background-color: color(#{$css-var} a(#{percentage($opacity)}));
|
67
|
+
}
|
68
|
+
} @else {
|
69
|
+
background-color: rgba($base-color, $opacity);
|
70
|
+
}
|
71
|
+
/* stylelint-enable at-rule-empty-line-before, block-closing-brace-newline-after */
|
72
|
+
}
|
73
|
+
|
74
|
+
@mixin mdc-ripple-bg-base_($config) {
|
75
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
76
|
+
$radius: map-get($config, radius);
|
77
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
78
|
+
|
79
|
+
@include mdc-ripple-color_($config);
|
80
|
+
|
81
|
+
position: absolute;
|
82
|
+
top: calc(50% - #{$radius});
|
83
|
+
left: calc(50% - #{$radius});
|
84
|
+
width: $radius * 2;
|
85
|
+
height: $radius * 2;
|
86
|
+
transform: scale(1);
|
87
|
+
transition: opacity 200ms linear;
|
88
|
+
border-radius: 50%;
|
89
|
+
opacity: 0;
|
90
|
+
pointer-events: none;
|
91
|
+
}
|
92
|
+
|
93
|
+
@mixin mdc-ripple-bg($config: ()) {
|
94
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
95
|
+
$config: map-merge(mdc-ripple-default-config_(), $config);
|
96
|
+
$pseudo: map-get($config, pseudo);
|
97
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
98
|
+
|
99
|
+
/* stylelint-disable at-rule-empty-line-before, block-closing-brace-newline-after */
|
100
|
+
@if ($pseudo) {
|
101
|
+
&#{$pseudo} {
|
102
|
+
@include mdc-ripple-bg-base_($config);
|
103
|
+
|
104
|
+
content: "";
|
105
|
+
}
|
106
|
+
} @else {
|
107
|
+
@include mdc-ripple-bg-base_($config);
|
108
|
+
}
|
109
|
+
/* stylelint-enable at-rule-empty-line-before, block-closing-brace-newline-after */
|
110
|
+
|
111
|
+
&.mdc-ripple-upgraded--background-active#{$pseudo} {
|
112
|
+
opacity: .99999;
|
113
|
+
}
|
114
|
+
|
115
|
+
// When an element goes active, a foreground ripple will be triggered.
|
116
|
+
// Therefore, we adjust the transition duration for the correct "wind-
|
117
|
+
// up" animation.
|
118
|
+
&.mdc-ripple-upgraded--background-active:active#{$pseudo} {
|
119
|
+
transition-duration: 600ms;
|
120
|
+
}
|
121
|
+
|
122
|
+
&.mdc-ripple-upgraded--background-bounded-active-fill#{$pseudo} {
|
123
|
+
transition-duration: 120ms;
|
124
|
+
opacity: 1;
|
125
|
+
}
|
126
|
+
|
127
|
+
&.mdc-ripple-upgraded--unbounded#{$pseudo} {
|
128
|
+
top: var(--mdc-ripple-top);
|
129
|
+
left: var(--mdc-ripple-left);
|
130
|
+
width: var(--mdc-ripple-fg-size);
|
131
|
+
height: var(--mdc-ripple-fg-size);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
@mixin mdc-ripple-fg-base_($config) {
|
136
|
+
@include mdc-ripple-color_($config);
|
137
|
+
|
138
|
+
position: absolute;
|
139
|
+
width: var(--mdc-ripple-fg-size);
|
140
|
+
height: var(--mdc-ripple-fg-size);
|
141
|
+
transform: scale(0);
|
142
|
+
transform-origin: center center;
|
143
|
+
border-radius: 50%;
|
144
|
+
opacity: 0;
|
145
|
+
pointer-events: none;
|
146
|
+
}
|
147
|
+
|
148
|
+
@mixin mdc-ripple-fg($config: ()) {
|
149
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
150
|
+
$config: map-merge(mdc-ripple-default-config_(), $config);
|
151
|
+
$pseudo: map-get($config, pseudo);
|
152
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
153
|
+
|
154
|
+
/* stylelint-disable at-rule-empty-line-before, block-closing-brace-newline-after */
|
155
|
+
@if ($pseudo) {
|
156
|
+
&#{$pseudo} {
|
157
|
+
@include mdc-ripple-fg-base_($config);
|
158
|
+
|
159
|
+
content: "";
|
160
|
+
}
|
161
|
+
} @else {
|
162
|
+
@include mdc-ripple-fg-base_($config);
|
163
|
+
}
|
164
|
+
/* stylelint-enable at-rule-empty-line-before, block-closing-brace-newline-after */
|
165
|
+
|
166
|
+
&:not(.mdc-ripple-upgraded--unbounded)#{$pseudo} {
|
167
|
+
top: calc(var(--mdc-ripple-top) - var(--mdc-ripple-fg-size) / 2);
|
168
|
+
left: calc(var(--mdc-ripple-left) - var(--mdc-ripple-fg-size) / 2);
|
169
|
+
transform-origin: center center;
|
170
|
+
}
|
171
|
+
|
172
|
+
&.mdc-ripple-upgraded--unbounded#{$pseudo} {
|
173
|
+
top: var(--mdc-ripple-top);
|
174
|
+
left: var(--mdc-ripple-left);
|
175
|
+
transform-origin: var(--mdc-ripple-xfo-x) var(--mdc-ripple-xfo-y);
|
176
|
+
}
|
177
|
+
|
178
|
+
&.mdc-ripple-upgraded--foreground-bounded-active-fill#{$pseudo} {
|
179
|
+
animation-fill-mode: forwards;
|
180
|
+
animation: 800ms mdc-ripple-fg-radius-in, 400ms mdc-ripple-fg-opacity-out;
|
181
|
+
}
|
182
|
+
|
183
|
+
&.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded--foreground-unbounded-activation#{$pseudo} {
|
184
|
+
transform: scale(1);
|
185
|
+
transition:
|
186
|
+
opacity 110ms linear,
|
187
|
+
transform var(--mdc-ripple-fg-unbounded-transform-duration) linear 80ms;
|
188
|
+
opacity: 1;
|
189
|
+
}
|
190
|
+
|
191
|
+
&.mdc-ripple-upgraded--unbounded.mdc-ripple-upgraded--foreground-unbounded-deactivation#{$pseudo} {
|
192
|
+
animation:
|
193
|
+
mdc-ripple-fg-unbounded-opacity-deactivate var(--mdc-ripple-fg-unbounded-opacity-duration) linear,
|
194
|
+
mdc-ripple-fg-unbounded-transform-deactivate var(--mdc-ripple-fg-unbounded-transform-duration) $mdc-ripple-easing-fn;
|
195
|
+
}
|
196
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2016 Google Inc. All Rights Reserved.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
$mdc-ripple-easing-fn: cubic-bezier(.157, .72, .386, .987);
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2016 Google Inc. All Rights Reserved.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
@import "@material/animation/functions";
|
18
|
+
@import "@material/theme/mixins";
|
19
|
+
@import "./mixins";
|
20
|
+
|
21
|
+
/* postcss-bem-linter: define ripple-surface */
|
22
|
+
|
23
|
+
.mdc-ripple-surface {
|
24
|
+
position: relative;
|
25
|
+
outline: none;
|
26
|
+
overflow: hidden;
|
27
|
+
|
28
|
+
&[data-mdc-ripple-is-unbounded] {
|
29
|
+
overflow: visible;
|
30
|
+
}
|
31
|
+
|
32
|
+
&::before {
|
33
|
+
position: absolute;
|
34
|
+
top: 0;
|
35
|
+
right: 0;
|
36
|
+
bottom: 0;
|
37
|
+
left: 0;
|
38
|
+
transition: mdc-animation-exit(opacity, 120ms);
|
39
|
+
border-radius: inherit;
|
40
|
+
background: currentColor;
|
41
|
+
content: "";
|
42
|
+
opacity: 0;
|
43
|
+
}
|
44
|
+
|
45
|
+
&:focus::before {
|
46
|
+
opacity: .12;
|
47
|
+
}
|
48
|
+
|
49
|
+
&:active::before {
|
50
|
+
opacity: .18;
|
51
|
+
}
|
52
|
+
|
53
|
+
&.mdc-ripple-upgraded {
|
54
|
+
@include mdc-ripple-base;
|
55
|
+
@include mdc-ripple-bg((pseudo: "::before"));
|
56
|
+
@include mdc-ripple-fg((pseudo: "::after"));
|
57
|
+
}
|
58
|
+
|
59
|
+
&--primary.mdc-ripple-upgraded {
|
60
|
+
&::before,
|
61
|
+
&::after {
|
62
|
+
@include mdc-theme-prop(background-color, primary);
|
63
|
+
}
|
64
|
+
|
65
|
+
@include mdc-ripple-bg((pseudo: "::before", theme-style: primary, opacity: .14));
|
66
|
+
@include mdc-ripple-fg((pseudo: "::after", theme-style: primary, opacity: .14));
|
67
|
+
}
|
68
|
+
|
69
|
+
&--accent.mdc-ripple-upgraded {
|
70
|
+
&::before,
|
71
|
+
&::after {
|
72
|
+
@include mdc-theme-prop(background-color, primary);
|
73
|
+
}
|
74
|
+
|
75
|
+
@include mdc-ripple-bg((pseudo: "::before", theme-style: accent, opacity: .14));
|
76
|
+
@include mdc-ripple-fg((pseudo: "::after", theme-style: accent, opacity: .14));
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
/* postcss-bem-linter: end */
|
@@ -0,0 +1,251 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright 2016 Google Inc. All Rights Reserved.
|
3
|
+
*
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
* you may not use this file except in compliance with the License.
|
6
|
+
* You may obtain a copy of the License at
|
7
|
+
*
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
*
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
* See the License for the specific language governing permissions and
|
14
|
+
* limitations under the License.
|
15
|
+
*/
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Creates a rule that will be applied when an MDC-Web component is within the context of an RTL layout.
|
19
|
+
*
|
20
|
+
* Usage Example:
|
21
|
+
* ```scss
|
22
|
+
* .mdc-foo {
|
23
|
+
* position: absolute;
|
24
|
+
* left: 0;
|
25
|
+
*
|
26
|
+
* @include mdc-rtl {
|
27
|
+
* left: auto;
|
28
|
+
* right: 0;
|
29
|
+
* }
|
30
|
+
*
|
31
|
+
* &__bar {
|
32
|
+
* margin-left: 4px;
|
33
|
+
* @include mdc-rtl(".mdc-foo") {
|
34
|
+
* margin-left: auto;
|
35
|
+
* margin-right: 4px;
|
36
|
+
* }
|
37
|
+
* }
|
38
|
+
* }
|
39
|
+
*
|
40
|
+
* .mdc-foo--mod {
|
41
|
+
* padding-left: 4px;
|
42
|
+
*
|
43
|
+
* @include mdc-rtl {
|
44
|
+
* padding-left: auto;
|
45
|
+
* padding-right: 4px;
|
46
|
+
* }
|
47
|
+
* }
|
48
|
+
* ```
|
49
|
+
*
|
50
|
+
* Note that this works by checking for [dir="rtl"] on an ancestor element. While this will work
|
51
|
+
* in most cases, it will in some cases lead to false negatives, e.g.
|
52
|
+
*
|
53
|
+
* ```html
|
54
|
+
* <html dir="rtl">
|
55
|
+
* <!-- ... -->
|
56
|
+
* <div dir="ltr">
|
57
|
+
* <div class="mdc-foo">Styled incorrectly as RTL!</div>
|
58
|
+
* </div>
|
59
|
+
* </html>
|
60
|
+
* ```
|
61
|
+
*
|
62
|
+
* In the future, selectors such as :dir (http://mdn.io/:dir) will help us mitigate this.
|
63
|
+
*/
|
64
|
+
@mixin mdc-rtl($root-selector: null) {
|
65
|
+
@if ($root-selector) {
|
66
|
+
@at-root {
|
67
|
+
[dir="rtl"] #{$root-selector} &,
|
68
|
+
#{$root-selector}[dir="rtl"] & {
|
69
|
+
@content;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
@else {
|
75
|
+
[dir="rtl"] &,
|
76
|
+
&[dir="rtl"] {
|
77
|
+
@content;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* Takes a base box-model property - e.g. margin / border / padding - along with a default
|
84
|
+
* direction and value, and emits rules which apply the value to the
|
85
|
+
* "<base-property>-<default-direction>" property by default, but flips the direction
|
86
|
+
* when within an RTL context.
|
87
|
+
*
|
88
|
+
* For example:
|
89
|
+
*
|
90
|
+
* ```scss
|
91
|
+
* .mdc-foo {
|
92
|
+
* @include mdc-rtl-reflexive-box(margin, left, 8px);
|
93
|
+
* }
|
94
|
+
* ```
|
95
|
+
* is equivalent to:
|
96
|
+
*
|
97
|
+
* ```scss
|
98
|
+
* .mdc-foo {
|
99
|
+
* margin-left: 8px;
|
100
|
+
*
|
101
|
+
* @include mdc-rtl {
|
102
|
+
* margin-right: 8px;
|
103
|
+
* margin-left: 0;
|
104
|
+
* }
|
105
|
+
* }
|
106
|
+
* ```
|
107
|
+
* whereas:
|
108
|
+
*
|
109
|
+
* ```scss
|
110
|
+
* .mdc-foo {
|
111
|
+
* @include mdc-rtl-reflexive-box(margin, right, 8px);
|
112
|
+
* }
|
113
|
+
* ```
|
114
|
+
* is equivalent to:
|
115
|
+
*
|
116
|
+
* ```scss
|
117
|
+
* .mdc-foo {
|
118
|
+
* margin-right: 8px;
|
119
|
+
*
|
120
|
+
* @include mdc-rtl {
|
121
|
+
* margin-right: 0;
|
122
|
+
* margin-left: 8px;
|
123
|
+
* }
|
124
|
+
* }
|
125
|
+
* ```
|
126
|
+
*
|
127
|
+
* You can also pass a 4th optional $root-selector argument which will be forwarded to `mdc-rtl`,
|
128
|
+
* e.g. `@include mdc-rtl-reflexive-box-property(margin, left, 8px, ".mdc-component")`.
|
129
|
+
*
|
130
|
+
* Note that this function will always zero out the original value in an RTL context. If you're
|
131
|
+
* trying to flip the values, use mdc-rtl-reflexive-property().
|
132
|
+
*/
|
133
|
+
@mixin mdc-rtl-reflexive-box($base-property, $default-direction, $value, $root-selector: null) {
|
134
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
135
|
+
|
136
|
+
@if (index((right, left), $default-direction) == null) {
|
137
|
+
@error "Invalid default direction #{default-direction}. Please specifiy either right or left";
|
138
|
+
}
|
139
|
+
|
140
|
+
$left-value: $value;
|
141
|
+
$right-value: 0;
|
142
|
+
|
143
|
+
@if ($default-direction == right) {
|
144
|
+
$left-value: 0;
|
145
|
+
$right-value: $value;
|
146
|
+
}
|
147
|
+
|
148
|
+
@include mdc-rtl-reflexive-property($base-property, $left-value, $right-value, $root-selector);
|
149
|
+
|
150
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Takes a base property and emits rules that assign <base-property>-left to <left-value> and
|
155
|
+
* <base-property>-right to <right-value> in a LTR context, and vice versa in a RTL context.
|
156
|
+
* For example:
|
157
|
+
*
|
158
|
+
* ```scss
|
159
|
+
* .mdc-foo {
|
160
|
+
* @include mdc-rtl-reflexive-property(margin, auto, 12px);
|
161
|
+
* }
|
162
|
+
* ```
|
163
|
+
* is equivalent to:
|
164
|
+
*
|
165
|
+
* ```scss
|
166
|
+
* .mdc-foo {
|
167
|
+
* margin-left: auto;
|
168
|
+
* margin-right: 12px;
|
169
|
+
*
|
170
|
+
* @include mdc-rtl {
|
171
|
+
* margin-left: 12px;
|
172
|
+
* margin-right: auto;
|
173
|
+
* }
|
174
|
+
* }
|
175
|
+
* ```
|
176
|
+
*
|
177
|
+
* A 4th optional $root-selector argument can be given, which will be passed to `mdc-rtl`.
|
178
|
+
*/
|
179
|
+
@mixin mdc-rtl-reflexive-property($base-property, $left-value, $right-value, $root-selector: null) {
|
180
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
181
|
+
|
182
|
+
$prop-left: #{$base-property}-left;
|
183
|
+
$prop-right: #{$base-property}-right;
|
184
|
+
|
185
|
+
@include mdc-rtl-reflexive_($prop-left, $left-value, $prop-right, $right-value, $root-selector);
|
186
|
+
|
187
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Takes an argument specifying a horizontal position property (either "left" or "right") as well
|
192
|
+
* as a value, and applies that value to the specified position in a LTR context, and flips it in a
|
193
|
+
* RTL context. For example:
|
194
|
+
*
|
195
|
+
* ```scss
|
196
|
+
* .mdc-foo {
|
197
|
+
* @include mdc-rtl-reflexive-position(left, 0);
|
198
|
+
* position: absolute;
|
199
|
+
* }
|
200
|
+
* ```
|
201
|
+
* is equivalent to:
|
202
|
+
*
|
203
|
+
* ```scss
|
204
|
+
* .mdc-foo {
|
205
|
+
* position: absolute;
|
206
|
+
* left: 0;
|
207
|
+
* right: initial;
|
208
|
+
*
|
209
|
+
* @include mdc-rtl {
|
210
|
+
* right: 0;
|
211
|
+
* left: initial;
|
212
|
+
* }
|
213
|
+
* }
|
214
|
+
* ```
|
215
|
+
* An optional third $root-selector argument may also be given, which is passed to `mdc-rtl`.
|
216
|
+
*/
|
217
|
+
@mixin mdc-rtl-reflexive-position($pos, $value, $root-selector: null) {
|
218
|
+
/* stylelint-disable scss/dollar-variable-pattern */
|
219
|
+
|
220
|
+
@if (index((right, left), $pos) == null) {
|
221
|
+
@error "Invalid position #{pos}. Please specifiy either right or left";
|
222
|
+
}
|
223
|
+
|
224
|
+
$left-value: $value;
|
225
|
+
$right-value: initial;
|
226
|
+
|
227
|
+
@if ($pos == right) {
|
228
|
+
$right-value: $value;
|
229
|
+
$left-value: initial;
|
230
|
+
}
|
231
|
+
|
232
|
+
@include mdc-rtl-reflexive_(left, $left-value, right, $right-value, $root-selector);
|
233
|
+
|
234
|
+
/* stylelint-enable scss/dollar-variable-pattern */
|
235
|
+
}
|
236
|
+
|
237
|
+
@mixin mdc-rtl-reflexive_(
|
238
|
+
$left-property,
|
239
|
+
$left-value,
|
240
|
+
$right-property,
|
241
|
+
$right-value,
|
242
|
+
$root-selector: null
|
243
|
+
) {
|
244
|
+
#{$left-property}: $left-value;
|
245
|
+
#{$right-property}: $right-value;
|
246
|
+
|
247
|
+
@include mdc-rtl($root-selector) {
|
248
|
+
#{$left-property}: $right-value;
|
249
|
+
#{$right-property}: $left-value;
|
250
|
+
}
|
251
|
+
}
|