UNPKG

5.67 kBSCSSView Raw
1//
2// Copyright 2020 Google Inc.
3//
4// Permission is hereby granted, free of charge, to any person obtaining a copy
5// of this software and associated documentation files (the "Software"), to deal
6// in the Software without restriction, including without limitation the rights
7// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8// copies of the Software, and to permit persons to whom the Software is
9// furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20// THE SOFTWARE.
21//
22
23// stylelint-disable selector-class-pattern --
24// Selector '.mdc-*' should only be used in this project.
25
26@use '@material/feature-targeting/feature-targeting';
27@use '@material/ripple/ripple';
28@use '@material/ripple/ripple-theme';
29@use '@material/rtl/mixins' as rtl;
30@use '@material/theme/theme';
31@use '@material/touch-target/mixins' as touch;
32@use './variables';
33
34$ripple-target: '.mdc-deprecated-chip-trailing-action__ripple';
35
36@mixin core-styles($query: feature-targeting.all()) {
37 @include without-ripple($query: $query);
38 @include ripple($query: $query);
39}
40
41@mixin without-ripple($query: feature-targeting.all()) {
42 $feat-structure: feature-targeting.create-target($query, structure);
43 $feat-color: feature-targeting.create-target($query, color);
44
45 @include touch.wrapper($query); // COPYBARA_COMMENT_THIS_LINE
46 @include _touch-target-base($query);
47
48 .mdc-deprecated-chip-trailing-action {
49 @include size(variables.$size, $query);
50 @include color(variables.$color, $query);
51 @include touch-target-width(variables.$touch-target-width, $query);
52
53 @include feature-targeting.targets($feat-structure) {
54 border: none;
55 display: inline-flex;
56 position: relative;
57 align-items: center;
58 justify-content: center;
59 box-sizing: border-box;
60 padding: 0;
61 outline: none;
62 cursor: pointer;
63 -webkit-appearance: none;
64 }
65
66 @include feature-targeting.targets($feat-color) {
67 background: none;
68 }
69
70 // Nested to increase specificity, ensuring SVG and font icon
71 // color is affected regardless of load order without needing
72 // !important or HTML tag targetting.
73 .mdc-deprecated-chip-trailing-action__icon {
74 @include feature-targeting.targets($feat-color) {
75 fill: currentColor;
76 color: inherit;
77 }
78 }
79 }
80}
81
82@mixin ripple($query: feature-targeting.all()) {
83 @include ripple.common($query); // COPYBARA_COMMENT_THIS_LINE
84 $feat-structure: feature-targeting.create-target($query, structure);
85
86 .mdc-deprecated-chip-trailing-action {
87 @include ripple.surface($query: $query, $ripple-target: $ripple-target);
88 @include ripple.radius-unbounded(
89 $query: $query,
90 $ripple-target: $ripple-target
91 );
92 @include ripple-theme.states(
93 variables.$ripple-color,
94 $query: $query,
95 $ripple-target: $ripple-target
96 );
97
98 #{$ripple-target} {
99 @include feature-targeting.targets($feat-structure) {
100 position: absolute;
101 // Ripple needs content-box as the box sizing and box-sizing: border-box
102 // is often set as a default, so we override that here.
103 box-sizing: content-box;
104 width: 100%;
105 height: 100%;
106 overflow: hidden;
107 }
108 }
109 }
110}
111
112/// Set the color of the trailing action
113/// @param {Color} $color The trailing action color
114@mixin color($color, $query: feature-targeting.all()) {
115 $feat-color: feature-targeting.create-target($query, color);
116
117 .mdc-deprecated-chip-trailing-action {
118 @include feature-targeting.targets($feat-color) {
119 @include theme.property(color, $color);
120 }
121 }
122}
123
124/// Set the size of the trailing action
125/// @param {Number} $number The size of the trailing action
126@mixin size($size, $query: feature-targeting.all()) {
127 $feat-structure: feature-targeting.create-target($query, structure);
128
129 .mdc-deprecated-chip-trailing-action__icon {
130 @include feature-targeting.targets($feat-structure) {
131 height: $size;
132 width: $size;
133 font-size: $size;
134 }
135 }
136}
137
138/// Set the horizontal spacing of the trailing action
139/// @param {Number} $left The left spacing
140/// @param {Number} $right The right spacing
141@mixin horizontal-spacing($left, $right, $query: feature-targeting.all()) {
142 $feat-structure: feature-targeting.create-target($query, structure);
143
144 .mdc-deprecated-chip-trailing-action {
145 @include feature-targeting.targets($feat-structure) {
146 @include rtl.reflexive-property(margin, $left, $right);
147 }
148 }
149}
150
151/// Set the width of the touch target
152/// @param {Number} $width The width of the touch target
153@mixin touch-target-width($width, $query: feature-targeting.all()) {
154 $feat-structure: feature-targeting.create-target($query, structure);
155
156 .mdc-deprecated-chip-trailing-action__touch {
157 @include feature-targeting.targets($feat-structure) {
158 width: $width;
159 }
160 }
161}
162
163/// Private mixins
164
165@mixin _touch-target-base($query: feature-targeting.all()) {
166 .mdc-deprecated-chip-trailing-action__touch {
167 @include touch.touch-target($set-width: true, $query: $query);
168 }
169}