aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-13 12:54:58 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-13 12:54:58 +0200
commit8419a8e403abf5b25e3b53655cfafabf4eb30a3e (patch)
treeb5cd318de008e796d329a8796d5bd5cd71907ea6 /src/app
parent986ca08271fe0b8fed9e7934d3fd221c2e8b5495 (diff)
downloadDevHive-Angular-8419a8e403abf5b25e3b53655cfafabf4eb30a3e.tar
DevHive-Angular-8419a8e403abf5b25e3b53655cfafabf4eb30a3e.tar.gz
DevHive-Angular-8419a8e403abf5b25e3b53655cfafabf4eb30a3e.zip
Updated the highlight functionalityrating_system
Diffstat (limited to 'src/app')
-rw-r--r--src/app/components/post/post.component.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/app/components/post/post.component.ts b/src/app/components/post/post.component.ts
index b2742c0..bf43a83 100644
--- a/src/app/components/post/post.component.ts
+++ b/src/app/components/post/post.component.ts
@@ -73,20 +73,18 @@ export class PostComponent implements OnInit {
if (Object.values(x)[3] === isLike) {
this.deleteRating(Object.values(x)[0], isLike);
- this.voteBtns.item(Number(!isLike))!.style.backgroundColor = 'white';
- this.voteBtns.item(Number(isLike))!.style.backgroundColor = 'white';
+ this.changeColorOfVoteButton(false, false);
}
else {
this.putRating(isLike);
- this.voteBtns.item(Number(!isLike))!.style.backgroundColor = 'lightblue';
- this.voteBtns.item(Number(isLike))!.style.backgroundColor = 'white';
+ this.changeColorOfVoteButton(isLike, !isLike);
}
},
() => {
this.createRating(isLike);
- this.voteBtns.item(Number(!isLike))!.style.backgroundColor = 'lightblue';
+ this.changeColorOfVoteButton(isLike, !isLike);
}
);
}
@@ -115,4 +113,9 @@ export class PostComponent implements OnInit {
}
);
}
+
+ private changeColorOfVoteButton(isUpvoted: boolean, isDownvoted: boolean): void {
+ this.voteBtns.item(0)!.style.backgroundColor = (isUpvoted) ? 'lightblue' : 'white';
+ this.voteBtns.item(1)!.style.backgroundColor = (isDownvoted) ? 'lightblue' : 'white';
+ }
}