-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(stepper): Merge stepper branch into master #6594
Conversation
src/lib/stepper/_stepper-theme.scss
Outdated
@import '../core/theming/theming'; | ||
@import '../core/typography/_typography-utils.scss'; | ||
|
||
@mixin mat-stepper-theme($theme) { |
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.
should have typography mixin too (even if it currently does nothing)
7ec40bf
to
1bbb27f
Compare
}); | ||
|
||
this.emailFormGroup = this._formBuilder.group({ | ||
emailCtrl: ['', Validators.pattern(EMAIL_REGEX)] |
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.
Validators.email
can be used here: emailCtrl: ['', Validators.email]
[class.mat-step-icon-not-touched]="icon == 'number' && !selected"> | ||
<span *ngIf="icon == 'number'">{{index + 1}}</span> | ||
<md-icon *ngIf="icon == 'edit'">create</md-icon> | ||
<md-icon *ngIf="icon == 'done'">done</md-icon> |
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.
I think ngSwitch
fits better than 3 *ngIf
.
[ngSwitch]="icon"
*ngSwitchCase="number" ...
*ngSwitchCase="edit"...
*ngSwitchCase="done"...
end
All the checks are now passing 👍 Ready for review |
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.
LGTM
src/cdk/stepper/stepper.ts
Outdated
|
||
/** The top level abstract control of the step. */ | ||
@Input() | ||
get stepControl() { return this._stepControl; } |
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.
Why is this using a getter and a setter? It doesn't seem like it has any special logic. Using a normal property will result in a bit less generated JS.
}) | ||
export class CdkStepper { | ||
/** The list of step components that the stepper is holding. */ | ||
@ContentChildren(CdkStep) _steps: QueryList<CdkStep>; |
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.
Is there a reason for this, _stepHeader
and _focusIndex
to be public? It seems like they're only used internally.
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.
Anything that's a @ContentChild(ren)
or @ViewChild(ren)
as well as anything referenced in the template must be public, they start with _
to indicate they're internal
return 'previous'; | ||
} else if (position > 0) { | ||
return 'next'; | ||
} else { |
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.
The else
here is redundant, you can just add the return 'current'
at the end.
} | ||
|
||
private _emitStepperSelectionEvent(newIndex: number): void { | ||
const stepsArray = this._steps.toArray(); |
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.
It seems like there are a lot of places where you're converting the steps
into an array in order to look something up. It might be cleaner if you stored the selected step object instead of its index.
|
||
_onKeydown(event: KeyboardEvent) { | ||
switch (event.keyCode) { | ||
case RIGHT_ARROW: |
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.
This doesn't account for RTL where the directions are inverted.
src/lib/stepper/stepper-vertical.ts
Outdated
animations: [ | ||
trigger('stepTransition', [ | ||
state('previous', style({height: '0px', visibility: 'hidden'})), | ||
state('next', style({height: '0px', visibility: 'hidden'})), |
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.
Since the previous
and next
states have the same styling, you can combine them:
state('next, previous', style({height: '0px', visibility: 'hidden'}))
```html | ||
<md-vertical-stepper> | ||
<md-step label="Step 1"> | ||
Content 1 |
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.
Consider using some real-world text for the example, instead of Content X
.
src/lib/stepper/stepper.spec.ts
Outdated
import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes'; | ||
import {MdStepper} from './stepper'; | ||
|
||
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/; |
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.
Since the unit test doesn't really care about what you're validating, you can use a simpler regex that only validates a certain value, e.g. const UNICORN_REGEX = /unicorn/
.
|
||
it('should support keyboard events to move and select focus', () => { | ||
let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-horizontal-stepper-header')); | ||
assertCorrectKeyboardInteraction(stepperComponent, fixture, stepHeaders); |
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.
Not a fan of having the assertions be in separate functions, because it makes failures harder to track down, although in this case the assertions seem pretty complicated. Thoughts @jelbourn?
src/lib/stepper/stepper.ts
Outdated
constructor(mdStepper: MdStepper, | ||
@Optional() @SkipSelf() @Inject(MD_ERROR_GLOBAL_OPTIONS) errorOptions: ErrorOptions) { | ||
super(mdStepper); | ||
this._originalErrorStateMatcher = |
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.
The ternary with a nested || is a little hard to follow. It might be cleaner if it used a regular if/else
.
@g1shin please address @rafaelss95's and @crisbeto's stylistic comments in a follow-up PR. The RTL issue that @crisbeto pointed out is a bug and should be fixed in this PR before merging |
fixed RTL bugs |
…tepper branch. (#5742) * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Adding "selectedIndex" attribute to stepper and working on TemplateOulet. * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Template rendering and selectIndex control done. * Work in progress for accessibility * Added functionalities based on the tentative API doc. * Refactor code for cdk-stepper and cdk-step * Add support for templated label * Added support for keyboard events and focus changes for accessibility. * Updated vertical stepper + added comments * Fix package-lock.json * Fix indention * Changes made based on the review * Changes based on review - event properties, selectors, SPACE support, etc. + demo * Add select() for step component + refactor to avoid circular dependency + support cycling using arrow keys * API change based on review * Minor code clean up based on review. * Several name changes, etc based on review * Add to compatibility mode list and refactor to avoid circular dependency feat(stepper): Create stepper button directives to enable adding buttons to stepper (#5951) * Create stepper button directives to enable adding buttons to stepper * Changes made based on review * Minor changes with click handlers Build changes feat(stepper): Add initial styles to stepper based on Material guidelines (#6242) * Add initial styles to stepper based on Material guidelines * Fix flex-shrink and min-width * Changes made based on review * Fix alignment * Margin modifications feat(stepper): Add support for linear stepper (#6116) * Add form controls and custom error state matcher * Modify form controls for stepper-demo and add custom validator * Move custom step validation function so that users can simply import and use * Implement @input() stepControl for each step * Add linear attribute to stepper * Add enabling/disabling linear state of demo feat(stepper): Add animation to stepper (#6361) * Add animation * Implement Angular animation * Clean up unnecessary code * Generalize animation so that vertical and horizontal steppers can use the same function Rebase onto upstream/master feat(stepper): Add unit tests for stepper (#6428) * Add unit tests for stepper * Changes made based on review * More changes based on review feat(stepper): Add support for linear stepper #2 - each step as its own form. (#6117) * Add form control - consider each step as its own form group * Comment edits * Add 'valid' to MdStep for form validation * Add [stepControl] to each step based on merging * Changes based on review Fix focus logic and CSS changes (#6507) feat(stepper): Add documentation for stepper (#6533) * Documentation for stepper * Revision based on review + add accessibility section feat(stepper): Support additional properties for step (#6509) * Additional properties for step * Unit tests * Code changes based on review + test name changes * Refactor code for shared functionality between vertical and horizontal stepper * Refactor md-step-header and md-step-content + optional step change * Simplify code based on review * Changes to step-header based on review * Minor changes Fix host style and demo page (#6592) Revert package.json and package-lock.json Changes made along with BUILD changes in google3 Add typography mixin Changes to address aot compiler failures fix rtl bugs
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.