Skip to content

Commit

Permalink
Add mixins to emit the theme based on tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed May 16, 2023
1 parent eabcb1c commit f990c0b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/material/_index.scss
Expand Up @@ -37,6 +37,7 @@
@forward './core/style/button-common' as private-button-common-*;
// The form field density mixin needs to be exposed, because the paginator depends on it.
@forward './form-field/form-field-theme' as private-form-field-* show private-form-field-density;
@forward './token-theming' as private-apply-*;

// Structural
@forward './core/core' show core;
Expand Down
2 changes: 2 additions & 0 deletions src/material/_token-theming.scss
@@ -0,0 +1,2 @@
@forward './card/card-theme' as card-* show card-theme-from-tokens;
@forward './checkbox/checkbox-theme' as checkbox-* show checkbox-theme-from-tokens;
11 changes: 11 additions & 0 deletions src/material/card/_card-theme.scss
@@ -1,3 +1,4 @@
@use 'sass:map';
@use '../core/theming/theming';
@use '../core/typography/typography';
@use '../core/tokens/token-utils';
Expand Down Expand Up @@ -76,3 +77,13 @@
}
}
}

@mixin theme-from-tokens($tokens) {
// Add values for card tokens.
.mat-mdc-card {
@include mdc-elevated-card-theme.theme(map.get($tokens, tokens-mdc-elevated-card.$prefix));
@include mdc-outlined-card-theme.theme(map.get($tokens, tokens-mdc-outlined-card.$prefix));
@include token-utils.create-token-values(
tokens-mat-card.$prefix, map.get($tokens, tokens-mat-card.$prefix));
}
}
9 changes: 9 additions & 0 deletions src/material/checkbox/_checkbox-theme.scss
Expand Up @@ -82,3 +82,12 @@
}
}
}

@mixin theme-from-tokens($tokens) {
// TODO(mmalerba): Some of the theme styles above are not represented in terms of tokens,
// so this mixin is currently incomplete.

.mat-mdc-checkbox {
@include mdc-checkbox-theme.theme(map.get($tokens, tokens-mdc-checkbox.$prefix));
}
}

0 comments on commit f990c0b

Please sign in to comment.