Skip to content

Commit 6857426

Browse files
raygervaisjelbourn
authored andcommitted
docs(stepper): Created stepper examples for documentation (#10537)
Updates button logic setting button from true to !isLinear, including text indicator of current state. Creates editable and optional documentation examples Imports into .MD file using special syntax
1 parent dba8a0c commit 6857426

File tree

8 files changed

+139
-3
lines changed

8 files changed

+139
-3
lines changed

src/lib/stepper/stepper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ are completed.
112112
If completion of a step in linear stepper is not required, then the `optional` attribute can be set
113113
on `mat-step`.
114114

115+
<!-- example(stepper-optional) -->
116+
117+
115118
#### Editable step
116119
By default, steps are editable, which means users can return to previously completed steps and
117120
edit their responses. `editable="true"` can be set on `mat-step` to change the default.
118121

122+
<!-- example(stepper-editable) -->
123+
119124
#### Completed step
120125
By default, the `completed` attribute of a step returns `true` if the step is valid (in case of
121126
linear stepper) and the user has interacted with the step. The user, however, can also override
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<button mat-raised-button (click)="isEditable = !isEditable">
2+
{{!isEditable ? 'Enable edit mode' : 'Disable edit mode'}}
3+
</button>
4+
5+
<mat-horizontal-stepper [linear]="true" #stepper>
6+
<mat-step [stepControl]="firstFormGroup" [editable]="isEditable">
7+
<form [formGroup]="firstFormGroup">
8+
<ng-template matStepLabel>Fill out your name</ng-template>
9+
<mat-form-field>
10+
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
11+
</mat-form-field>
12+
<div>
13+
<button mat-button matStepperNext>Next</button>
14+
</div>
15+
</form>
16+
</mat-step>
17+
<mat-step [stepControl]="secondFormGroup" [editable]="isEditable">
18+
<form [formGroup]="secondFormGroup">
19+
<ng-template matStepLabel>Fill out your address</ng-template>
20+
<mat-form-field>
21+
<input matInput placeholder="Address" formControlName="secondCtrl" required>
22+
</mat-form-field>
23+
<div>
24+
<button mat-button matStepperPrevious>Back</button>
25+
<button mat-button matStepperNext>Next</button>
26+
</div>
27+
</form>
28+
</mat-step>
29+
<mat-step>
30+
<ng-template matStepLabel>Done</ng-template>
31+
You are now done.
32+
<div>
33+
<button mat-button matStepperPrevious>Back</button>
34+
<button mat-button (click)="stepper.reset()">Reset</button>
35+
</div>
36+
</mat-step>
37+
</mat-horizontal-stepper>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {Component} from '@angular/core';
2+
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3+
4+
/**
5+
* @title Stepper with editable steps
6+
*/
7+
@Component({
8+
selector: 'stepper-editable-example',
9+
templateUrl: 'stepper-editable-example.html',
10+
styleUrls: ['stepper-editable-example.css']
11+
})
12+
export class StepperEditableExample {
13+
firstFormGroup: FormGroup;
14+
secondFormGroup: FormGroup;
15+
isEditable: boolean = false;
16+
17+
constructor(private _formBuilder: FormBuilder) { }
18+
19+
ngOnInit() {
20+
this.firstFormGroup = this._formBuilder.group({
21+
firstCtrl: ['', Validators.required]
22+
});
23+
this.secondFormGroup = this._formBuilder.group({
24+
secondCtrl: ['', Validators.required]
25+
});
26+
}
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/** No CSS for this example */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<button mat-raised-button (click)="isOptional = !isOptional">
2+
{{!isOptional ? 'Enable optional steps' : 'Disable optional steps'}}
3+
</button>
4+
5+
<mat-horizontal-stepper [linear]="true" #stepper>
6+
<mat-step [stepControl]="firstFormGroup">
7+
<form [formGroup]="firstFormGroup">
8+
<ng-template matStepLabel>Fill out your name</ng-template>
9+
<mat-form-field>
10+
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
11+
</mat-form-field>
12+
<div>
13+
<button mat-button matStepperNext>Next</button>
14+
</div>
15+
</form>
16+
</mat-step>
17+
<mat-step [stepControl]="secondFormGroup" [optional]="isOptional">
18+
<form [formGroup]="secondFormGroup">
19+
<ng-template matStepLabel>Fill out your address</ng-template>
20+
<mat-form-field>
21+
<input matInput placeholder="Address" formControlName="secondCtrl" required>
22+
</mat-form-field>
23+
<div>
24+
<button mat-button matStepperPrevious>Back</button>
25+
<button mat-button matStepperNext>Next</button>
26+
</div>
27+
</form>
28+
</mat-step>
29+
<mat-step>
30+
<ng-template matStepLabel>Done</ng-template>
31+
You are now done.
32+
<div>
33+
<button mat-button matStepperPrevious>Back</button>
34+
<button mat-button (click)="stepper.reset()">Reset</button>
35+
</div>
36+
</mat-step>
37+
</mat-horizontal-stepper>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {Component} from '@angular/core';
2+
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3+
4+
/**
5+
* @title Stepper with optional steps
6+
*/
7+
@Component({
8+
selector: 'stepper-optional-example',
9+
templateUrl: 'stepper-optional-example.html',
10+
styleUrls: ['stepper-optional-example.css']
11+
})
12+
export class StepperOptionalExample {
13+
firstFormGroup: FormGroup;
14+
secondFormGroup: FormGroup;
15+
isOptional: boolean = false;
16+
17+
constructor(private _formBuilder: FormBuilder) { }
18+
19+
ngOnInit() {
20+
this.firstFormGroup = this._formBuilder.group({
21+
firstCtrl: ['', Validators.required]
22+
});
23+
this.secondFormGroup = this._formBuilder.group({
24+
secondCtrl: ''
25+
});
26+
}
27+
}

src/material-examples/stepper-overview/stepper-overview-example.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
<button mat-raised-button (click)="isLinear = true" id="toggle-linear">Enable linear mode</button>
2-
3-
<mat-horizontal-stepper [linear]="isLinear" #stepper="matHorizontalStepper">
1+
<button mat-raised-button (click)="isLinear = !isLinear" id="toggle-linear">
2+
{{!isLinear ? 'Enable linear mode' : 'Disable linear mode'}}
3+
</button>
4+
<mat-horizontal-stepper [linear]="isLinear" #stepper>
45
<mat-step [stepControl]="firstFormGroup">
56
<form [formGroup]="firstFormGroup">
67
<ng-template matStepLabel>Fill out your name</ng-template>

0 commit comments

Comments
 (0)