Add likes/dislikes counts in the buttons
authorChocobozzz <me@florianbigard.com>
Thu, 5 Dec 2019 15:28:05 +0000 (16:28 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 5 Dec 2019 15:28:05 +0000 (16:28 +0100)
client/src/app/videos/+video-watch/video-watch.component.html
client/src/app/videos/+video-watch/video-watch.component.scss
client/src/app/videos/+video-watch/video-watch.component.ts

index 5b2e91bc52996bfe32d91a2e9761db28a34f185c..58b2382f0341b12d06339fa6a33a2bfb4a90f3b7 100644 (file)
             <div class="video-actions-rates">
               <div class="video-actions fullWidth justify-content-end">
                 <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'"
                   i18n-title title="Like this video"
                 >
                   <my-global-icon iconName="like"></my-global-icon>
+                  <span *ngIf="video.likes" class="count">{{ video.likes }}</span>
                 </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'"
                   i18n-title title="Dislike this video"
                 >
                   <my-global-icon iconName="dislike"></my-global-icon>
+                  <span *ngIf="video.dislikes" class="count">{{ video.dislikes }}</span>
                 </div>
 
                 <div *ngIf="video.support" (click)="showSupportModal()" class="action-button action-button-support">
index 80d01b7ce36ecd22512d85ff18300fc2c6eec8bf..86b44d5daab81f92700df97e84276c4c8508a38e 100644 (file)
@@ -239,9 +239,20 @@ $player-factor: 1.7; // 16/9
               display: none;
             }
 
+            .action-button-like,
+            .action-button-dislike {
+              .count {
+                margin-right: 5px;
+              }
+            }
+
             &.action-button-like.activated {
               background-color: $green;
 
+              .count {
+                color: #fff;
+              }
+
               my-global-icon {
                 @include apply-svg-color(#fff);
               }
@@ -250,6 +261,10 @@ $player-factor: 1.7; // 16/9
             &.action-button-dislike.activated {
               background-color: $red;
 
+              .count {
+                color: #fff;
+              }
+
               my-global-icon {
                 @include apply-svg-color(#fff);
               }
index 0007331f8651d53a792b862ae7dc1cd68717439f..aacd697cff7f89b67d3712f9c2c9b47c2e914a26 100644 (file)
@@ -166,6 +166,12 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     else this.setRating('dislike')
   }
 
+  getRatePopoverText () {
+    if (this.isUserLoggedIn()) return undefined
+
+    return this.i18n('You need to be connected to rate this content.')
+  }
+
   showMoreDescription () {
     if (this.completeVideoDescription === undefined) {
       return this.loadCompleteDescription()