Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
add stepper component
Browse files Browse the repository at this point in the history
  • Loading branch information
syjer committed Apr 4, 2019
1 parent ea65a48 commit d7fc81a
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { HttpClientModule, HttpClientXsrfModule, HttpClient } from '@angular/

import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { library } from '@fortawesome/fontawesome-svg-core';
import { faInfoCircle, faGift, faTicketAlt } from '@fortawesome/free-solid-svg-icons'
import { faInfoCircle, faGift, faTicketAlt, faCheck, faAddressCard, faFileAlt, faThumbsUp, faMoneyBill } from '@fortawesome/free-solid-svg-icons'
import { faCalendarAlt, faCalendarPlus, faCalendarCheck, faCompass, faClock } from '@fortawesome/free-regular-svg-icons';
import { faGoogle } from '@fortawesome/free-brands-svg-icons'
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
Expand All @@ -21,6 +21,7 @@ import { OverviewComponent } from './reservation/overview/overview.component';
import { SuccessComponent } from './reservation/success/success.component';
import { ReservationComponent } from './reservation/reservation.component';
import { EventHeaderComponent } from './event-header/event-header.component';
import { StepperComponent } from './stepper/stepper.component';



Expand All @@ -38,7 +39,8 @@ export function HttpLoaderFactory(http: HttpClient) {
OverviewComponent,
SuccessComponent,
ReservationComponent,
EventHeaderComponent
EventHeaderComponent,
StepperComponent
],
imports: [
BrowserModule,
Expand All @@ -64,7 +66,7 @@ export function HttpLoaderFactory(http: HttpClient) {
})
export class AppModule {
constructor() {
library.add(faInfoCircle, faGift, faTicketAlt);
library.add(faInfoCircle, faGift, faTicketAlt, faCheck, faAddressCard, faFileAlt, faThumbsUp, faMoneyBill);
library.add(faCalendarAlt, faCalendarPlus, faCalendarCheck, faCompass, faClock);
library.add(faGoogle);
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/reservation/booking/booking.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

<hr>
<app-stepper [currentStep]="2"></app-stepper>
<hr>
<div *ngIf="reservation">
<form [formGroup]="contactAndTicketsForm" (submit)="submitForm(reservation.event.shortName, reservation.reservationId, contactAndTicketsForm.value)">
Expand Down
3 changes: 3 additions & 0 deletions src/app/reservation/overview/overview.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<hr>
<app-stepper [currentStep]="3"></app-stepper>

<div *ngIf="overview">

<form [formGroup]="overviewForm" (submit)="confirm(overview.event.shortName, overview.reservationId, overviewForm.value)">
Expand Down
31 changes: 31 additions & 0 deletions src/app/stepper/stepper.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="wizard2 center text-muted">
<div [ngClass]="{'wizard2-current': currentStep === 1}">
<div>
<span class="badge" [ngClass]="{'badge-success': currentStep > 1 }"><fa-icon [icon]="['fas', 'check']"></fa-icon></span>
<span translate="breadcrumb.step1"></span>
</div>
<div class="wizard2-line"></div>
</div>
<div [ngClass]="{'wizard2-current': currentStep === 2}">
<div>
<span class="badge" [ngClass]="{'badge-success': currentStep > 2 }"><fa-icon [icon]="currentStep > 2 ? ['fas', 'check'] : ['fas', 'address-card']"></fa-icon></span>
<span translate="breadcrumb.step2"></span>
</div>
<div class="wizard2-line"></div>
</div>
<div [ngClass]="{'wizard2-current': currentStep === 3}">
<div>
<span class="badge" [ngClass]="{'badge-success': currentStep > 3 }">
<fa-icon *ngIf="free" [icon]="currentStep > 3 ? ['fas', 'check'] : ['fas', 'file-alt']"></fa-icon>
<fa-icon *ngIf="!free" [icon]="currentStep > 3 ? ['fas', 'check'] : ['fas', 'money-bill']"></fa-icon>
</span>
<span [translate]="'breadcrumb.step3'+(free ? '.free' : '')"></span></div>
<div class="wizard2-line"></div>
</div>
<div [ngClass]="{'wizard2-current': currentStep === 4}">
<div>
<span class="badge" [ngClass]="{'badge-success': currentStep > 4 }"><fa-icon [icon]="['fas', 'thumbs-up']"></fa-icon></span>
<span translate="breadcrumb.step4"></span>
</div>
</div>
</div>
59 changes: 59 additions & 0 deletions src/app/stepper/stepper.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* based on https://material-ui.com/demos/steppers/ */
.wizard2 {
display: flex;
flex-direction: row;
align-items: flex-start;
margin: 4rem 0;
}

.wizard2 > div {
flex: 1;
position:relative
}

.wizard2 > div > div:first-child {
flex-direction: column;
display: flex;
align-items: center;
}

.wizard2 .badge {
display: inline-block;
min-width: 35px;
padding: 3px 7px;
font-size: 14px;
font-weight: 700;
line-height: 2;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: top;
background-color: #777;
border-radius: 17px;
min-height: 30px;
}

.wizard2 .wizard2-line {
top: 17px;
left: calc(50% + 20px);
right: calc(-50% + 20px);
position: absolute;
border-top: 1px solid #bdbdbd;
}

.badge-success {
background-color: #449d44 !important;
}

.wizard2 .wizard2-current .badge {
background-color: #007ACC;
}

.wizard2 span:nth-child(2) {
margin-top: 1em;
}

.wizard2 .wizard2-current span:nth-child(2) {
font-weight:bold;
color: black;
}
25 changes: 25 additions & 0 deletions src/app/stepper/stepper.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { StepperComponent } from './stepper.component';

describe('StepperComponent', () => {
let component: StepperComponent;
let fixture: ComponentFixture<StepperComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ StepperComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(StepperComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
21 changes: 21 additions & 0 deletions src/app/stepper/stepper.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Component, OnInit, Input } from '@angular/core';

@Component({
selector: 'app-stepper',
templateUrl: './stepper.component.html',
styleUrls: ['./stepper.component.scss']
})
export class StepperComponent implements OnInit {

@Input()
free: boolean = true;

@Input()
currentStep: number = 1;

constructor() { }

ngOnInit() {
}

}

0 comments on commit d7fc81a

Please sign in to comment.