Skip to content
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

Merged
merged 4 commits into from
Aug 31, 2017
Merged

feat(stepper): Merge stepper branch into master #6594

merged 4 commits into from
Aug 31, 2017

Conversation

g1shin
Copy link

@g1shin g1shin commented Aug 22, 2017

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 22, 2017
@g1shin g1shin removed the request for review from devversion August 22, 2017 22:13
@import '../core/theming/theming';
@import '../core/typography/_typography-utils.scss';

@mixin mat-stepper-theme($theme) {
Copy link
Contributor

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)

@g1shin g1shin requested a review from crisbeto as a code owner August 23, 2017 00:32
@g1shin g1shin force-pushed the stepper branch 2 times, most recently from 7ec40bf to 1bbb27f Compare August 23, 2017 01:27
});

this.emailFormGroup = this._formBuilder.group({
emailCtrl: ['', Validators.pattern(EMAIL_REGEX)]
Copy link
Contributor

@rafaelss95 rafaelss95 Aug 23, 2017

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>
Copy link
Contributor

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

@g1shin
Copy link
Author

g1shin commented Aug 23, 2017

All the checks are now passing 👍 Ready for review

Copy link
Contributor

@mmalerba mmalerba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


/** The top level abstract control of the step. */
@Input()
get stepControl() { return this._stepControl; }
Copy link
Member

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>;
Copy link
Member

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.

Copy link
Contributor

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 {
Copy link
Member

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();
Copy link
Member

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:
Copy link
Member

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.

animations: [
trigger('stepTransition', [
state('previous', style({height: '0px', visibility: 'hidden'})),
state('next', style({height: '0px', visibility: 'hidden'})),
Copy link
Member

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
Copy link
Member

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.

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-]+)*$/;
Copy link
Member

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);
Copy link
Member

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?

constructor(mdStepper: MdStepper,
@Optional() @SkipSelf() @Inject(MD_ERROR_GLOBAL_OPTIONS) errorOptions: ErrorOptions) {
super(mdStepper);
this._originalErrorStateMatcher =
Copy link
Member

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.

@mmalerba
Copy link
Contributor

@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

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Aug 23, 2017
@mmalerba
Copy link
Contributor

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
@jelbourn jelbourn merged commit 87318bc into master Aug 31, 2017
@g1shin g1shin mentioned this pull request Sep 8, 2017
@jelbourn jelbourn deleted the stepper branch December 7, 2017 23:47
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants