]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix avatar responsive
authorChocobozzz <me@florianbigard.com>
Mon, 2 May 2022 11:46:09 +0000 (13:46 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 2 May 2022 11:46:09 +0000 (13:46 +0200)
client/src/app/+accounts/accounts.component.html
client/src/app/+video-channels/video-channels.component.html
client/src/app/+video-channels/video-channels.component.scss
client/src/app/shared/shared-actor-image/actor-avatar.component.ts
client/src/app/shared/shared-main/account/account.model.ts
client/src/app/shared/shared-main/account/actor.model.ts
client/src/sass/include/_account-channel-page.scss

index 1544ad0349d60fce100e04ebcd6dc8d66f8db6b6..8362e6b7e50bfa5f30bdd6882c16ce8b165e3dc3 100644 (file)
@@ -2,7 +2,7 @@
   <div class="account-info">
 
     <div class="account-avatar-row">
-      <my-actor-avatar class="main-avatar" [account]="account" size="120"></my-actor-avatar>
+      <my-actor-avatar class="main-avatar" [account]="account"></my-actor-avatar>
 
       <div>
         <div class="section-label" i18n>ACCOUNT</div>
index 09f81d2ce6efe9c175bab9de9d04640c08eec2ae..212e2f8671454e0d60f6cd02e34263726d21c41a 100644 (file)
@@ -23,7 +23,7 @@
         <div class="section-label" i18n>OWNER ACCOUNT</div>
 
         <div class="avatar-row">
-          <my-actor-avatar class="account-avatar" [account]="ownerAccount" [internalHref]="getAccountUrl()" size="48"></my-actor-avatar>
+          <my-actor-avatar class="account-avatar" [account]="ownerAccount" [internalHref]="getAccountUrl()"></my-actor-avatar>
 
           <div class="actor-info">
             <h4>
@@ -51,7 +51,7 @@
     </ng-template>
 
     <div class="channel-avatar-row">
-      <my-actor-avatar class="main-avatar" [channel]="videoChannel" size="120"></my-actor-avatar>
+      <my-actor-avatar class="main-avatar" [channel]="videoChannel"></my-actor-avatar>
 
       <div>
         <div class="section-label" i18n>VIDEO CHANNEL</div>
index 004ad7998526d6faef52a649c5852964e567cdce..c00dacae59c65b139cdaa8930f196fb5fed45099 100644 (file)
       font-size: var(--myGreyOwnerFontSize);
       color: pvar(--greyForegroundColor);
     }
+
+    .account-avatar {
+      @include actor-avatar-size(48px);
+    }
   }
 
   .owner-description {
index b2e1ef46eac4f47af403c645c7959453d3368045..600984aa2d6baaa402d89af2bb292179daf7e209 100644 (file)
@@ -23,7 +23,7 @@ export class ActorAvatarComponent {
 
   @Input() previewImage: string
 
-  @Input() size: ActorAvatarSize = '32'
+  @Input() size: ActorAvatarSize
 
   // Use an external link
   @Input() href: string
@@ -50,13 +50,13 @@ export class ActorAvatarComponent {
   }
 
   get defaultAvatarUrl () {
-    if (this.account) return Account.GET_DEFAULT_AVATAR_URL(+this.size)
-    if (this.channel) return VideoChannel.GET_DEFAULT_AVATAR_URL(+this.size)
+    if (this.account) return Account.GET_DEFAULT_AVATAR_URL(this.getSizeNumber())
+    if (this.channel) return VideoChannel.GET_DEFAULT_AVATAR_URL(this.getSizeNumber())
   }
 
   get avatarUrl () {
-    if (this.account) return Account.GET_ACTOR_AVATAR_URL(this.account, +this.size)
-    if (this.channel) return VideoChannel.GET_ACTOR_AVATAR_URL(this.channel, +this.size)
+    if (this.account) return Account.GET_ACTOR_AVATAR_URL(this.account, this.getSizeNumber())
+    if (this.channel) return VideoChannel.GET_ACTOR_AVATAR_URL(this.channel, this.getSizeNumber())
 
     return ''
   }
@@ -88,6 +88,12 @@ export class ActorAvatarComponent {
     return !!this.account || !!this.channel
   }
 
+  private getSizeNumber () {
+    if (this.size) return +this.size
+
+    return undefined
+  }
+
   private getColorTheme () {
     const initialLowercase = this.initial.toLowerCase()
 
index a26a9c11cc274f5f122f61e20f1fa702b29422e9..e34f6ef642ff7e2cd720abd9179409d2f903a613 100644 (file)
@@ -17,12 +17,12 @@ export class Account extends Actor implements ServerAccount {
 
   userId?: number
 
-  static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size: number) {
+  static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size?: number) {
     return Actor.GET_ACTOR_AVATAR_URL(actor, size)
   }
 
-  static GET_DEFAULT_AVATAR_URL (size: number) {
-    if (size <= 48) {
+  static GET_DEFAULT_AVATAR_URL (size?: number) {
+    if (size && size <= 48) {
       return `${window.location.origin}/client/assets/images/default-avatar-account-48x48.png`
     }
 
index 977fdb7e53215ea1b112c10069a07934c7295de3..8427c990299529c7313542398793d5d591680eda 100644 (file)
@@ -20,8 +20,12 @@ export abstract class Actor implements ServerActor {
 
   isLocal: boolean
 
-  static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size: number) {
-    const avatar = actor.avatars.sort((a, b) => a.width - b.width).find(a => a.width >= size)
+  static GET_ACTOR_AVATAR_URL (actor: { avatars: { width: number, url?: string, path: string }[] }, size?: number) {
+    const avatars = actor.avatars.sort((a, b) => a.width - b.width)
+
+    const avatar = size
+      ? avatars.find(a => a.width >= size)
+      : avatars[0]
 
     if (!avatar) return ''
     if (avatar.url) return avatar.url
index 06384b98d37dab7375f9d6f78417693a8422b232..f05b8169e5cea87cc378cfd564ae3b48f76180a5 100644 (file)
     color: pvar(--mainColor);
   }
 
+  .main-avatar {
+    @include actor-avatar-size(120px);
+  }
+
   @media screen and (max-width: $mobile-view) {
     margin-bottom: 15px;