Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinayuangao committed Feb 17, 2017
1 parent 43f8fa2 commit a7ac5f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/lib/button-toggle/_button-toggle-theme.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
@import '../core/theming/palette';
@import '../core/theming/theming';

// Applies a focus style to an md-button-toggle element for each of the supported palettes.
@mixin _mat-button-toggle-focus-color($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);

&.mat-primary .mat-button-toggle-focus-overlay {
background-color: mat-color($primary, 0.12);
}

&.mat-accent .mat-button-toggle-focus-overlay {
background-color: mat-color($accent, 0.12);
}

&.mat-warn .mat-button-toggle-focus-overlay {
background-color: mat-color($warn, 0.12);
}
}

@mixin mat-button-toggle-theme($theme) {
$foreground: map-get($theme, foreground);
$background: map-get($theme, background);

.mat-button-toggle {
color: mat-color($foreground, hint-text);

&.cdk-focused {
@include _mat-button-toggle-focus-color($theme);
}
}

.mat-button-toggle-checked {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ export class MdButtonToggle implements OnInit {
@Optional() toggleGroupMultiple: MdButtonToggleGroupMultiple,
public buttonToggleDispatcher: UniqueSelectionDispatcher,
private _renderer: Renderer,
private _elementRef: ElementRef,
private _focusOriginMonitor: FocusOriginMonitor) {
this.buttonToggleGroup = toggleGroup;

Expand Down Expand Up @@ -364,7 +365,7 @@ export class MdButtonToggle implements OnInit {
if (this.buttonToggleGroup && this._value == this.buttonToggleGroup.value) {
this._checked = true;
}
this._focusOriginMonitor.registerElementForFocusClasses(this._inputElement.nativeElement, this._renderer);
this._focusOriginMonitor.monitor(this._elementRef.nativeElement, this._renderer, true);
}

/** Unique ID for the underlying `input` element. */
Expand Down

0 comments on commit a7ac5f8

Please sign in to comment.