|
20 | 20 | // THE SOFTWARE. |
21 | 21 | // |
22 | 22 |
|
23 | | -@import "../theme/mixins"; |
| 23 | +@import "../elevation/mixins"; |
| 24 | +@import "../featuretargeting/functions"; |
| 25 | +@import "../featuretargeting/mixins"; |
| 26 | +@import "../ripple/mixins"; |
| 27 | +@import "../rtl/mixins"; |
24 | 28 | @import "../shape/mixins"; |
| 29 | +@import "../theme/mixins"; |
25 | 30 | @import "./variables"; |
26 | 31 |
|
27 | 32 | // |
28 | 33 | // Public |
29 | 34 | // |
30 | 35 |
|
31 | | -@mixin mdc-card-fill-color($color) { |
32 | | - @include mdc-theme-prop(background-color, $color); |
| 36 | +@mixin mdc-card($query: mdc-feature-all()) { |
| 37 | + // postcss-bem-linter: define card |
| 38 | + |
| 39 | + $feat-color: mdc-feature-create-target($query, color); |
| 40 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 41 | + |
| 42 | + .mdc-card { |
| 43 | + @include mdc-card-shape-radius(medium, $query: $query); |
| 44 | + @include mdc-card-fill-color(surface, $query); |
| 45 | + @include mdc-elevation(1, $query: $query); |
| 46 | + |
| 47 | + @include mdc-feature-targets($feat-structure) { |
| 48 | + @include mdc-card-container-layout_; |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + .mdc-card--outlined { |
| 53 | + @include mdc-elevation(0, $query: $query); |
| 54 | + @include mdc-card-outline($mdc-card-outline-color, $query: $query); |
| 55 | + } |
| 56 | + |
| 57 | + // |
| 58 | + // Media |
| 59 | + // |
| 60 | + |
| 61 | + .mdc-card__media { |
| 62 | + @include mdc-feature-targets($feat-structure) { |
| 63 | + position: relative; // Child element `__media-content` has `position: absolute` |
| 64 | + box-sizing: border-box; |
| 65 | + background-repeat: no-repeat; |
| 66 | + background-position: center; |
| 67 | + background-size: cover; |
| 68 | + } |
| 69 | + |
| 70 | + &::before { |
| 71 | + @include mdc-feature-targets($feat-structure) { |
| 72 | + display: block; |
| 73 | + content: ""; |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + .mdc-card__media:first-child { |
| 79 | + @include mdc-feature-targets($feat-structure) { |
| 80 | + border-top-left-radius: inherit; |
| 81 | + border-top-right-radius: inherit; |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + .mdc-card__media:last-child { |
| 86 | + @include mdc-feature-targets($feat-structure) { |
| 87 | + border-bottom-left-radius: inherit; |
| 88 | + border-bottom-right-radius: inherit; |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + .mdc-card__media--square { |
| 93 | + @include mdc-card-media-aspect-ratio(1, 1, $query); |
| 94 | + } |
| 95 | + |
| 96 | + .mdc-card__media--16-9 { |
| 97 | + @include mdc-card-media-aspect-ratio(16, 9, $query); |
| 98 | + } |
| 99 | + |
| 100 | + .mdc-card__media-content { |
| 101 | + @include mdc-feature-targets($feat-structure) { |
| 102 | + position: absolute; |
| 103 | + top: 0; |
| 104 | + right: 0; |
| 105 | + bottom: 0; |
| 106 | + left: 0; |
| 107 | + box-sizing: border-box; |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + // |
| 112 | + // Primary action |
| 113 | + // |
| 114 | + |
| 115 | + .mdc-card__primary-action { |
| 116 | + @include mdc-ripple-surface($query); |
| 117 | + @include mdc-ripple-radius-bounded($query: $query); |
| 118 | + |
| 119 | + @include mdc-feature-targets($feat-structure) { |
| 120 | + @include mdc-card-container-layout_; |
| 121 | + |
| 122 | + position: relative; // Needed to prevent the ripple wash from overflowing the container in IE and Edge |
| 123 | + outline: none; |
| 124 | + color: inherit; |
| 125 | + text-decoration: none; |
| 126 | + cursor: pointer; |
| 127 | + overflow: hidden; |
| 128 | + } |
| 129 | + |
| 130 | + @include mdc-states($query: $query); |
| 131 | + } |
| 132 | + |
| 133 | + .mdc-card__primary-action:first-child { |
| 134 | + @include mdc-feature-targets($feat-structure) { |
| 135 | + border-top-left-radius: inherit; |
| 136 | + border-top-right-radius: inherit; |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + .mdc-card__primary-action:last-child { |
| 141 | + @include mdc-feature-targets($feat-structure) { |
| 142 | + border-bottom-left-radius: inherit; |
| 143 | + border-bottom-right-radius: inherit; |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + // |
| 148 | + // Action row |
| 149 | + // |
| 150 | + |
| 151 | + .mdc-card__actions { |
| 152 | + @include mdc-feature-targets($feat-structure) { |
| 153 | + @include mdc-card-actions-layout_; |
| 154 | + |
| 155 | + min-height: 52px; |
| 156 | + padding: 8px; |
| 157 | + } |
| 158 | + } |
| 159 | + |
| 160 | + .mdc-card__actions--full-bleed { |
| 161 | + @include mdc-feature-targets($feat-structure) { |
| 162 | + padding: 0; |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + .mdc-card__action-buttons, |
| 167 | + .mdc-card__action-icons { |
| 168 | + @include mdc-feature-targets($feat-structure) { |
| 169 | + @include mdc-card-actions-layout_; |
| 170 | + } |
| 171 | + } |
| 172 | + |
| 173 | + .mdc-card__action-icons { |
| 174 | + @include mdc-feature-targets($feat-color) { |
| 175 | + @include mdc-theme-prop(color, text-icon-on-background); |
| 176 | + } |
| 177 | + |
| 178 | + @include mdc-feature-targets($feat-structure) { |
| 179 | + flex-grow: 1; |
| 180 | + justify-content: flex-end; |
| 181 | + } |
| 182 | + } |
| 183 | + |
| 184 | + .mdc-card__action-buttons + .mdc-card__action-icons { |
| 185 | + @include mdc-feature-targets($feat-structure) { |
| 186 | + @include mdc-rtl-reflexive-box(margin, left, 16px); |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + // |
| 191 | + // Action items |
| 192 | + // |
| 193 | + |
| 194 | + .mdc-card__action { |
| 195 | + @include mdc-feature-targets($feat-structure) { |
| 196 | + @include mdc-card-actions-layout_(inline-flex); |
| 197 | + |
| 198 | + justify-content: center; |
| 199 | + cursor: pointer; |
| 200 | + user-select: none; |
| 201 | + } |
| 202 | + |
| 203 | + &:focus { |
| 204 | + @include mdc-feature-targets($feat-structure) { |
| 205 | + outline: none; |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | + |
| 210 | + // |
| 211 | + // Action buttons |
| 212 | + // |
| 213 | + |
| 214 | + .mdc-card__action--button { |
| 215 | + @include mdc-feature-targets($feat-structure) { |
| 216 | + @include mdc-rtl-reflexive-box(margin, right, 8px); |
| 217 | + |
| 218 | + padding: 0 8px; |
| 219 | + } |
| 220 | + |
| 221 | + &:last-child { |
| 222 | + @include mdc-feature-targets($feat-structure) { |
| 223 | + @include mdc-rtl-reflexive-box(margin, right, 0); |
| 224 | + } |
| 225 | + } |
| 226 | + } |
| 227 | + |
| 228 | + .mdc-card__actions--full-bleed .mdc-card__action--button { |
| 229 | + @include mdc-feature-targets($feat-structure) { |
| 230 | + justify-content: space-between; |
| 231 | + width: 100%; |
| 232 | + height: auto; |
| 233 | + max-height: none; |
| 234 | + margin: 0; |
| 235 | + padding: 8px 16px; |
| 236 | + /* @noflip */ |
| 237 | + text-align: left; |
| 238 | + } |
| 239 | + |
| 240 | + @include mdc-rtl { |
| 241 | + @include mdc-feature-targets($feat-structure) { |
| 242 | + /* @noflip */ |
| 243 | + text-align: right; |
| 244 | + } |
| 245 | + } |
| 246 | + } |
| 247 | + |
| 248 | + // |
| 249 | + // Action icons |
| 250 | + // |
| 251 | + |
| 252 | + .mdc-card__action--icon { |
| 253 | + @include mdc-feature-targets($feat-structure) { |
| 254 | + // Icon toggles are taller than buttons, so we need to adjust their margins to prevent the action row from expanding. |
| 255 | + margin: -6px 0; |
| 256 | + |
| 257 | + // Same padding as mdc-icon-button. |
| 258 | + padding: 12px; |
| 259 | + } |
| 260 | + } |
| 261 | + |
| 262 | + .mdc-card__action--icon:not(:disabled) { |
| 263 | + @include mdc-feature-targets($feat-color) { |
| 264 | + @include mdc-theme-prop(color, text-icon-on-background); |
| 265 | + } |
| 266 | + } |
| 267 | + |
| 268 | + // postcss-bem-linter: end |
33 | 269 | } |
34 | 270 |
|
35 | | -@mixin mdc-card-outline($color, $thickness: $mdc-card-outline-width) { |
36 | | - border: $thickness solid mdc-theme-prop-value($color); |
| 271 | +@mixin mdc-card-fill-color($color, $query: mdc-feature-all()) { |
| 272 | + $feat-color: mdc-feature-create-target($query, color); |
| 273 | + |
| 274 | + @include mdc-feature-targets($feat-color) { |
| 275 | + @include mdc-theme-prop(background-color, $color); |
| 276 | + } |
| 277 | +} |
| 278 | + |
| 279 | +@mixin mdc-card-outline($color, $thickness: $mdc-card-outline-width, $query: mdc-feature-all()) { |
| 280 | + $feat-color: mdc-feature-create-target($query, color); |
| 281 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 282 | + |
| 283 | + @include mdc-feature-targets($feat-structure) { |
| 284 | + border-width: $thickness; |
| 285 | + border-style: solid; |
| 286 | + } |
| 287 | + |
| 288 | + @include mdc-feature-targets($feat-color) { |
| 289 | + border-color: mdc-theme-prop-value($color); |
| 290 | + } |
37 | 291 | } |
38 | 292 |
|
39 | | -@mixin mdc-card-shape-radius($radius, $rtl-reflexive: false) { |
40 | | - @include mdc-shape-radius($radius, $rtl-reflexive); |
| 293 | +@mixin mdc-card-shape-radius($radius, $rtl-reflexive: false, $query: mdc-feature-all()) { |
| 294 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 295 | + |
| 296 | + @include mdc-feature-targets($feat-structure) { |
| 297 | + @include mdc-shape-radius($radius, $rtl-reflexive); |
| 298 | + } |
41 | 299 | } |
42 | 300 |
|
43 | | -@mixin mdc-card-media-aspect-ratio($x, $y) { |
| 301 | +@mixin mdc-card-media-aspect-ratio($x, $y, $query: mdc-feature-all()) { |
| 302 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 303 | + |
44 | 304 | &::before { |
45 | | - // This clever trick brought to you by: http://www.mademyday.de/css-height-equals-width-with-pure-css.html |
46 | | - margin-top: percentage($y / $x); |
| 305 | + @include mdc-feature-targets($feat-structure) { |
| 306 | + // This clever trick brought to you by: http://www.mademyday.de/css-height-equals-width-with-pure-css.html |
| 307 | + margin-top: percentage($y / $x); |
| 308 | + } |
47 | 309 | } |
48 | 310 | } |
49 | 311 |
|
|
63 | 325 | align-items: center; |
64 | 326 | box-sizing: border-box; |
65 | 327 | } |
66 | | - |
67 | | -@mixin mdc-card-media-aspect-ratio-base_ { |
68 | | - &::before { |
69 | | - display: block; |
70 | | - content: ""; |
71 | | - } |
72 | | -} |
|
0 commit comments