| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- //
- // Copyright 2019 Google Inc.
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- @use "@material/base/mixins" as base-mixins;
- @use "@material/feature-targeting/functions";
- @use "@material/feature-targeting/mixins" as feature-targeting-mixins;
- @use "./variables";
- /// Styles applied to the component's touch target wrapper element.
- @mixin wrapper($query: functions.all()) {
- $feat-structure: functions.create-target($query, structure);
- .mdc-touch-target-wrapper {
- @include feature-targeting-mixins.targets($feat-structure) {
- // Ensure that styles are only emitted once across all components that
- // have increased touch targets.
- @include base-mixins.emit-once("mdc-touch-target/wrapper") {
- // NOTE: Will change to `inline-block` in the future, but keeping as is
- // temporarily for backwards-compatibility.
- display: inline;
- }
- }
- }
- }
- /// Styles applied to the component's inner touch target element.
- /// By default, only sets the inner element height to the minimum touch target
- /// height ($mdc-touch-target-height).
- /// @param {Boolean} $set-width [false] - Sets the inner element width to the
- /// minimum touch target width ($mdc-touch-target-width).
- @mixin touch-target($set-width: false, $query: functions.all()) {
- $feat-structure: functions.create-target($query, structure);
- @include feature-targeting-mixins.targets($feat-structure) {
- position: absolute;
- top: 50%;
- right: 0;
- height: variables.$height;
- }
- @if $set-width {
- @include feature-targeting-mixins.targets($feat-structure) {
- /* @noflip */
- left: 50%;
- width: variables.$width;
- transform: translate(-50%, -50%);
- }
- } @else {
- @include feature-targeting-mixins.targets($feat-structure) {
- left: 0;
- transform: translateY(-50%);
- }
- }
- }
- /// Applies margin to the component with the increased touch target,
- /// to compensate for the touch target.
- @mixin margin($component-height, $component-width: null, $query: functions.all()) {
- $feat-structure: functions.create-target($query, structure);
- $vertical-margin-value: (variables.$height - $component-height) / 2;
- @include feature-targeting-mixins.targets($feat-structure) {
- margin-top: $vertical-margin-value;
- margin-bottom: $vertical-margin-value;
- }
- @if $component-width {
- $horizontal-margin-value: (variables.$width - $component-width) / 2;
- @include feature-targeting-mixins.targets($feat-structure) {
- margin-right: $horizontal-margin-value;
- margin-left: $horizontal-margin-value;
- }
- }
- }
|