aboutsummaryrefslogtreecommitdiff
path: root/src/components/user_card_content/user_card_content.vue
blob: 59cee734570d2cb1ee2ee47e8f8dd285e63a0a86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
  <div>
    <div class="base00-background panel-heading text-center" v-bind:style="style">
      <div class='user-info'>
        <img :src="user.profile_image_url">
        <span class="glyphicon glyphicon-user"></span>
        <div class='user-name'>{{user.name}}</div>
        <div class='user-screen-name'>@{{user.screen_name}}</div>
        <div v-if="isOtherUser" class="user-interactions">
          <div v-if="user.follows_you" class="following base06">
            Follows you!
          </div>
          <div class="follow">
            <span v-if="user.following">
              <!--Following them!-->
              <button @click="unfollowUser" class="base06 base01-background base06-border">
                Unfollow
              </button>
            </span>
            <span v-if="!user.following">
              <button @click="followUser" class="base01 base04-background base01-border">
                Follow
              </button>
            </span>
          </div>
          <div class='mute' v-if='isOtherUser'>
            <span v-if='user.muted'>
              <button @click="toggleMute" class="base04 base01-background base06-border">Unmute</button>
            </span>
            <span v-if='!user.muted'>
              <button @click="toggleMute" class="base01 base04-background base01-border">Mute</button>
            </span>
          </div>
        </div>
      </div>
    </div>
    <div class="panel-body base00-background">
      <div class="user-counts">
        <div class="user-count">
          <h5>Statuses</h5>
          <span>{{user.statuses_count}}</span>
        </div>
        <div class="user-count">
          <h5>Following</h5>
          <span>{{user.friends_count}}</span>
        </div>
        <div class="user-count">
          <h5>Followers</h5>
          <span>{{user.followers_count}}</span>
        </div>
      </div>
      <p>{{user.description}}</p>
    </div>
  </div>
</template>

<script>
  export default {
    props: [ 'user' ],
    computed: {
      style () {
        return {
          color: `#${this.user.profile_link_color}`,
          'background-image': `url(${this.user.cover_photo})`
        }
      },
      isOtherUser () {
        return this.user !== this.$store.state.users.currentUser
      }
    },
    methods: {
      followUser () {
        const store = this.$store
        store.state.api.backendInteractor.followUser(this.user.id)
          .then((followedUser) => store.commit('addNewUsers', [followedUser]))
      },
      unfollowUser () {
        const store = this.$store
        store.state.api.backendInteractor.unfollowUser(this.user.id)
          .then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser]))
      },
      toggleMute () {
        const store = this.$store
        store.commit('setMuted', {user: this.user, muted: !this.user.muted})
        store.state.api.backendInteractor.setUserMute(this.user)
      }
    }
  }
</script>