diff --git a/projects/igniteui-angular/src/lib/stepper/igx-stepper.component.html b/projects/igniteui-angular/src/lib/stepper/igx-stepper.component.html new file mode 100644 index 00000000000..2277fc6c9fd --- /dev/null +++ b/projects/igniteui-angular/src/lib/stepper/igx-stepper.component.html @@ -0,0 +1 @@ + diff --git a/projects/igniteui-angular/src/lib/stepper/igx-stepper.component.ts b/projects/igniteui-angular/src/lib/stepper/igx-stepper.component.ts new file mode 100644 index 00000000000..797e08e2fe6 --- /dev/null +++ b/projects/igniteui-angular/src/lib/stepper/igx-stepper.component.ts @@ -0,0 +1,61 @@ +import { AfterContentInit, Component, ContentChildren, Input, NgModule, OnDestroy, QueryList } from '@angular/core'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; +import { Subject } from 'rxjs'; +import { takeUntil } from 'rxjs/operators'; +import { IgxAccordionModule } from '../accordion/accordion.module'; +import { IgxCarouselModule } from '../carousel/carousel.component'; +import { IBaseEventArgs } from '../core/utils'; +import { IgxStepComponent } from './step/igx-step.component'; + +@Component({ + selector: 'igx-stepper', + templateUrl: 'igx-stepper.component.html' +}) +export class IgxStepperComponent implements AfterContentInit, OnDestroy { + @ContentChildren(IgxStepComponent) + public steps: QueryList; + + @Input() + public linear: boolean; + + private destroy$ = new Subject(); + + public navigateTo(id: number) { + this.steps.forEach(s => { + s.toggleActive(id); + }); + } + + public ngAfterContentInit() { + this.steps.forEach(s => { + s.activated.pipe(takeUntil(this.destroy$)).subscribe((e: IBaseEventArgs) => { + const stepperId = e.owner.id; + this.steps.forEach(_s => { + _s.toggleActive(stepperId); + }); + }); + }); + } + + public ngOnDestroy() { + this.destroy$.next(); + this.destroy$.complete(); + } +} + +@NgModule({ + imports: [ + BrowserAnimationsModule, + IgxCarouselModule, + IgxAccordionModule + ], + declarations: [ + IgxStepComponent, + IgxStepperComponent + ], + exports: [ + IgxStepComponent, + IgxStepperComponent + ] +}) +export class IgxStepperModule { } diff --git a/projects/igniteui-angular/src/lib/stepper/step/igx-step.component.html b/projects/igniteui-angular/src/lib/stepper/step/igx-step.component.html new file mode 100644 index 00000000000..07ee66c6e1d --- /dev/null +++ b/projects/igniteui-angular/src/lib/stepper/step/igx-step.component.html @@ -0,0 +1,4 @@ + + + + diff --git a/projects/igniteui-angular/src/lib/stepper/step/igx-step.component.ts b/projects/igniteui-angular/src/lib/stepper/step/igx-step.component.ts new file mode 100644 index 00000000000..e69290f9aaf --- /dev/null +++ b/projects/igniteui-angular/src/lib/stepper/step/igx-step.component.ts @@ -0,0 +1,53 @@ +import { Component, ContentChild, EventEmitter, HostListener, Input, Output } from '@angular/core'; +import { IBaseEventArgs, mkenum } from '../../core/utils'; +import { IgxIconComponent } from '../../icon/icon.component'; +import { IgxLabelDirective } from '../../input-group/public_api'; + +let NEXT_ID = 0; + +@Component({ + selector: 'igx-step', + templateUrl: 'igx-step.component.html' +}) +export class IgxStepComponent { + @Input() + public id = NEXT_ID++; + + @Input() + public skip: boolean; + + @Input() + public interactable = true; + + @ContentChild(IgxIconComponent) + public icon: IgxIconComponent; + + @ContentChild(IgxLabelDirective) + public label: IgxLabelDirective; + + @Output() + public activated = new EventEmitter(); + + public active: boolean; + + private get inactive() { + return this.skip || !this.interactable; + } + + @HostListener('click') + public onClick() { + if (this.inactive) { + return; + } + + this.activated.emit({ owner: this }); + } + + public toggleActive(id: number) { + if (this.inactive) { + return; + } + + this.active = id === this.id; + } +} diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 289f8e1b686..afaef4d96ff 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -153,6 +153,8 @@ import { GridLocalizationSampleComponent } from './grid-localization/grid-locali import { TreeGridGroupBySampleComponent } from './tree-grid-groupby/tree-grid-groupby.sample'; import { PaginationSampleComponent } from './pagination/pagination.component'; import { GridCellAPISampleComponent } from './grid-cell-api/grid-cell-api.sample'; +import { IgxStepperModule } from 'projects/igniteui-angular/src/lib/stepper/igx-stepper.component'; +import { IgxStepperSampleComponent } from './stepper/stepper.sample'; const components = [ AccordionSampleComponent, @@ -286,7 +288,8 @@ const components = [ GridNestedPropsSampleComponent, IgxColumnGroupingDirective, GridColumnTypesSampleComponent, - GridLocalizationSampleComponent + GridLocalizationSampleComponent, + IgxStepperSampleComponent ]; @NgModule({ @@ -317,7 +320,8 @@ const components = [ routing, HammerModule, IgxDateTimeEditorModule, - IgxButtonModule + IgxButtonModule, + IgxStepperModule ], providers: [ LocalService, diff --git a/src/app/app.routing.ts b/src/app/app.routing.ts index 196a0b79083..e2cc1ac12cc 100644 --- a/src/app/app.routing.ts +++ b/src/app/app.routing.ts @@ -95,6 +95,7 @@ import { GridLocalizationSampleComponent } from './grid-localization/grid-locali import { TreeGridGroupBySampleComponent } from './tree-grid-groupby/tree-grid-groupby.sample'; import { PaginationSampleComponent } from './pagination/pagination.component'; import { GridCellAPISampleComponent } from './grid-cell-api/grid-cell-api.sample'; +import { IgxStepperSampleComponent } from './stepper/stepper.sample'; const appRoutes = [ { @@ -446,6 +447,10 @@ const appRoutes = [ { path: 'pagination', Comment: PaginationSampleComponent + }, + { + path: 'stepper', + component: IgxStepperSampleComponent } ]; diff --git a/src/app/routing.ts b/src/app/routing.ts index 95add95642a..d22f4e8827e 100644 --- a/src/app/routing.ts +++ b/src/app/routing.ts @@ -125,6 +125,7 @@ import { GridLocalizationSampleComponent } from './grid-localization/grid-locali import { TreeGridGroupBySampleComponent } from './tree-grid-groupby/tree-grid-groupby.sample'; import { PaginationSampleComponent } from './pagination/pagination.component'; import { GridCellAPISampleComponent } from './grid-cell-api/grid-cell-api.sample'; +import { IgxStepperSampleComponent as StepperSampleComponent } from './stepper/stepper.sample'; const appRoutes = [ { @@ -598,6 +599,10 @@ const appRoutes = [ },{ path: 'pagination', component: PaginationSampleComponent + }, + { + path: 'stepper', + component: StepperSampleComponent } ]; diff --git a/src/app/stepper/stepper.sample.html b/src/app/stepper/stepper.sample.html new file mode 100644 index 00000000000..09782593eb2 --- /dev/null +++ b/src/app/stepper/stepper.sample.html @@ -0,0 +1,51 @@ + + + +
+ + + + done + +
Test me daddy
+
+ + + calendar_today + + + + + + alarm + + + + + + check_circle + + + Apple + Orange + Grapes + Banana + + + + + delete + +
+ +
+
+
+
+ diff --git a/src/app/stepper/stepper.sample.scss b/src/app/stepper/stepper.sample.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/stepper/stepper.sample.ts b/src/app/stepper/stepper.sample.ts new file mode 100644 index 00000000000..64ffef6bb83 --- /dev/null +++ b/src/app/stepper/stepper.sample.ts @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; + +@Component({ + templateUrl: 'stepper.sample.html', + styleUrls: ['stepper.sample.scss'] +}) +export class IgxStepperSampleComponent { }