2017-02-22 4 views
6

だから、プライマリ・パレットから色相/明るい色を取得するにはどのように、私は私のテーマは、私が彼らのドキュメントから把握することはできませんどのような 角度資料2に

$store-primary: mat-palette($mat-storecast); 
$store-accent: mat-palette($mat-pink, A200, A100, A400); 

// The warn palette is optional (defaults to red). 
$store-warn: mat-palette($mat-red); 

// Create the theme object (a Sass map containing all of the palettes). 
$store-theme: mat-light-theme($store-primary, $store-accent, $store-warn); 

// Include theme styles for core and each component used in your app. 
// Alternatively, you can import and @include the theme mixins for each component 
// that you are using. 
@include angular-material-theme($store-theme); 

を設定しているが異なる色相の色を取得する方法ですプライマリパレットから、ボタン上のツールバーに移動します。

<button md-mini-fab (click)="zoomIn()" color="primary"> 
    <md-icon>add</md-icon> 
</button> 

は、それが唯一の色=プライマリまたは色を理解し、それのように思える=アクセントがetc..how私は主-100またはプライマリ-500などを使用したい指定するのですか?

私は同じ方法であるかどうかわからないんだけど、私は何をするディレクティブを使用している、角度-材料1を使用し

答えて

1

公式の回答をこれは現在不可能であるということです。ほとんどのコンポーネントで利用可能なcolor属性は、パレットタイプ、つまりプライマリ、アクセント、または警告のみを受け入れます。

本当にこれをやりたいのであれば、内部APIを悪用しても構わない場合は、(コンポーネントごとに)可能です。たとえば、A100の色をボタンに表示するには、テーマにカスタムミックスインを追加します。

// custom-button-theme.scss 
@import '[email protected]/material/core/theming/all-theme'; 
@import '[email protected]/material/button/_button-theme'; 

@mixin custom-button-theme($theme) { 

    .mat-raised-button.a100, .mat-fab.a100, .mat-mini-fab.a100 { 
    // _mat-button-theme-color is a mixin defined in _button-theme.scss 
    // which applies the given property, in this case background-color 
    // for each of the palettes - i.e. primary, accent and warn. 
    // The last parameter is the hue colour to apply. 
    @include _mat-button-theme-color($theme, 'background-color', 'A100'); 
    } 

} 

メインのテーマファイルでは、カスタムミックスインをインポートします。

@import 'custom-button-theme.scss'; 
@include custom-button-theme($store-theme); 

ボタンは、a100クラスを追加することで色を使用できます。

<button md-mini-fab (click)="zoomIn()" color="primary" class="a100"> 
    <md-icon>add</md-icon> 
</button> 

ただし、内部APIはいつでも変更できることに注意してください。このコードはバージョン2.0.0-beta.2でテストされました。ベータ3が出てきたら保証がありません。

+0

ありがとう、イアン、これは近い将来追加されると思う。 – StevieB

1

themenameでもちろんmd-colors="::{background: 'themename-primary-100'}"あなたがテーマ名入れ:P

+0

私はcolor = "primary-100"のようにしようとしましたが、なんらかの理由でアクセントのテーマに変更されました。かなり奇妙な – StevieB

+0

テーマを定義する必要があります。角度1では、次のようにします: '$ mdThemingProvider.theme( 'themename') .primaryPalette( 'blue-gray') .accentPalette( 'lime') .warnPalette ('赤'); $ mdThemingProvider.setDefaultTheme( 'themename'); '次に' md-colors = ":: {background: 'themename-primary-100'}" ' –

+0

を使用してください。私はすべての答えを読むことができるように編集します。 –

関連する問題