@@ -30,6 +30,7 @@ import {MdTab} from './tab';
3030import { map } from '../core/rxjs/index' ;
3131import { merge } from 'rxjs/observable/merge' ;
3232import { CanDisableRipple , mixinDisableRipple } from '../core/common-behaviors/disable-ripple' ;
33+ import { CanColor , mixinColor , ThemePalette } from '../core/common-behaviors/color' ;
3334
3435
3536/** Used to generate unique ID's for each tab component */
@@ -46,8 +47,10 @@ export type MdTabHeaderPosition = 'above' | 'below';
4647
4748// Boilerplate for applying mixins to MdTabGroup.
4849/** @docs -private */
49- export class MdTabGroupBase { }
50- export const _MdTabGroupMixinBase = mixinDisableRipple ( MdTabGroupBase ) ;
50+ export class MdTabGroupBase {
51+ constructor ( public _renderer : Renderer2 , public _elementRef : ElementRef ) { }
52+ }
53+ export const _MdTabGroupMixinBase = mixinColor ( mixinDisableRipple ( MdTabGroupBase ) , 'primary' ) ;
5154
5255/**
5356 * Material design tab-group component. Supports basic tab pairs (label + content) and includes
@@ -60,15 +63,15 @@ export const _MdTabGroupMixinBase = mixinDisableRipple(MdTabGroupBase);
6063 templateUrl : 'tab-group.html' ,
6164 styleUrls : [ 'tab-group.css' ] ,
6265 changeDetection : ChangeDetectionStrategy . OnPush ,
63- inputs : [ 'disableRipple' ] ,
66+ inputs : [ 'color' , ' disableRipple'] ,
6467 host : {
6568 'class' : 'mat-tab-group' ,
6669 '[class.mat-tab-group-dynamic-height]' : 'dynamicHeight' ,
6770 '[class.mat-tab-group-inverted-header]' : 'headerPosition === "below"' ,
6871 }
6972} )
7073export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit ,
71- AfterContentChecked , AfterViewChecked , OnDestroy , CanDisableRipple {
74+ AfterContentChecked , AfterViewChecked , OnDestroy , CanColor , CanDisableRipple {
7275
7376 @ContentChildren ( MdTab ) _tabs : QueryList < MdTab > ;
7477
@@ -109,6 +112,22 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
109112 /** Position of the tab header. */
110113 @Input ( ) headerPosition : MdTabHeaderPosition = 'above' ;
111114
115+ /** Background color of the tab group. */
116+ @Input ( )
117+ get backgroundColor ( ) : ThemePalette { return this . _backgroundColor ; }
118+ set backgroundColor ( value : ThemePalette ) {
119+ let nativeElement = this . _elementRef . nativeElement ;
120+
121+ this . _renderer . removeClass ( nativeElement , `mat-background-${ this . backgroundColor } ` ) ;
122+
123+ if ( value ) {
124+ this . _renderer . addClass ( nativeElement , `mat-background-${ value } ` ) ;
125+ }
126+
127+ this . _backgroundColor = value ;
128+ }
129+ private _backgroundColor : ThemePalette ;
130+
112131 /** Output to enable support for two-way binding on `[(selectedIndex)]` */
113132 @Output ( ) get selectedIndexChange ( ) : Observable < number > {
114133 return map . call ( this . selectChange , event => event . index ) ;
@@ -122,8 +141,10 @@ export class MdTabGroup extends _MdTabGroupMixinBase implements AfterContentInit
122141
123142 private _groupId : number ;
124143
125- constructor ( private _renderer : Renderer2 , private _changeDetectorRef : ChangeDetectorRef ) {
126- super ( ) ;
144+ constructor ( _renderer : Renderer2 ,
145+ elementRef : ElementRef ,
146+ private _changeDetectorRef : ChangeDetectorRef ) {
147+ super ( _renderer , elementRef ) ;
127148 this . _groupId = nextId ++ ;
128149 }
129150
0 commit comments