|
27 | 27 | @use '@material/base/mixins' as base-mixins;
|
28 | 28 | @use '@material/feature-targeting/feature-targeting';
|
29 | 29 | @use '@material/rtl/rtl';
|
| 30 | +@use '@material/theme/theme'; |
| 31 | +@use '@material/theme/keys'; |
| 32 | +@use '@material/theme/custom-properties'; |
30 | 33 |
|
31 | 34 | $height: 48px !default;
|
32 | 35 | $width: $height !default;
|
@@ -96,22 +99,73 @@ $width: $height !default;
|
96 | 99 | ) {
|
97 | 100 | $feat-structure: feature-targeting.create-target($query, structure);
|
98 | 101 |
|
99 |
| - $vertical-margin-value: math.div($touch-target-height - $component-height, 2); |
100 |
| - |
101 | 102 | @include feature-targeting.targets($feat-structure) {
|
102 |
| - margin-top: $vertical-margin-value; |
103 |
| - margin-bottom: $vertical-margin-value; |
| 103 | + @if keys.is-key($touch-target-height) or |
| 104 | + keys.is-key($component-height) or |
| 105 | + custom-properties.is-custom-prop($touch-target-height) or |
| 106 | + custom-properties.is-custom-prop($component-height) |
| 107 | + { |
| 108 | + // Custom properties |
| 109 | + @include theme.property( |
| 110 | + margin-top, |
| 111 | + 'max((touch-target-height - component-height) / 2, 0px)', |
| 112 | + $replace: ( |
| 113 | + component-height: $component-height, |
| 114 | + touch-target-height: $touch-target-height |
| 115 | + ) |
| 116 | + ); |
| 117 | + @include theme.property( |
| 118 | + margin-bottom, |
| 119 | + 'max((touch-target-height - component-height) / 2, 0px)', |
| 120 | + $replace: ( |
| 121 | + component-height: $component-height, |
| 122 | + touch-target-height: $touch-target-height |
| 123 | + ) |
| 124 | + ); |
| 125 | + } @else { |
| 126 | + // Static values |
| 127 | + $vertical-margin-value: math.div( |
| 128 | + $touch-target-height - $component-height, |
| 129 | + 2 |
| 130 | + ); |
| 131 | + margin-top: $vertical-margin-value; |
| 132 | + margin-bottom: $vertical-margin-value; |
| 133 | + } |
104 | 134 | }
|
105 | 135 |
|
106 | 136 | @if $component-width {
|
107 |
| - $horizontal-margin-value: math.div( |
108 |
| - $touch-target-width - $component-width, |
109 |
| - 2 |
110 |
| - ); |
111 |
| - |
112 | 137 | @include feature-targeting.targets($feat-structure) {
|
113 |
| - margin-right: $horizontal-margin-value; |
114 |
| - margin-left: $horizontal-margin-value; |
| 138 | + @if keys.is-key($touch-target-width) or |
| 139 | + keys.is-key($component-width) or |
| 140 | + custom-properties.is-custom-prop($touch-target-width) or |
| 141 | + custom-properties.is-custom-prop($component-width) |
| 142 | + { |
| 143 | + // Custom properties |
| 144 | + @include theme.property( |
| 145 | + margin-right, |
| 146 | + 'max((touch-target-width - component-width) / 2, 0px)', |
| 147 | + $replace: ( |
| 148 | + component-width: $component-width, |
| 149 | + touch-target-width: $touch-target-width |
| 150 | + ) |
| 151 | + ); |
| 152 | + @include theme.property( |
| 153 | + margin-left, |
| 154 | + 'max((touch-target-width - component-width) / 2), 0px', |
| 155 | + $replace: ( |
| 156 | + component-width: $component-width, |
| 157 | + touch-target-width: $touch-target-width |
| 158 | + ) |
| 159 | + ); |
| 160 | + } @else { |
| 161 | + // Static values |
| 162 | + $horizontal-margin-value: math.div( |
| 163 | + $touch-target-width - $component-width, |
| 164 | + 2 |
| 165 | + ); |
| 166 | + margin-right: $horizontal-margin-value; |
| 167 | + margin-left: $horizontal-margin-value; |
| 168 | + } |
115 | 169 | }
|
116 | 170 | }
|
117 | 171 | }
|
0 commit comments