|
18 | 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19 | 19 | // THE SOFTWARE.
|
20 | 20 |
|
| 21 | +@import "@material/feature-targeting/functions"; |
| 22 | +@import "@material/feature-targeting/mixins"; |
21 | 23 | @import "@material/shape/mixins";
|
22 | 24 | @import "@material/shape/functions";
|
| 25 | +@import "@material/theme/mixins"; |
| 26 | +@import "@material/typography/mixins"; |
23 | 27 | @import "./variables";
|
24 | 28 |
|
25 |
| -@mixin mdc-image-list-aspect($width-height-ratio) { |
| 29 | +@mixin mdc-image-list-core-styles($query: mdc-feature-all()) { |
| 30 | + $feat-color: mdc-feature-create-target($query, color); |
| 31 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 32 | + |
| 33 | + // postcss-bem-linter: define image-list |
| 34 | + .mdc-image-list { |
| 35 | + @include mdc-feature-targets($feat-structure) { |
| 36 | + display: flex; |
| 37 | + flex-wrap: wrap; |
| 38 | + // Margin and padding are set to override default user agent styles for lists, and also to center the Image List |
| 39 | + margin: 0 auto; |
| 40 | + padding: 0; |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + .mdc-image-list__item, |
| 45 | + .mdc-image-list__image-aspect-container { |
| 46 | + @include mdc-feature-targets($feat-structure) { |
| 47 | + // Supports absolute positioning of protected supporting content for item, and image for image-aspect-container |
| 48 | + position: relative; |
| 49 | + box-sizing: border-box; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + .mdc-image-list__item { |
| 54 | + @include mdc-feature-targets($feat-structure) { |
| 55 | + list-style-type: none; |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + .mdc-image-list__image { |
| 60 | + @include mdc-feature-targets($feat-structure) { |
| 61 | + width: 100%; |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + // Descendant selector allows image-aspect-container to be optional in DOM structure |
| 66 | + .mdc-image-list__image-aspect-container .mdc-image-list__image { |
| 67 | + @include mdc-feature-targets($feat-structure) { |
| 68 | + position: absolute; |
| 69 | + top: 0; |
| 70 | + right: 0; |
| 71 | + bottom: 0; |
| 72 | + left: 0; |
| 73 | + height: 100%; |
| 74 | + // Background styles to support div instead of img |
| 75 | + background-repeat: no-repeat; |
| 76 | + background-position: center; |
| 77 | + background-size: cover; |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + @include mdc-image-list-aspect(1, $query: $query); |
| 82 | + @include mdc-image-list-shape-radius(0, $query: $query); |
| 83 | + |
| 84 | + .mdc-image-list__supporting { |
| 85 | + @include mdc-feature-targets($feat-color) { |
| 86 | + @include mdc-theme-prop(color, text-primary-on-background); |
| 87 | + } |
| 88 | + |
| 89 | + @include mdc-feature-targets($feat-structure) { |
| 90 | + display: flex; |
| 91 | + align-items: center; |
| 92 | + justify-content: space-between; |
| 93 | + box-sizing: border-box; |
| 94 | + padding: 8px 0; |
| 95 | + line-height: $mdc-image-list-icon-size; |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + .mdc-image-list__label { |
| 100 | + @include mdc-typography(subtitle1, $query: $query); |
| 101 | + @include mdc-typography-overflow-ellipsis($query: $query); |
| 102 | + } |
| 103 | + |
| 104 | + // Modifier for labels/icons with text protection, overlaying images. |
| 105 | + |
| 106 | + .mdc-image-list--with-text-protection .mdc-image-list__supporting { |
| 107 | + @include mdc-feature-targets($feat-structure) { |
| 108 | + position: absolute; |
| 109 | + bottom: 0; |
| 110 | + width: 100%; |
| 111 | + height: $mdc-image-list-text-protection-height; |
| 112 | + padding: 0 $mdc-image-list-text-protection-horizontal-padding; |
| 113 | + } |
| 114 | + |
| 115 | + @include mdc-feature-targets($feat-color) { |
| 116 | + background: $mdc-image-list-text-protection-background-color; |
| 117 | + color: #fff; |
| 118 | + } |
| 119 | + } |
| 120 | + |
| 121 | + // Masonry Image List, using CSS columns (i.e. renders down then across) |
| 122 | + |
| 123 | + .mdc-image-list--masonry { |
| 124 | + @include mdc-feature-targets($feat-structure) { |
| 125 | + display: block; // Override flex |
| 126 | + } |
| 127 | + |
| 128 | + .mdc-image-list__item { |
| 129 | + @include mdc-feature-targets($feat-structure) { |
| 130 | + break-inside: avoid-column; |
| 131 | + } |
| 132 | + } |
| 133 | + |
| 134 | + .mdc-image-list__image { |
| 135 | + @include mdc-feature-targets($feat-structure) { |
| 136 | + display: block; |
| 137 | + height: auto; |
| 138 | + } |
| 139 | + } |
| 140 | + } |
| 141 | + // postcss-bem-linter: end |
| 142 | +} |
| 143 | + |
| 144 | +@mixin mdc-image-list-aspect($width-height-ratio, $query: mdc-feature-all()) { |
| 145 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 146 | + |
26 | 147 | .mdc-image-list__image-aspect-container {
|
27 |
| - padding-bottom: calc(100% / #{$width-height-ratio}); |
| 148 | + @include mdc-feature-targets($feat-structure) { |
| 149 | + padding-bottom: calc(100% / #{$width-height-ratio}); |
| 150 | + } |
28 | 151 | }
|
29 | 152 | }
|
30 | 153 |
|
31 |
| -@mixin mdc-image-list-shape-radius($radius, $rtl-reflexive: false) { |
| 154 | +@mixin mdc-image-list-shape-radius($radius, $rtl-reflexive: false, $query: mdc-feature-all()) { |
32 | 155 | .mdc-image-list__image {
|
33 |
| - @include mdc-shape-radius($radius, $rtl-reflexive); |
| 156 | + @include mdc-shape-radius($radius, $rtl-reflexive, $query: $query); |
34 | 157 | }
|
35 | 158 |
|
36 | 159 | $selector: if(&, "&.mdc-image-list--with-text-protection", ".mdc-image-list--with-text-protection");
|
37 | 160 |
|
38 | 161 | #{$selector} .mdc-image-list__supporting {
|
39 | 162 | $masked-radius: mdc-shape-mask-radius($radius, 0 0 1 1);
|
40 | 163 |
|
41 |
| - @include mdc-shape-radius($masked-radius, $rtl-reflexive); |
| 164 | + @include mdc-shape-radius($masked-radius, $rtl-reflexive, $query: $query); |
42 | 165 | }
|
43 | 166 | }
|
44 | 167 |
|
45 | 168 | // Standard Image List
|
46 | 169 |
|
47 |
| -@mixin mdc-image-list-standard-columns($column-count, $gutter-size: $mdc-image-list-standard-gutter-size) { |
| 170 | +@mixin mdc-image-list-standard-columns( |
| 171 | + $column-count, |
| 172 | + $gutter-size: $mdc-image-list-standard-gutter-size, |
| 173 | + $query: mdc-feature-all() |
| 174 | +) { |
| 175 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 176 | + |
48 | 177 | // This uses margin rather than padding to facilitate properly positioning the supporting content element when
|
49 | 178 | // --with-text-protection is used.
|
50 | 179 | .mdc-image-list__item {
|
51 |
| - // Subtract extra fraction from each item's width to ensure correct wrapping in IE and Edge which round differently |
52 |
| - width: calc(100% / #{$column-count} - #{$gutter-size + 1 / $column-count}); |
53 |
| - margin: $gutter-size / 2; |
| 180 | + @include mdc-feature-targets($feat-structure) { |
| 181 | + // Subtract extra fraction from each item's width to ensure correct wrapping in IE/Edge which round differently |
| 182 | + width: calc(100% / #{$column-count} - #{$gutter-size + 1 / $column-count}); |
| 183 | + margin: $gutter-size / 2; |
| 184 | + } |
54 | 185 | }
|
55 | 186 | }
|
56 | 187 |
|
57 | 188 | // Masonry Image List
|
58 | 189 |
|
59 |
| -@mixin mdc-image-list-masonry-columns($column-count, $gutter-size: $mdc-image-list-masonry-gutter-size) { |
60 |
| - column-count: $column-count; |
61 |
| - column-gap: $gutter-size; |
| 190 | +@mixin mdc-image-list-masonry-columns( |
| 191 | + $column-count, |
| 192 | + $gutter-size: $mdc-image-list-masonry-gutter-size, |
| 193 | + $query: mdc-feature-all() |
| 194 | +) { |
| 195 | + $feat-structure: mdc-feature-create-target($query, structure); |
| 196 | + |
| 197 | + @include mdc-feature-targets($feat-structure) { |
| 198 | + column-count: $column-count; |
| 199 | + column-gap: $gutter-size; |
| 200 | + } |
62 | 201 |
|
63 | 202 | .mdc-image-list__item {
|
64 |
| - margin-bottom: $gutter-size; |
| 203 | + @include mdc-feature-targets($feat-structure) { |
| 204 | + margin-bottom: $gutter-size; |
| 205 | + } |
65 | 206 | }
|
66 | 207 | }
|
0 commit comments