1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | @use 'sass:map';
|
27 | @use 'sass:math';
|
28 | @use '@material/feature-targeting/feature-targeting';
|
29 | @use '@material/theme/custom-properties';
|
30 | @use '@material/theme/keys';
|
31 | @use '@material/theme/state';
|
32 | @use '@material/theme/theme';
|
33 | @use '@material/theme/theme-color';
|
34 | @use '@material/tokens/resolvers';
|
35 | @use '@material/ripple/ripple-theme';
|
36 | @use './button-base';
|
37 | @use './button-shared-theme';
|
38 | @use './button-ripple';
|
39 |
|
40 | $outlined-border-width: 1px !default;
|
41 | $outline-color: rgba(theme-color.prop-value(on-surface), 0.12) !default;
|
42 |
|
43 | $_custom-property-prefix: 'outlined-button';
|
44 |
|
45 | $light-theme: (
|
46 | container-height: button-shared-theme.$height,
|
47 | container-shape: button-shared-theme.$shape-radius,
|
48 | disabled-label-text-color: button-shared-theme.$disabled-ink-color,
|
49 | disabled-outline-color: button-shared-theme.$disabled-container-color,
|
50 | focus-label-text-color: null,
|
51 | focus-outline-color: null,
|
52 | focus-state-layer-color: primary,
|
53 | focus-state-layer-opacity: 0.12,
|
54 | hover-label-text-color: null,
|
55 | hover-outline-color: null,
|
56 | hover-state-layer-color: primary,
|
57 | hover-state-layer-opacity: 0.04,
|
58 | label-text-color: primary,
|
59 | label-text-font: button-font-family,
|
60 | label-text-size: button-font-size,
|
61 | label-text-tracking: button-letter-spacing,
|
62 | label-text-transform: button-text-transform,
|
63 | label-text-weight: button-font-weight,
|
64 | outline-color: $outline-color,
|
65 | outline-width: $outlined-border-width,
|
66 | pressed-label-text-color: null,
|
67 | pressed-state-layer-color: primary,
|
68 | pressed-state-layer-opacity: 0.12,
|
69 | with-icon-icon-color: null,
|
70 | with-icon-icon-size: 18px,
|
71 | with-icon-hover-icon-color: null,
|
72 | with-icon-focus-icon-color: null,
|
73 | with-icon-pressed-icon-color: null,
|
74 | with-icon-disabled-icon-color: null,
|
75 | );
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | @mixin theme($theme, $resolver: resolvers.$material) {
|
81 | @include theme.validate-theme($light-theme, $theme);
|
82 | $theme: button-shared-theme.resolve-theme-elevation-keys(
|
83 | $theme,
|
84 | $resolver: $resolver
|
85 | );
|
86 | @include keys.declare-custom-properties($theme, $_custom-property-prefix);
|
87 | }
|
88 |
|
89 | @mixin theme-styles(
|
90 | $theme,
|
91 | $resolver: resolvers.$material,
|
92 | $query: feature-targeting.all()
|
93 | ) {
|
94 | @include theme.validate-theme-keys($light-theme, $theme);
|
95 | $theme: keys.create-theme-properties(
|
96 | $theme,
|
97 | $prefix: $_custom-property-prefix
|
98 | );
|
99 | @include _theme($theme, $resolver, $query: $query);
|
100 | }
|
101 |
|
102 | @mixin _theme($theme, $resolver, $query) {
|
103 | @include button-shared-theme.theme($theme, $resolver, $query: $query);
|
104 | @include outline-color(
|
105 | (
|
106 | default: map.get($theme, outline-color),
|
107 | disabled: map.get($theme, disabled-outline-color),
|
108 | focus: map.get($theme, focus-outline-color),
|
109 | hover: map.get($theme, hover-outline-color),
|
110 | ),
|
111 | $query: $query
|
112 | );
|
113 | @include outline-width(map.get($theme, outline-width), $query: $query);
|
114 | }
|
115 |
|
116 | @mixin deprecated-theme-styles($query: feature-targeting.all()) {
|
117 | .mdc-button--outlined {
|
118 | $theme: map.merge(
|
119 | $light-theme,
|
120 | (
|
121 | focus-state-layer-color: null,
|
122 | focus-state-layer-opacity: null,
|
123 | hover-state-layer-color: null,
|
124 | hover-state-layer-opacity: null,
|
125 | pressed-state-layer-color: null,
|
126 | pressed-state-layer-opacity: null,
|
127 | label-text-font: null,
|
128 | label-text-size: null,
|
129 | label-text-tracking: null,
|
130 | label-text-transform: null,
|
131 | label-text-weight: null,
|
132 | )
|
133 | );
|
134 | @include _theme($theme, resolvers.$material, $query: $query);
|
135 | }
|
136 | }
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | @mixin outline-color($color-or-map, $query: feature-targeting.all()) {
|
145 | &:not(:disabled) {
|
146 | @include _outline-color(
|
147 | state.get-default-state($color-or-map),
|
148 | $query: $query
|
149 | );
|
150 |
|
151 | &:hover {
|
152 | @include _outline-color(
|
153 | state.get-hover-state($color-or-map),
|
154 | $query: $query
|
155 | );
|
156 | }
|
157 |
|
158 | @include ripple-theme.focus() {
|
159 | @include _outline-color(
|
160 | state.get-focus-state($color-or-map),
|
161 | $query: $query
|
162 | );
|
163 | }
|
164 |
|
165 |
|
166 | &:active,
|
167 | &:focus:active {
|
168 | @include _outline-color(
|
169 | state.get-pressed-state($color-or-map),
|
170 | $query: $query
|
171 | );
|
172 | }
|
173 | }
|
174 |
|
175 | &:disabled {
|
176 | @include _outline-color(
|
177 | state.get-disabled-state($color-or-map),
|
178 | $query: $query
|
179 | );
|
180 | }
|
181 | }
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | @mixin disabled-outline-color($color, $query: feature-targeting.all()) {
|
189 | @include outline-color(
|
190 | (
|
191 | disabled: $color,
|
192 | ),
|
193 | $query: $query
|
194 | );
|
195 | }
|
196 |
|
197 | @mixin outline-width(
|
198 | $outline-width,
|
199 | $padding: button-shared-theme.$contained-horizontal-padding,
|
200 | // For a button with an icon, the padding on the side of the button with the
|
201 | // icon.
|
202 | $padding-icon: button-shared-theme.$contained-horizontal-padding-icon,
|
203 | $query: feature-targeting.all()
|
204 | ) {
|
205 | $feat-structure: feature-targeting.create-target($query, structure);
|
206 |
|
207 | @if $outline-width != null {
|
208 | $outline-width-value: if(
|
209 | custom-properties.is-custom-prop($outline-width),
|
210 | custom-properties.get-fallback($outline-width),
|
211 | $outline-width
|
212 | );
|
213 |
|
214 |
|
215 | $padding-value: math.max($padding - $outline-width-value, 0);
|
216 | $padding-icon-value: math.max($padding-icon - $outline-width-value, 0);
|
217 |
|
218 | @include button-shared-theme.horizontal-padding(
|
219 | $padding: $padding-value,
|
220 | $padding-icon: $padding-icon-value,
|
221 | $query: $query
|
222 | );
|
223 |
|
224 | @include feature-targeting.targets($feat-structure) {
|
225 | @include theme.property(border-width, $outline-width);
|
226 | }
|
227 |
|
228 | #{button-ripple.$ripple-target} {
|
229 | @include feature-targeting.targets($feat-structure) {
|
230 | @include theme.property(top, -1 * $outline-width-value);
|
231 | @include theme.property(left, -1 * $outline-width-value);
|
232 | @include theme.property(bottom, -1 * $outline-width-value);
|
233 | @include theme.property(right, -1 * $outline-width-value);
|
234 | @include theme.property(border-width, $outline-width);
|
235 | }
|
236 | }
|
237 | .mdc-button__touch {
|
238 | @include feature-targeting.targets($feat-structure) {
|
239 | @include theme.property(
|
240 | left,
|
241 | 'calc(-1 * outline-width)',
|
242 | $replace: (outline-width: $outline-width)
|
243 | );
|
244 | @include theme.property(
|
245 | width,
|
246 | 'calc(100% + 2 * outline-width)',
|
247 | $replace: (outline-width: $outline-width)
|
248 | );
|
249 | }
|
250 | }
|
251 | }
|
252 | }
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 | @mixin _outline-color($color, $query: feature-targeting.all()) {
|
260 | $feat-color: feature-targeting.create-target($query, color);
|
261 |
|
262 | @if $color {
|
263 | @include feature-targeting.targets($feat-color) {
|
264 | @include theme.property(border-color, $color);
|
265 | }
|
266 | }
|
267 | }
|