1- import { Component , ContentChildren , QueryList , AfterContentInit , Output } from '@angular/core' ;
1+ import { Component , ContentChildren , QueryList , AfterContentInit , Input , Output } from '@angular/core' ;
22import { StepComponent } from './step' ;
33
44
@@ -8,9 +8,14 @@ import { StepComponent } from './step';
88 <div class="uk-wizard">
99 <div class="uk-wizard-nav">
1010 <ul>
11- <li *ngFor="let item of items" (click)="navClicked(item.id)" [style.width.%]="navWidth">
11+ <li *ngFor="let item of items" (click)="navClicked(item.id)"
12+ [style.width.%]="navWidth">
13+ <div class="uk-li" [style.border-bottom-color]="color">
1214 <span *ngIf="item.step.title">{{item.step.title}}</span>
1315 <span *ngIf="!item.step.title">Step {{item.id +1}}</span>
16+ </div>
17+ <div class="uk-overlay" [class.active]="item.id===currentStepIndex">
18+ </div>
1419 </li>
1520 </ul>
1621 </div>
@@ -26,21 +31,44 @@ import { StepComponent } from './step';
2631 }
2732 .uk-wizard-nav{
2833 width: 100%;
29-
3034 }
3135 .uk-wizard-steps{
3236 width: 100%
3337 }
3438 ul{
3539 padding: 0px;
40+ margin: 0px;
3641 }
3742 li{
3843 display: inline-block;
3944 min-width: 100px;
4045 overflow: hidden;
41- text-align: center;
46+ position: relative;
47+ }
48+ .uk-li{
49+ width: 100%;
4250 border-bottom: 5px solid;
43- padding: 5px 0px 5px 0px;
51+ padding: 10px 0px 5px 0px;
52+ text-align: center;
53+ }
54+ li:hover{
55+ cursor:pointer;
56+ }
57+ .uk-overlay{
58+ position: absolute;
59+ bottom: 0px;
60+ right: 0px;
61+ width: 100%;
62+ height: 5px;
63+ opacity: .8;
64+ background-color: #ccc;
65+ }
66+ .uk-overlay.active{
67+ opacity: 0.0;
68+ }
69+ :host >>> #uk-back, :host >>> #uk-next{
70+ min-width: 50px;
71+ padding: 5px;
4472 }
4573
4674 ` ]
@@ -51,6 +79,7 @@ export class WizardComponent implements AfterContentInit{
5179 currentStepIndex : number = 0 ;
5280 currentStep : string ;
5381 navWidth : number ;
82+ @Input ( ) color : string = 'blue' ;
5483 @ContentChildren ( StepComponent ) steps : QueryList < StepComponent > ;
5584
5685 navClicked ( id : number ) {
@@ -64,9 +93,11 @@ export class WizardComponent implements AfterContentInit{
6493 let i = 0 ;
6594 this . items = this . steps . map ( ( r ) => { return { step : r , id : i ++ } ; } ) ;
6695 this . items [ this . currentStepIndex ] . step . activeStep = true ; // setting default step as active step.
67- this . navWidth = 100 / this . items . length ;
96+ this . items [ 0 ] . step . firstStep = true ;
97+ this . items [ this . items . length - 1 ] . step . lastStep = true ;
98+ this . navWidth = 100 / this . items . length ;
6899 this . steps . forEach ( ( r ) => {
69- r . onBack . subscribe ( ( title : StepComponent ) => {
100+ r . onBack . subscribe ( ( title : StepComponent ) => {
70101 if ( this . currentStepIndex === 0 ) {
71102 console . log ( "you cannot go back from here!!" ) ;
72103 }
@@ -78,8 +109,8 @@ export class WizardComponent implements AfterContentInit{
78109 console . log ( this . currentStep ) ;
79110 }
80111 } ) ;
81- r . onNext . subscribe ( ( title : StepComponent ) => {
82- if ( this . currentStepIndex == this . items . length - 1 ) {
112+ r . onNext . subscribe ( ( title : StepComponent ) => {
113+ if ( this . currentStepIndex == this . items . length - 1 ) {
83114 //TODO call on finish
84115 console . log ( "Finished" ) ;
85116 }
0 commit comments