|
22 | 22 |
|
23 | 23 | @import "@material/theme/mixins";
|
24 | 24 | @import "@material/shape/mixins";
|
| 25 | +@import "@material/floating-label/mixins"; |
25 | 26 | @import "@material/shape/functions";
|
| 27 | +@import "@material/feature-targeting/functions"; |
| 28 | +@import "@material/feature-targeting/mixins"; |
26 | 29 | @import "@material/rtl/mixins";
|
27 | 30 | @import "./variables";
|
28 | 31 |
|
29 |
| -@mixin mdc-notched-outline-color($color) { |
| 32 | +@mixin mdc-notched-outline-core-styles($query: mdc-feature-all()) { |
| 33 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 34 | + |
| 35 | + .mdc-notched-outline { |
| 36 | + @include mdc-notched-outline-base_($query); |
| 37 | + |
| 38 | + &__leading, |
| 39 | + &__notch, |
| 40 | + &__trailing { |
| 41 | + @include mdc-feature-targets($feat-structure) { |
| 42 | + box-sizing: border-box; |
| 43 | + height: 100%; |
| 44 | + border-top: $mdc-notched-outline-border-width solid; |
| 45 | + border-bottom: $mdc-notched-outline-border-width solid; |
| 46 | + pointer-events: none; |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + &__leading { |
| 51 | + @include mdc-feature-targets($feat-structure) { |
| 52 | + @include mdc-rtl-reflexive-property(border, $mdc-notched-outline-border-width solid, none); |
| 53 | + |
| 54 | + width: $mdc-notched-outline-leading-width; |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | + &__trailing { |
| 59 | + @include mdc-feature-targets($feat-structure) { |
| 60 | + @include mdc-rtl-reflexive-property(border, none, $mdc-notched-outline-border-width solid); |
| 61 | + |
| 62 | + flex-grow: 1; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + &__notch { |
| 67 | + @include mdc-feature-targets($feat-structure) { |
| 68 | + flex: 0 0 auto; |
| 69 | + width: auto; |
| 70 | + max-width: calc(100% - #{$mdc-notched-outline-leading-width} * 2); |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + .mdc-floating-label { |
| 75 | + @include mdc-feature-targets($feat-structure) { |
| 76 | + display: inline-block; |
| 77 | + position: relative; |
| 78 | + max-width: 100%; |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | + .mdc-floating-label--float-above { |
| 83 | + @include mdc-feature-targets($feat-structure) { |
| 84 | + text-overflow: clip; |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + &--upgraded .mdc-floating-label--float-above { |
| 89 | + @include mdc-feature-targets($feat-structure) { |
| 90 | + max-width: calc(100% / .75); |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + |
| 95 | + .mdc-notched-outline--notched { |
| 96 | + .mdc-notched-outline__notch { |
| 97 | + @include mdc-feature-targets($feat-structure) { |
| 98 | + @include mdc-rtl-reflexive-box(padding, right, 8px); |
| 99 | + |
| 100 | + border-top: none; |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + .mdc-notched-outline--no-label { |
| 106 | + .mdc-notched-outline__notch { |
| 107 | + @include mdc-feature-targets($feat-structure) { |
| 108 | + padding: 0; |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +@mixin mdc-notched-outline-color($color, $query: mdc-feature-all()) { |
| 115 | + $feat-color: mdc-feature-create-target($query, color); |
| 116 | + |
30 | 117 | .mdc-notched-outline__leading,
|
31 | 118 | .mdc-notched-outline__notch,
|
32 | 119 | .mdc-notched-outline__trailing {
|
33 |
| - @include mdc-theme-prop(border-color, $color); |
| 120 | + @include mdc-feature-targets($feat-color) { |
| 121 | + @include mdc-theme-prop(border-color, $color); |
| 122 | + } |
34 | 123 | }
|
35 | 124 | }
|
36 | 125 |
|
37 |
| -@mixin mdc-notched-outline-stroke-width($width) { |
| 126 | +@mixin mdc-notched-outline-stroke-width($width, $query: mdc-feature-all()) { |
| 127 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 128 | + |
38 | 129 | .mdc-notched-outline__leading,
|
39 | 130 | .mdc-notched-outline__notch,
|
40 | 131 | .mdc-notched-outline__trailing {
|
41 |
| - border-width: $width; |
| 132 | + @include mdc-feature-targets($feat-structure) { |
| 133 | + border-width: $width; |
| 134 | + } |
42 | 135 | }
|
43 | 136 | }
|
44 | 137 |
|
|
47 | 140 | /// Use this when floating label is aligned to center to prevent label jump on focus.
|
48 | 141 | /// @param {Number} $stroke-width Stroke width of notched outline that needs to be offset.
|
49 | 142 | ///
|
50 |
| -@mixin mdc-notched-outline-notch-offset($stroke-width) { |
| 143 | +@mixin mdc-notched-outline-notch-offset($stroke-width, $query: mdc-feature-all()) { |
| 144 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 145 | + |
51 | 146 | .mdc-notched-outline--notched .mdc-notched-outline__notch {
|
52 |
| - padding-top: $stroke-width; |
| 147 | + @include mdc-feature-targets($feat-structure) { |
| 148 | + padding-top: $stroke-width; |
| 149 | + } |
53 | 150 | }
|
54 | 151 | }
|
55 | 152 |
|
56 |
| -@mixin mdc-notched-outline-shape-radius($radius, $rtl-reflexive: false) { |
| 153 | +@mixin mdc-notched-outline-shape-radius($radius, $rtl-reflexive: false, $query: mdc-feature-all()) { |
| 154 | + $feat-structure: mdc-feature-create-target($query, structure); |
57 | 155 | $radius: mdc-shape-prop-value($radius);
|
58 | 156 |
|
59 | 157 | @if (length($radius) > 1) {
|
|
64 | 162 | $radius: nth($radius, 1);
|
65 | 163 |
|
66 | 164 | .mdc-notched-outline__leading {
|
67 |
| - @include mdc-shape-radius(mdc-shape-mask-radius($radius, 1 0 0 1), $rtl-reflexive: true); |
| 165 | + @include mdc-shape-radius(mdc-shape-mask-radius($radius, 1 0 0 1), $rtl-reflexive: true, $query: $query); |
68 | 166 |
|
69 |
| - @if ($radius > $mdc-notched-outline-leading-width) { |
70 |
| - width: $radius; |
| 167 | + @include mdc-feature-targets($feat-structure) { |
| 168 | + @if ($radius > $mdc-notched-outline-leading-width) { |
| 169 | + width: $radius; |
| 170 | + } |
71 | 171 | }
|
72 | 172 | }
|
73 | 173 |
|
74 | 174 | @if ($radius > $mdc-notched-outline-leading-width) {
|
75 | 175 | .mdc-notched-outline__notch {
|
76 |
| - max-width: calc(100% - #{$radius} * 2); |
| 176 | + @include mdc-feature-targets($feat-structure) { |
| 177 | + max-width: calc(100% - #{$radius} * 2); |
| 178 | + } |
77 | 179 | }
|
78 | 180 | }
|
79 | 181 |
|
80 | 182 | .mdc-notched-outline__trailing {
|
81 |
| - @include mdc-shape-radius(mdc-shape-mask-radius($radius, 0 1 1 0), $rtl-reflexive: true); |
| 183 | + @include mdc-shape-radius(mdc-shape-mask-radius($radius, 0 1 1 0), $rtl-reflexive: true, $query: $query); |
82 | 184 | }
|
83 | 185 | }
|
84 | 186 |
|
85 |
| -@mixin mdc-notched-outline-floating-label-float-position($positionY, $positionX: 0%, $scale: .75) { |
86 |
| - @include mdc-floating-label-float-position($positionY + $mdc-notched-outline-label-adjust, $positionX, 1); |
| 187 | +@mixin mdc-notched-outline-floating-label-float-position( |
| 188 | + $positionY, $positionX: 0%, $scale: .75, $query: mdc-feature-all()) { |
| 189 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 190 | + |
| 191 | + @include mdc-floating-label-float-position( |
| 192 | + $positionY + $mdc-notched-outline-label-adjust, $positionX, 1, $query: $query); |
87 | 193 |
|
88 | 194 | .mdc-floating-label--float-above {
|
89 |
| - font-size: ($scale * 1rem); |
| 195 | + @include mdc-feature-targets($feat-structure) { |
| 196 | + font-size: ($scale * 1rem); |
| 197 | + } |
90 | 198 | }
|
91 | 199 |
|
92 | 200 | // Two selectors to ensure we select the appropriate class when applied from this component or a parent component.
|
93 | 201 | &.mdc-notched-outline--upgraded,
|
94 | 202 | .mdc-notched-outline--upgraded {
|
95 |
| - @include mdc-floating-label-float-position($positionY, $positionX, $scale); |
| 203 | + @include mdc-floating-label-float-position($positionY, $positionX, $scale, $query: $query); |
96 | 204 |
|
97 | 205 | // stylelint-disable-next-line no-descending-specificity
|
98 | 206 | .mdc-floating-label--float-above {
|
99 |
| - font-size: 1rem; |
| 207 | + @include mdc-feature-targets($feat-structure) { |
| 208 | + font-size: 1rem; |
| 209 | + } |
100 | 210 | }
|
101 | 211 | }
|
102 | 212 | }
|
|
111 | 221 | /// @todo Replace mixin `mdc-notched-outline-floating-label-float-position` with this mixin when floating label is
|
112 | 222 | /// center aligned in all the places.
|
113 | 223 | ///
|
114 |
| -@mixin mdc-notched-outline-floating-label-float-position-absolute($positionY, $positionX: 0, $scale: .75) { |
115 |
| - @include mdc-floating-label-float-position($positionY + $mdc-notched-outline-label-adjust-absolute, $positionX, 1); |
| 224 | +@mixin mdc-notched-outline-floating-label-float-position-absolute( |
| 225 | + $positionY, $positionX: 0, $scale: .75, $query: mdc-feature-all()) { |
| 226 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 227 | + |
| 228 | + @include mdc-floating-label-float-position( |
| 229 | + $positionY + $mdc-notched-outline-label-adjust-absolute, $positionX, 1, $query: $query); |
116 | 230 |
|
117 | 231 | .mdc-floating-label--float-above {
|
118 |
| - font-size: ($scale * 1rem); |
| 232 | + @include mdc-feature-targets($feat-structure) { |
| 233 | + font-size: ($scale * 1rem); |
| 234 | + } |
119 | 235 | }
|
120 | 236 |
|
121 | 237 | // Two selectors to ensure we select the appropriate class when applied from this component or a parent component.
|
122 | 238 | &.mdc-notched-outline--upgraded,
|
123 | 239 | .mdc-notched-outline--upgraded {
|
124 | 240 | @include mdc-floating-label-float-position(
|
125 |
| - $positionY, $positionX, $scale); |
| 241 | + $positionY, $positionX, $scale, $query: $query); |
126 | 242 |
|
127 | 243 | // stylelint-disable-next-line no-descending-specificity
|
128 | 244 | .mdc-floating-label--float-above {
|
129 |
| - font-size: 1rem; |
| 245 | + @include mdc-feature-targets($feat-structure) { |
| 246 | + font-size: 1rem; |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | +} |
| 251 | + |
| 252 | +// |
| 253 | +// Private |
| 254 | +// |
| 255 | +@mixin mdc-notched-outline-base_($query) { |
| 256 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 257 | + |
| 258 | + @include mdc-feature-targets($feat-structure) { |
| 259 | + display: flex; |
| 260 | + position: absolute; |
| 261 | + right: 0; |
| 262 | + left: 0; |
| 263 | + box-sizing: border-box; |
| 264 | + width: 100%; |
| 265 | + max-width: 100%; |
| 266 | + height: 100%; |
| 267 | + /* @noflip */ |
| 268 | + text-align: left; |
| 269 | + pointer-events: none; |
| 270 | + |
| 271 | + @include mdc-rtl { |
| 272 | + /* @noflip */ |
| 273 | + text-align: right; |
130 | 274 | }
|
131 | 275 | }
|
132 | 276 | }
|
0 commit comments