Skip to content

Commit

Permalink
feat(material-experimental/theming): add mixin for customizing checkb…
Browse files Browse the repository at this point in the history
…ox tokens
  • Loading branch information
wagnermaciel committed Mar 21, 2024
1 parent dba9e24 commit a687d0b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/material-experimental/theming/_customize-m3-tokens.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@use 'sass:map';
@use '@angular/material' as mat;

@use '../../material/core/style/sass-utils';
@use '../../material/core/tokens/token-utils';
@use '../../material/core/tokens/m2/mat/checkbox' as mat-checkbox-tokens;
@use '../../material/core/tokens/m2/mdc/checkbox' as mdc-checkbox-tokens;

@mixin customize-checkbox-tokens($tokens: ()) {
$mat-tokens: mat-checkbox-tokens.get-token-slots();
$mdc-tokens: mdc-checkbox-tokens.get-token-slots();

$custom-mat-tokens: ();
$custom-mdc-tokens: ();

@each $token, $value in $tokens {
$is-mat-token: map.get($mat-tokens, $token) != null;
$is-mdc-token: map.get($mdc-tokens, $token) != null;

@if ($is-mat-token) {
$custom-mat-tokens: map.set($custom-mat-tokens, $token, $value);
}

@if ($is-mdc-token) {
$custom-mdc-tokens: map.set($custom-mdc-tokens, $token, $value);
}

@if (not $is-mat-token and not $is-mdc-token) {
@error ("Invalid token: '" + $token + "'. Valid tokens include: " map.keys(map.merge($mat-tokens, $mdc-tokens)));
}
}

@include sass-utils.current-selector-or-root() {
@include token-utils.create-token-values(mat-checkbox-tokens.$prefix, $custom-mat-tokens);
@include token-utils.create-token-values(mdc-checkbox-tokens.$prefix, $custom-mdc-tokens);
}
}

0 comments on commit a687d0b

Please sign in to comment.