Skip to content

Commit 9dadfcf

Browse files
authored
V1.6.0 (#6)
- added a new directive "wizardStepTitle", which enables the developer to create his own title content for the navigation bar in html - added tests for the new WizardStepTitleDirective - expanded the documentation - added typedoc to generate a documentation - add a short introduction about the new wizard-step-title to the README
1 parent 8a9262b commit 9dadfcf

20 files changed

+652
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
/.sass-cache
2727
/connect.lock
2828
/coverage/*
29+
/docs/*
2930
/libpeerconnection.log
3031
npm-debug.log
3132
testem.log

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,24 @@ Possible `<wizard-completion-step>` parameters:
189189
| [navigationSymbolFontFamily] | string | null |
190190
| (stepEnter) | function(MovingDirection) | null |
191191

192+
### \[wizardStepTitle\]
193+
Sometimes it's not enough to define a title with the `title` attribute in `<wizard-step>` and `<wizard-completion-step>`.
194+
One example for such a case is, if the title should be written in another font.
195+
Another example would be if it's desired that the title should be choosen depending on the available width of your screen or window.
196+
In such cases you may want to specify the html for the title of a wizard step yourself.
197+
This can be achieved by using the `[wizardStepTitle]` directive inside a wizard step on a `ng-template` component.
198+
199+
```html
200+
<wizard-step (stepEnter)="enterStep($event)">
201+
<ng-template wizardStepTitle>
202+
<span class="hidden-sm-down">Delivery address</span>
203+
<span class="hidden-md-up">Address</span>
204+
</ng-template>
205+
</wizard-step>
206+
```
207+
208+
Be aware, that you can only use `[wizardStepTitle]` together with Angular, because `ng-template` was introduced in Angular 4.
209+
192210
### \[optionalStep\]
193211
If you need to define an optional step, that doesn't need to be done to continue to the next steps, you can define an optional step
194212
by adding the `optionalStep` directive to the step you want to declare as optional.

gulpfile.babel.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import gulp from 'gulp';
22
import ngc from 'gulp-ngc';
33
import less from 'gulp-less';
44
import inline from 'gulp-inline-ng2-template';
5+
import typedoc from 'gulp-typedoc';
56

67
import rimraf from 'rimraf';
78

@@ -60,4 +61,23 @@ gulp.task('compile', ['inline'], () => {
6061
return ngc('tmp/tsconfig.aot.json');
6162
});
6263

63-
gulp.task('default', ['cleanup', 'move-to-tmp', 'less', 'inline', 'compile']);
64+
/**
65+
* create the typescript documentation in the "./doc" folder
66+
*/
67+
gulp.task('typedoc', ['compile'], () => {
68+
return gulp
69+
.src(["src/**/*.ts", '!src/**/*.spec.ts'])
70+
.pipe(typedoc({
71+
mode: "file",
72+
module: "commonjs",
73+
target: "es6",
74+
out: "docs",
75+
preserveConstEnums: true,
76+
emitDecoratorMetadata: true,
77+
moduleResolution: "node",
78+
stripInternal: true,
79+
experimentalDecorators: true
80+
}));
81+
});
82+
83+
gulp.task('default', ['cleanup', 'move-to-tmp', 'less', 'inline', 'compile', 'typedoc']);

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng2-archwizard",
3-
"version": "1.5.1",
3+
"version": "1.6.0",
44
"license": "MIT",
55
"description": "An angular 2 module containing a wizard component and its supporting components and directives",
66
"homepage": "https://github.com/madoar/ng2-archwizard",
@@ -65,6 +65,7 @@
6565
"gulp-inline-ng2-template": "^4.0.0",
6666
"gulp-less": "^3.3.0",
6767
"gulp-ngc": "^0.3.0",
68+
"gulp-typedoc": "^2.0.2",
6869
"html-loader": "^0.4.0",
6970
"html-webpack-plugin": "^2.28.0",
7071
"istanbul-instrumenter-loader": "^2.0.0",
@@ -96,6 +97,7 @@
9697
"ts-helpers": "^1.1.2",
9798
"tslint": "^5.0.0",
9899
"tslint-loader": "^3.5.1",
100+
"typedoc": "^0.7.1",
99101
"typescript": "^2.2.2",
100102
"typings": "^2.1.0",
101103
"url-loader": "^0.5.6",

src/components/components/wizard-completion-step.component.ts

Lines changed: 82 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,143 @@
22
* Created by marc on 20.05.17.
33
*/
44

5-
import {Component, EventEmitter, HostBinding, Input, Output} from '@angular/core';
5+
import {Component, ContentChild, EventEmitter, HostBinding, Input, Output} from '@angular/core';
66
import {MovingDirection} from '../util/MovingDirection';
77
import {WizardComponent} from './wizard.component';
88
import {WizardStep} from '../util/WizardStep';
9+
import {WizardStepTitleDirective} from '../directives/wizard-step-title.directive';
910

11+
/**
12+
* The `wizard-completion-step` component can be used to define a completion/success step at the end of your wizard
13+
* After a `wizard-completion-step` has been entered, it has the characteristic that the user is blocked from
14+
* leaving it again to a previous step.
15+
* In addition entering a `wizard-completion-step` automatically sets the `wizard` amd all steps inside the `wizard`
16+
* as completed.
17+
*
18+
* ### Syntax
19+
*
20+
* ```html
21+
* <wizard-completion-step [title]="title of the wizard step" [navigationSymbol]="navigation symbol"
22+
* [navigationSymbolFontFamily]="navigation symbol font family"
23+
* (stepEnter)="event emitter to be called when the wizard step is entered"
24+
* (stepExit)="event emitter to be called when the wizard step is exited">
25+
* ...
26+
* </wizard-completion-step>
27+
* ```
28+
*
29+
* ### Example
30+
*
31+
* ```html
32+
* <wizard-completion-step title="Step 1" navigationSymbol="1">
33+
* ...
34+
* </wizard-completion-step>
35+
* ```
36+
*
37+
* With a navigation symbol from the `font-awesome` font:
38+
*
39+
* ```html
40+
* <wizard-completion-step title="Step 1" navigationSymbol="&#xf1ba;" navigationSymbolFontFamily="FontAwesome">
41+
* ...
42+
* </wizard-completion-step>
43+
* ```
44+
*
45+
* @author Marc Arndt
46+
*/
1047
@Component({
1148
selector: 'wizard-completion-step',
1249
templateUrl: 'wizard-completion-step.component.html',
1350
styleUrls: ['wizard-completion-step.component.css']
1451
})
1552
export class WizardCompletionStepComponent implements WizardStep {
1653
/**
17-
* The visible title of this step in the navigation bar of this wizard
54+
* @inheritDoc
55+
*/
56+
@ContentChild(WizardStepTitleDirective)
57+
public titleTemplate: WizardStepTitleDirective;
58+
59+
/**
60+
* @inheritDoc
1861
*/
1962
@Input()
2063
public title: string;
2164

2265
/**
23-
* The symbol which is visible inside the circle belonging to this wizard step in the navigation bar.
24-
*
25-
* @type {string}
66+
* @inheritDoc
2667
*/
2768
@Input()
2869
public navigationSymbol = '';
2970

3071
/**
31-
* The font in which the navigation symbol should be shown.
32-
* If no font is specified the system one should be taken.
72+
* @inheritDoc
3373
*/
3474
@Input()
3575
public navigationSymbolFontFamily: string;
3676

3777
/**
38-
* This EventEmitter is called when this step is entered.
39-
* The bound method should do initializing work.
78+
* This EventEmitter is called when the step is entered.
79+
* The bound method should be used to do initialization work.
4080
*
4181
* @type {EventEmitter<MovingDirection>}
4282
*/
4383
@Output()
4484
public stepEnter = new EventEmitter<MovingDirection>();
4585

4686
/**
47-
* This EventEmitter is called when this step is exited.
87+
* This EventEmitter is called when the step is exited.
88+
* The bound method can be used to do cleanup work.
4889
*
4990
* @type {EventEmitter<MovingDirection>}
5091
*/
5192
public stepExit = new EventEmitter<MovingDirection>();
5293

94+
/**
95+
* Returns if this wizard step should be visible to the user.
96+
* If the step should be visible to the user false is returned, otherwise true
97+
*
98+
* @returns {boolean}
99+
*/
53100
@HostBinding('hidden')
54101
public get hidden(): boolean {
55102
return !this.selected;
56103
}
57104

105+
/**
106+
* @inheritDoc
107+
*/
58108
public completed: false;
109+
110+
/**
111+
* @inheritDoc
112+
*/
59113
public selected = false;
114+
115+
/**
116+
* @inheritDoc
117+
*/
60118
public optional = false;
61119

120+
/**
121+
* @inheritDoc
122+
*/
62123
public canExit: ((direction: MovingDirection) => boolean) | boolean = false;
63124

64-
constructor(private wizard: WizardComponent) {
65-
}
125+
/**
126+
* Constructor
127+
* @param wizard The [[WizardComponent]], this completion step is contained inside
128+
*/
129+
constructor(private wizard: WizardComponent) { }
66130

131+
/**
132+
* @inheritDoc
133+
*/
67134
enter(direction: MovingDirection): void {
68135
this.wizard.completed = true;
69136
this.stepEnter.emit(direction);
70137
}
71138

139+
/**
140+
* @inheritDoc
141+
*/
72142
exit(direction: MovingDirection): void {
73143
// do nothing
74144
}

src/components/components/wizard-navigation-bar.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
optional: step.optional && !step.completed && !step.selected && !wizard.completed
1313
}">
1414
<div>
15-
<a [goToStep]="step">{{step.title}}</a>
15+
<a [goToStep]="step">
16+
<ng-container *ngIf="step.titleTemplate" [ngTemplateOutlet]="step.titleTemplate.templateRef"></ng-container>
17+
<ng-container *ngIf="!step.titleTemplate">{{step.title}}</ng-container>
18+
</a>
1619
</div>
1720
</li>
1821
</ul>

src/components/components/wizard-navigation-bar.component.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,46 @@ import {Component} from '@angular/core';
22
import {WizardComponent} from './wizard.component';
33
import {WizardStep} from '../util/WizardStep';
44

5+
/**
6+
* The `wizard-navigation-bar` component contains the navigation bar inside a [[WizardComponent]].
7+
* To correctly display the navigation bar, it's required to set the right css classes for the navigation bar,
8+
* otherwise it will look like a normal `ul` component.
9+
*
10+
* ### Syntax
11+
*
12+
* ```html
13+
* <wizard-navigation-bar></wizard-navigation-bar>
14+
* ```
15+
*
16+
* @author Marc Arndt
17+
*/
518
@Component({
619
selector: 'wizard-navigation-bar',
720
templateUrl: 'wizard-navigation-bar.component.html',
821
styleUrls: ['wizard-navigation-bar.component.horizontal.less', 'wizard-navigation-bar.component.vertical.less']
922
})
1023
export class WizardNavigationBarComponent {
11-
24+
/**
25+
* Constructor
26+
*
27+
* @param wizard The wizard, which includes this navigation bar
28+
*/
1229
constructor(private wizard: WizardComponent) { }
1330

31+
/**
32+
* Returns all [[WizardStep]]s contained in the wizard
33+
*
34+
* @returns {Array<WizardStep>} An array containing all [[WizardStep]]s
35+
*/
1436
get wizardSteps(): Array<WizardStep> {
1537
return this.wizard.allSteps;
1638
}
1739

40+
/**
41+
* Returns the number of wizard steps, that need to be displaced in the navigation bar
42+
*
43+
* @returns {number} The number of wizard steps to be displayed
44+
*/
1845
get numberOfWizardSteps(): number {
1946
return this.wizard.allSteps.length;
2047
}

0 commit comments

Comments
 (0)