2017-09-14 68 views
0

我能够得到小学,口音和警告调色板,并将它们保存在SCSS瓦尔:是否可以检索Angular 4 Material Theme的背景和前景调色板?

$candy-app-theme: mat-dark-theme($candy-app-primary, $candy-app-accent, $candy-app-warn); 
$primary: map-get($candy-app-theme, primary); 
$accent: map-get($candy-app-theme, accent); 
$warn: map-get($candy-app-theme, warn); 

现在我能我的风格与CSS类自己的组件。但可以说我想制作一个卡片css类(无法想象一个更好的例子,我知道有一个卡片组件),背景色比md-sidenav-container的正常背景稍浅。

我会如何处理这个问题?

我已经看了@Theming your own components(可惜它没有覆盖) 另外我偶然发现了this guide

enter image description here

我想这一点 - 但只要我试图让一个出彩的前景我得到了以下错误:

color: mat-color($foreground, text); 
//Error 

Module build failed: 
undefined 
     ^
     Argument `$map` of `map-get($map, $key)` must be a map 

Backtrace: 
     node_modules/@angular/material/_theming.scss:1107, in function `map-get` 
     node_modules/@angular/material/_theming.scss:1107, in function `mat-color` 
     src/assets/scss/angular-material/main-theme.scss:22 
     in C:\Users\tobia\Documents\frontend\node_modules\@angular\material\_theming.scss (line 1107, column 11) 
Error: 
undefined 
     ^
     Argument `$map` of `map-get($map, $key)` must be a map 

Backtrace: 
     node_modules/@angular/material/_theming.scss:1107, in function `map-get` 
     node_modules/@angular/material/_theming.scss:1107, in function `mat-color` 

我希望我没有忽视了一些东西明显。任何形式的帮助,将不胜感激:)

回答

1

我认为有一些关于如何将自定义主题应用于材质核心主题的缺失。

styles.scss -file创建自定义主题,一个mixin:

@import 'app/components/ml-file-tree-theme.scss'; 

@mixin custom-theme($theme) { 
    @include ml-file-tree-theme($theme);  
} 

之后,你必须包括混入材料主题:

@include angular-material-theme($my-theme); // default angular material theme 
@include custom-theme($my-theme);   // include custom theme 

很好的指导主题化(包括自定义主题)在角材2是由托马斯Trajan:https://medium.com/@tomastrajan/the-complete-guide-to-angular-material-themes-4d165a9d24d1

+0

谢谢指导帮助我 - 包括ml文件树主题($主题);不是解决方案,我只是有一些搞砸了 –