@@ -217,37 +217,55 @@ $mat-typography-level-mappings: (
217
217
///
218
218
/// @example
219
219
/// .my-app {
220
- /// @include mat-mdc-strong-focus-indicators();
220
+ /// @include mat-mdc-strong-focus-indicators($config );
221
221
/// }
222
- @mixin mat-mdc-strong-focus-indicators () {
223
- // Base styles for the focus indicators.
222
+ @mixin mat-mdc-strong-focus-indicators ($config : ()) {
223
+ // Default focus indicator config.
224
+ $default-config : (
225
+ border-style : solid ,
226
+ border-width : 3px ,
227
+ border-radius : 4px ,
228
+ );
229
+
230
+ // Merge default config with user config.
231
+ $config : map-merge ($default-config , $config );
232
+ $border-style : map-get ($config , border-style );
233
+ $border-width : map-get ($config , border-width );
234
+ $border-radius : map-get ($config , border-radius );
235
+
236
+ // Base styles for focus indicators.
224
237
.mat-mdc-focus-indicator ::before {
225
238
@include mat-fill ();
226
-
227
- border-radius : $mat-focus-indicator-border-radius ;
228
- border : $mat-focus-indicator-border-width $mat-focus-indicator-border-style transparent ;
229
239
box-sizing : border-box ;
230
240
pointer-events : none ;
241
+ border : $border-width $border-style transparent ;
242
+ border-radius : $border-radius ;
231
243
}
232
244
233
245
// By default, all focus indicators are flush with the bounding box of their
234
246
// host element. For particular elements (listed below), default inset/offset
235
247
// values are necessary to ensure that the focus indicator is sufficiently
236
248
// contrastive and renders appropriately.
237
249
238
- .mat-mdc-button-base .mat-mdc-focus-indicator ::before ,
250
+ .mat-mdc-unelevated-button .mat-mdc-focus-indicator ::before ,
251
+ .mat-mdc-raised-button .mat-mdc-focus-indicator ::before ,
252
+ .mdc-fab .mat-mdc-focus-indicator ::before ,
239
253
.mat-mdc-focus-indicator.mdc-chip ::before {
240
- margin : $mat-focus-indicator-border-width * -2 ;
254
+ margin : - ($border-width + 2px );
255
+ }
256
+
257
+ .mat-mdc-outlined-button .mat-mdc-focus-indicator ::before {
258
+ margin : - ($border-width + 3px );
241
259
}
242
260
243
261
.mat-mdc-focus-indicator.mat-mdc-chip-remove ::before ,
244
262
.mat-mdc-focus-indicator.mat-chip-row-focusable-text-content ::before {
245
- margin : $mat-focus-indicator- border-width * -1 ;
263
+ margin : - $ border-width ;
246
264
}
247
265
248
266
.mat-mdc-focus-indicator.mat-mdc-tab ::before ,
249
267
.mat-mdc-focus-indicator.mat-mdc-tab-link ::before {
250
- margin : $mat-focus-indicator-border-width * 2 ;
268
+ margin : 5 px ;
251
269
}
252
270
253
271
// Render the focus indicator on focus. Defining a pseudo element's
@@ -258,6 +276,8 @@ $mat-typography-level-mappings: (
258
276
.mdc-checkbox__native-control :focus ~ .mat-mdc-focus-indicator ::before ,
259
277
.mat-mdc-slide-toggle-focused .mat-mdc-focus-indicator ::before ,
260
278
.mat-mdc-radio-button.cdk-focused .mat-mdc-focus-indicator ::before ,
279
+
280
+ // For buttons, render the focus indicator when the parent button is focused.
261
281
.mat-mdc-button-base :focus .mat-mdc-focus-indicator ::before ,
262
282
263
283
// For all other components, render the focus indicator on focus.
@@ -268,24 +288,24 @@ $mat-typography-level-mappings: (
268
288
269
289
/// Mixin that sets the color of the focus indicators.
270
290
///
271
- /// @param {color|map} $themeOrMap
291
+ /// @param {color|map} $theme-or-color
272
292
/// If theme, focus indicators are set to the primary color of the theme. If
273
293
/// color, focus indicators are set to that color.
274
294
///
275
295
/// @example
276
296
/// .demo-dark-theme {
277
- /// @include mat-mdc-strong-focus-indicators-theme($darkThemeMap );
297
+ /// @include mat-mdc-strong-focus-indicators-theme($dark-theme-map );
278
298
/// }
279
299
///
280
300
/// @example
281
301
/// .demo-red-theme {
282
- /// @include mat-mdc-strong-focus-indicators-theme(#F00 );
302
+ /// @include mat-mdc-strong-focus-indicators-theme(#f00 );
283
303
/// }
284
- @mixin mat-mdc-strong-focus-indicators-theme ($themeOrColor ) {
304
+ @mixin mat-mdc-strong-focus-indicators-theme ($theme-or-color ) {
285
305
.mat-mdc-focus-indicator ::before {
286
306
border-color : if (
287
- type-of ($themeOrColor ) == ' map' ,
288
- mat-color (map_get ($themeOrColor , primary )),
289
- $themeOrColor );
307
+ type-of ($theme-or-color ) == ' map' ,
308
+ mat-color (map_get ($theme-or-color , primary )),
309
+ $theme-or-color );
290
310
}
291
311
}
0 commit comments