Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(selection-list): support specifying theme color#15237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jelbourn
merged 1 commit into
angular:master
from
devversion:feat/selection-list-support-theme-colorFeb 22, 2019
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -46,6 +46,7 @@ import { | ||
| MatLine, | ||
| setLines, | ||
| mixinDisableRipple, | ||
| ThemePalette, | ||
| } from '@angular/material/core'; | ||
| import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; | ||
| import {Subscription} from 'rxjs'; | ||
| @@ -97,6 +98,11 @@ export class MatSelectionListChange { | ||
| 'tabindex': '-1', | ||
| '[class.mat-list-item-disabled]': 'disabled', | ||
| '[class.mat-list-item-with-avatar]': '_avatar || _icon', | ||
| // Manually set the "primary" or "warn" class if the color has been explicitly | ||
| // set to "primary" or "warn". The pseudo checkbox picks up these classes for | ||
| // its theme. The accent theme palette is the default and doesn't need to be set. | ||
| '[class.mat-primary]': 'color === "primary"', | ||
| '[class.mat-warn]': 'color === "warn"', | ||
| '[attr.aria-selected]': 'selected.toString()', | ||
| '[attr.aria-disabled]': 'disabled.toString()', | ||
| }, | ||
| @@ -121,6 +127,12 @@ export class MatListOption extends _MatListOptionMixinBase | ||
| /** Whether the label should appear before or after the checkbox. Defaults to 'after' */ | ||
| @Input() checkboxPosition: 'before' | 'after' = 'after'; | ||
| /** Theme color of the list option. This sets the color of the checkbox. */ | ||
| @Input() | ||
| get color(): ThemePalette { return this._color || this.selectionList.color; } | ||
crisbeto marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| set color(newValue: ThemePalette) { this._color = newValue; } | ||
| private _color: ThemePalette; | ||
| /** Value of the option */ | ||
| @Input() | ||
| get value(): any { return this._value; } | ||
| @@ -316,6 +328,9 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu | ||
| /** Tabindex of the selection list. */ | ||
| @Input() tabIndex: number = 0; | ||
| /** Theme color of the selection list. This sets the checkbox color for all list options. */ | ||
| @Input() color: ThemePalette = 'accent'; | ||
| /** | ||
| * Function used for comparing an option against the selected value when determining which | ||
| * options should appear as selected. The first argument is the value of an options. The second | ||
| @@ -389,8 +404,10 @@ export class MatSelectionList extends _MatSelectionListMixinBase implements Focu | ||
| ngOnChanges(changes: SimpleChanges) { | ||
| const disableRippleChanges = changes.disableRipple; | ||
| const colorChanges = changes.color; | ||
| if (disableRippleChanges && !disableRippleChanges.firstChange) { | ||
| if ((disableRippleChanges && !disableRippleChanges.firstChange) || | ||
| (colorChanges && !colorChanges.firstChange)) { | ||
| this._markOptionsForCheck(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.