diff --git a/src/app/app.component.html b/src/app/app.component.html index 372fa1d..962bea1 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -2,35 +2,36 @@
-

{{housePoints.gryffindor | number}}

- - - +

{{housePoints.gryffindor | number}}

+ + +
-

{{housePoints.ravenclaw | number}}

- - - +

{{housePoints.ravenclaw | number}}

+ + +
-

{{housePoints.hufflepuff | number}}

- - - +

{{housePoints.hufflepuff | number}}

+ + +
-

{{housePoints.slytherin | number}}

- - - +

{{housePoints.slytherin | number}}

+ + +
+ diff --git a/src/app/app.component.sass b/src/app/app.component.sass index 898fc34..cf3a897 100644 --- a/src/app/app.component.sass +++ b/src/app/app.component.sass @@ -1,14 +1,25 @@ +body + background-color: #000000 + .house-column display: table-cell !important float: none !important border-style: solid border-width: 1em + text-align: center + img margin: 1em img.banner max-width: 100% img.crest max-width: 65% + +@media screen and (max-width: 600px) + img.banner + max-width: 40% !important + img.crest + display: none !important #slytherin background-color: #011803 @@ -27,6 +38,12 @@ border-color: #00165e color: #77b7d2 .points - font-size: 7em font-family: Garamond - text-align: center \ No newline at end of file + text-align: center + +@media screen and (min-width: 601px) + .points + font-size: 7em +@media screen and (max-width: 600px) + .points + font-size: 4em diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a0b1207..43e363b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -13,6 +13,7 @@ export class AppComponent implements OnInit { ngOnInit() { this.getHousePoints(); + setInterval(()=>{this.getHousePoints();}, 10000); } getHousePoints(): void { @@ -20,8 +21,12 @@ export class AppComponent implements OnInit { .subscribe(points => this.housePoints = points); } - updateHousePoints(): void { - this.housePointsService.updatePoints$(this.housePoints); + updateHousePoints(housePoints: HousePoints): void { + this.housePointsService.updatePoints$(housePoints) + .subscribe(result => { + console.log(result); + this.getHousePoints(); + }); } title = 'Hogwart\'s Point Keeper'; @@ -29,22 +34,43 @@ export class AppComponent implements OnInit { housePoints: HousePoints; changeGryffindorPoints($event) { - this.housePoints.gryffindor += $event; - this.updateHousePoints(); + this.housePointsService.getPoints$() + .subscribe(points => { + points.gryffindor += $event; + this.updateHousePoints(points); + }); } changeRavenclawPoints($event) { - this.housePoints.ravenclaw += $event; - this.updateHousePoints(); + this.housePointsService.getPoints$() + .subscribe(points => { + points.ravenclaw += $event; + this.updateHousePoints(points); + }); } changeHufflepuffPoints($event) { - this.housePoints.hufflepuff += $event; - this.updateHousePoints(); + this.housePointsService.getPoints$() + .subscribe(points => { + points.hufflepuff += $event; + this.updateHousePoints(points); + }); } changeSlytherinPoints($event) { - this.housePoints.slytherin += $event; - this.updateHousePoints(); + this.housePointsService.getPoints$() + .subscribe(points => { + points.slytherin += $event; + this.updateHousePoints(points); + }); + } + + resetPoints() { + this.updateHousePoints({ + gryffindor:0, + ravenclaw:0, + hufflepuff:0, + slytherin:0 + }); } } diff --git a/src/app/house-points-remote.service.ts b/src/app/house-points-remote.service.ts index 961fc25..6dcb202 100644 --- a/src/app/house-points-remote.service.ts +++ b/src/app/house-points-remote.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { Observable, of } from 'rxjs'; +// import { BehaviorSubject } from 'rxjs'; import { HousePoints } from './HousePoints'; import { HttpClient } from '@angular/common/http'; import { HttpHeaders } from '@angular/common/http'; @@ -26,6 +27,6 @@ export class HousePointsRemoteService { } updatePoints$(points: HousePoints): Observable { - return this.http.post(this.url, points, httpOptions); + return this.http.put(this.url, points, httpOptions); } } diff --git a/src/app/points.component.html b/src/app/points.component.html index 6f4bd79..cea4e0b 100644 --- a/src/app/points.component.html +++ b/src/app/points.component.html @@ -1,3 +1,3 @@ - diff --git a/src/app/points.component.sass b/src/app/points.component.sass new file mode 100644 index 0000000..2894e1d --- /dev/null +++ b/src/app/points.component.sass @@ -0,0 +1,6 @@ +.btn + opacity: 0.5 + margin: 4% + font-family: Garamond + font-weight: bold + font-size: 1.5em \ No newline at end of file diff --git a/src/app/points.component.ts b/src/app/points.component.ts index 9dda6f9..8ccdaf5 100644 --- a/src/app/points.component.ts +++ b/src/app/points.component.ts @@ -3,14 +3,19 @@ import { Component, Output, EventEmitter, Input } from '@angular/core'; @Component({ selector: 'points', templateUrl: './points.component.html', + styleUrls: ['./points.component.sass'] }) export class PointsComponent { - @Input() pointWorth: number; + @Input() amount: number; @Output() changeEvent = new EventEmitter(); - addPoints() { - this.changeEvent.emit(this.pointWorth); + change() { + this.changeEvent.emit(this.amount); + } + + isPositive() { + return this.amount > 0; } } \ No newline at end of file diff --git a/src/assets/img/Harry-potter-ties.jpg b/src/assets/img/Harry-potter-ties.jpg new file mode 100644 index 0000000..bab40c0 Binary files /dev/null and b/src/assets/img/Harry-potter-ties.jpg differ diff --git a/src/index.html b/src/index.html index 96e0c01..e4b92b9 100644 --- a/src/index.html +++ b/src/index.html @@ -8,7 +8,7 @@ - +