2017-09-14 36 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文件樹主題($主題);不是解決方案,我只是有一些搞砸了 –

相關問題