]> cat aescling's git repositories - mastodon.git/commitdiff
Add interrelationship icon (#15149)
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Thu, 12 Nov 2020 16:43:12 +0000 (01:43 +0900)
committerGitHub <noreply@github.com>
Thu, 12 Nov 2020 16:43:12 +0000 (17:43 +0100)
* Add interrelationship icon

* Fix arrow for rtl

* Fix to predefined color

app/controllers/relationships_controller.rb
app/helpers/application_helper.rb
app/javascript/styles/mastodon/variables.scss
app/javascript/styles/mastodon/widgets.scss
app/views/relationships/_account.html.haml

index 031e3241f902426a0597d0106f7b63fb0710e54f..96cce55e9e4f6ecf30066d16f169113086a2607b 100644 (file)
@@ -5,6 +5,7 @@ class RelationshipsController < ApplicationController
 
   before_action :authenticate_user!
   before_action :set_accounts, only: :show
+  before_action :set_relationships, only: :show
   before_action :set_body_classes
 
   helper_method :following_relationship?, :followed_by_relationship?, :mutual_relationship?
@@ -28,6 +29,10 @@ class RelationshipsController < ApplicationController
     @accounts = RelationshipFilter.new(current_account, filter_params).results.page(params[:page]).per(40)
   end
 
+  def set_relationships
+    @relationships = AccountRelationshipsPresenter.new(@accounts.pluck(:id), current_user.account_id)
+  end
+
   def form_account_batch_params
     params.require(:form_account_batch).permit(:action, account_ids: [])
   end
index 5512a9543413c9c5c783e9e8b464d90ca710a63b..8914b015ce34c3ebf4229188b92fca6b8278c4e7 100644 (file)
@@ -89,6 +89,16 @@ module ApplicationHelper
     end
   end
 
+  def interrelationships_icon(relationships, account_id)
+    if relationships.following[account_id] && relationships.followed_by[account_id]
+      fa_icon('exchange', title: I18n.t('relationships.mutual'), class: 'fa-fw active passive')
+    elsif relationships.following[account_id]
+      fa_icon(locale_direction == 'ltr' ? 'arrow-right' : 'arrow-left', title: I18n.t('relationships.following'), class: 'fa-fw active')
+    elsif relationships.followed_by[account_id]
+      fa_icon(locale_direction == 'ltr' ? 'arrow-left' : 'arrow-right', title: I18n.t('relationships.followers'), class: 'fa-fw passive')
+    end
+  end
+
   def custom_emoji_tag(custom_emoji, animate = true)
     if animate
       image_tag(custom_emoji.image.url, class: 'emojione', alt: ":#{custom_emoji.shortcode}:")
index 8602c3dde9d5a38103805d77de5c76187a8892c2..f463419c8203ca3e6405c900f3732904dc99b40c 100644 (file)
@@ -36,6 +36,8 @@ $dark-text-color: $ui-base-lighter-color !default;
 $secondary-text-color: $ui-secondary-color !default;
 $highlight-text-color: $ui-highlight-color !default;
 $action-button-color: $ui-base-lighter-color !default;
+$passive-text-color: $gold-star !default;
+$active-passive-text-color: $success-green !default;
 // For texts on inverted backgrounds
 $inverted-text-color: $ui-base-color !default;
 $lighter-text-color: $ui-base-lighter-color !default;
index 47e02d41df20fbe25f08ec5a4a4a71f9b5b8a371..5ee4d104bad6d0c4d0edc75fd8a659bc6b616e72 100644 (file)
     vertical-align: initial !important;
   }
 
+  &__interrelationships {
+    width: 21px;
+  }
+
+  .fa {
+    font-size: 16px;
+
+    &.active {
+      color: $highlight-text-color;
+    }
+
+    &.passive {
+      color: $passive-text-color;
+    }
+
+    &.active.passive {
+      color: $active-passive-text-color;
+    }
+  }
+
   @media screen and (max-width: $no-gap-breakpoint) {
     tbody td.optional {
       display: none;
index af5a4aaf7d0fce7a1c897e3c9225ed90b47a2d84..f521aff2258ed2bbe3650adfc54797d3da6c6fe4 100644 (file)
@@ -5,6 +5,8 @@
     %table.accounts-table
       %tbody
         %tr
+          %td.accounts-table__interrelationships
+            = interrelationships_icon(@relationships, account.id)
           %td= account_link_to account
           %td.accounts-table__count.optional
             = number_to_human account.statuses_count, strip_insignificant_zeros: true