, "" , , . , . , ( DIV, SPAN ..) , . , , 2 Angular 2.
:
:
@import '~@angular/material/_theming.scss';
@include mat-core();
// default theme:
$primary: mat-palette($mat-blue,800);
$accent: mat-palette($mat-teal);
$theme: mat-light-theme($primary, $accent);
@include angular-material-theme($theme);
// "dark" theme
$dark-p: mat-palette($mat-blue-grey, 500);
$dark-a: mat-palette($mat-blue-grey,900);
$dark-t: mat-dark-theme($dark-p, $dark-a);
.darkTheme {
@include angular-material-theme($dark-t);
}
scss :
@import '../../themes/main-theme';
$light-foreground-palette: map-get($theme, foreground);
$light-background-palette: map-get($theme, background);
$dark-foreground-palette: map-get($dark-t, foreground);
$dark-background-palette: map-get($dark-t, background);
.light-colors{
background-color : mat-color($primary, default);
color: mat-color($light-foreground-palette, text);
}
.dark-colors{
background-color : mat-color($dark-p, default);
color: mat-color($dark-foreground-palette, text);
}
"" ( , , , , ), isDarkTheme. , .
, , ngClass isDarkTheme:
<div [ngClass]="{'light-colors' : !svc.isDarkTheme,'dark-colors' : svc.isDarkTheme}">
...my content...
</div>
div, , ngClass, darkTheme isDarkTheme. Material-aware , light-colors dark-colors , . , , , .
, , :
"" ($primary $dark-p ):
$accent $warn.
" " ($light-foreground-palette $dark-foreground-palette ):
"background" ($light-background-palette $dark-background-palette ):
, :
80% , , , , , ...