1
0
Fork 0

Add likes/dislikes counts in the buttons

This commit is contained in:
Chocobozzz 2019-12-05 16:28:05 +01:00
parent f56ebb3616
commit 0d3a9be9f1
No known key found for this signature in database
GPG key ID: 583A612D890159BE
3 changed files with 25 additions and 2 deletions

View file

@ -58,19 +58,21 @@
<div class="video-actions-rates"> <div class="video-actions-rates">
<div class="video-actions fullWidth justify-content-end"> <div class="video-actions fullWidth justify-content-end">
<div <div
*ngIf="isUserLoggedIn()" [ngClass]="{ 'activated': userRating === 'like' }" (click)="setLike()" [ngbPopover]="getRatePopoverText()" [ngClass]="{ 'activated': userRating === 'like' }" (click)="setLike()"
class="action-button action-button-like" role="button" [attr.aria-pressed]="userRating === 'like'" class="action-button action-button-like" role="button" [attr.aria-pressed]="userRating === 'like'"
i18n-title title="Like this video" i18n-title title="Like this video"
> >
<my-global-icon iconName="like"></my-global-icon> <my-global-icon iconName="like"></my-global-icon>
<span *ngIf="video.likes" class="count">{{ video.likes }}</span>
</div> </div>
<div <div
*ngIf="isUserLoggedIn()" [ngClass]="{ 'activated': userRating === 'dislike' }" (click)="setDislike()" [ngbPopover]="getRatePopoverText()" [ngClass]="{ 'activated': userRating === 'dislike' }" (click)="setDislike()"
class="action-button action-button-dislike" role="button" [attr.aria-pressed]="userRating === 'dislike'" class="action-button action-button-dislike" role="button" [attr.aria-pressed]="userRating === 'dislike'"
i18n-title title="Dislike this video" i18n-title title="Dislike this video"
> >
<my-global-icon iconName="dislike"></my-global-icon> <my-global-icon iconName="dislike"></my-global-icon>
<span *ngIf="video.dislikes" class="count">{{ video.dislikes }}</span>
</div> </div>
<div *ngIf="video.support" (click)="showSupportModal()" class="action-button action-button-support"> <div *ngIf="video.support" (click)="showSupportModal()" class="action-button action-button-support">

View file

@ -239,9 +239,20 @@ $player-factor: 1.7; // 16/9
display: none; display: none;
} }
.action-button-like,
.action-button-dislike {
.count {
margin-right: 5px;
}
}
&.action-button-like.activated { &.action-button-like.activated {
background-color: $green; background-color: $green;
.count {
color: #fff;
}
my-global-icon { my-global-icon {
@include apply-svg-color(#fff); @include apply-svg-color(#fff);
} }
@ -250,6 +261,10 @@ $player-factor: 1.7; // 16/9
&.action-button-dislike.activated { &.action-button-dislike.activated {
background-color: $red; background-color: $red;
.count {
color: #fff;
}
my-global-icon { my-global-icon {
@include apply-svg-color(#fff); @include apply-svg-color(#fff);
} }

View file

@ -166,6 +166,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
else this.setRating('dislike') else this.setRating('dislike')
} }
getRatePopoverText () {
if (this.isUserLoggedIn()) return undefined
return this.i18n('You need to be connected to rate this content.')
}
showMoreDescription () { showMoreDescription () {
if (this.completeVideoDescription === undefined) { if (this.completeVideoDescription === undefined) {
return this.loadCompleteDescription() return this.loadCompleteDescription()