-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor md-step-header and md-step-content + optional step change
- Loading branch information
1 parent
b214f70
commit add81b0
Showing
26 changed files
with
474 additions
and
362 deletions.
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
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,61 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {Directive, Input} from '@angular/core'; | ||
import {CdkStep, CdkStepper} from './stepper'; | ||
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; | ||
|
||
@Directive({ | ||
selector: 'cdkStepContent', | ||
host: { | ||
'role': 'tabpanel', | ||
'[attr.id]': 'contentId', | ||
'[attr.aria-labelledby]': 'labelId', | ||
'[attr.aria-expanded]': 'selectedIndex == index', | ||
} | ||
}) | ||
export class CdkStepContent { | ||
/** Whether the orientation of stepper is horizontal. */ | ||
@Input() | ||
get horizontal() { return this._horizontal; } | ||
set horizontal(value: any) { | ||
this._horizontal = coerceBooleanProperty(value); | ||
} | ||
private _horizontal: boolean; | ||
|
||
/** Unique label ID of step header. */ | ||
@Input() | ||
labelId: string; | ||
|
||
/** Unique content ID of step content. */ | ||
@Input() | ||
contentId: string; | ||
|
||
/** Index of the given step. */ | ||
@Input() | ||
get index() { return this._index; } | ||
set index(value: any) { | ||
this._index = coerceNumberProperty(value); | ||
} | ||
private _index: number; | ||
|
||
/** Index of selected step in stepper. */ | ||
@Input() | ||
get selectedIndex() { return this._selectedIndex; } | ||
set selectedIndex(value: any) { | ||
this._selectedIndex = coerceNumberProperty(value); | ||
} | ||
private _selectedIndex: number; | ||
|
||
/** Returns the step at the index position in stepper. */ | ||
get step(): CdkStep { | ||
return this._stepper._steps.toArray()[this._index]; | ||
} | ||
|
||
constructor(private _stepper: CdkStepper) { } | ||
} |
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,71 @@ | ||
/** | ||
* @license | ||
* Copyright Google Inc. All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {Directive, Input} from '@angular/core'; | ||
import {CdkStep, CdkStepper} from './stepper'; | ||
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; | ||
|
||
@Directive({ | ||
selector: 'cdkStepHeader', | ||
host: { | ||
'role': 'tab', | ||
'[attr.id]': 'labelId', | ||
'[attr.aria-controls]': 'contentId', | ||
'[attr.aria-selected]': 'selected' | ||
} | ||
}) | ||
export class CdkStepHeader { | ||
/** Whether the orientation of stepper is horizontal. */ | ||
@Input() | ||
get horizontal() { return this._horizontal; } | ||
set horizontal(value: any) { | ||
this._horizontal = coerceBooleanProperty(value); | ||
} | ||
private _horizontal: boolean; | ||
|
||
/** Unique label ID of step header. */ | ||
@Input() | ||
labelId: string; | ||
|
||
/** Unique content ID of step content. */ | ||
@Input() | ||
contentId: string; | ||
|
||
/** Index of the given step. */ | ||
@Input() | ||
get index() { return this._index; } | ||
set index(value: any) { | ||
this._index = coerceNumberProperty(value); | ||
} | ||
private _index: number; | ||
|
||
/** Whether the given step is selected. */ | ||
@Input() | ||
get selected() { return this._selected; } | ||
set selected(value: any) { | ||
this._selected = coerceBooleanProperty(value); | ||
} | ||
private _selected: boolean; | ||
|
||
|
||
/** Returns the step at the index position in stepper. */ | ||
get step(): CdkStep { | ||
return this._stepper._steps.toArray()[this._index]; | ||
} | ||
|
||
constructor(private _stepper: CdkStepper) { } | ||
|
||
/** Returns the type of icon to be displayed. */ | ||
_getIndicatorType(): 'number' | 'edit' | 'done' { | ||
if (!this.step.completed || this.selected) { | ||
return 'number'; | ||
} else { | ||
return this.step.editable ? 'edit' : 'done'; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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.