-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
feat(select): support disabling #1667
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,11 +1,30 @@ | ||
<div class="demo-select"> | ||
<md-select placeholder="Food" [formControl]="control" [required]="isRequired"> | ||
<md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }} </md-option> | ||
</md-select> | ||
<p> Value: {{ control.value }} </p> | ||
<p> Touched: {{ control.touched }} </p> | ||
<p> Dirty: {{ control.dirty }} </p> | ||
<p> Status: {{ control.status }} </p> | ||
<button md-button (click)="control.setValue('pizza-1')">SET VALUE</button> | ||
<button md-button (click)="isRequired=!isRequired">TOGGLE REQUIRED</button> | ||
<md-card> | ||
<md-select placeholder="Food" [formControl]="foodControl"> | ||
<md-option *ngFor="let food of foods" [value]="food.value"> {{ food.viewValue }} </md-option> | ||
</md-select> | ||
<p> Value: {{ foodControl.value }} </p> | ||
<p> Touched: {{ foodControl.touched }} </p> | ||
<p> Dirty: {{ foodControl.dirty }} </p> | ||
<p> Status: {{ foodControl.status }} </p> | ||
<button md-button (click)="foodControl.setValue('pizza-1')">SET VALUE</button> | ||
<button md-button (click)="toggleDisabled()">TOGGLE DISABLED</button> | ||
</md-card> | ||
|
||
<md-card> | ||
<md-select placeholder="Drink" [(ngModel)]="currentDrink" [required]="isRequired" [disabled]="isDisabled" | ||
#drinkControl="ngModel"> | ||
<md-option *ngFor="let drink of drinks" [value]="drink.value" [disabled]="drink.disabled"> | ||
{{ drink.viewValue }} | ||
</md-option> | ||
</md-select> | ||
<p> Value: {{ currentDrink }} </p> | ||
<p> Touched: {{ drinkControl.touched }} </p> | ||
<p> Dirty: {{ drinkControl.dirty }} </p> | ||
<p> Status: {{ drinkControl.control?.status }} </p> | ||
<button md-button (click)="currentDrink='sprite-1'">SET VALUE</button> | ||
<button md-button (click)="isRequired=!isRequired">TOGGLE REQUIRED</button> | ||
<button md-button (click)="isDisabled=!isDisabled">TOGGLE DISABLED</button> | ||
</md-card> | ||
|
||
</div> |
This file contains 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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
.demo-select { | ||
display: flex; | ||
flex-flow: row wrap; | ||
|
||
md-card { | ||
width: 450px; | ||
margin: 24px; | ||
} | ||
|
||
} |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
// Gradient for showing the dashed line when the input is disabled. | ||
// Unlike using a border, a gradient allows us to adjust the spacing of the dotted line | ||
// to match the Material Design spec. | ||
$md-underline-disabled-background-image: | ||
linear-gradient(to right, rgba(0, 0, 0, 0.26) 0%, rgba(0, 0, 0, 0.26) 33%, transparent 0%); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment saying why you use a linear-gradient like this instead of a border? |
||
|
||
@mixin md-control-disabled-underline { | ||
background-image: $md-underline-disabled-background-image; | ||
background-size: 4px 1px; | ||
background-repeat: repeat-x; | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<ng-content></ng-content> | ||
<div class="md-option-ripple" md-ripple md-ripple-background-color="rgba(0,0,0,0)" | ||
<div class="md-option-ripple" *ngIf="!disabled" md-ripple md-ripple-background-color="rgba(0,0,0,0)" | ||
[md-ripple-trigger]="_getHostElement()"></div> |
This file contains 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 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentDrink
needs to be defined in the class.(failing google presubmit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed