diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/user_card_content/user_card_content.vue | 33 | ||||
| -rw-r--r-- | src/components/user_profile/user_profile.vue | 17 |
2 files changed, 50 insertions, 0 deletions
diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue index 7ad86e63..d9e661a9 100644 --- a/src/components/user_card_content/user_card_content.vue +++ b/src/components/user_card_content/user_card_content.vue @@ -6,6 +6,24 @@ <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="following-info"> + <div v-if="user.follows_you" class="following"> + Follows you! + </div> + <div class="followed"> + <span v-if="user.following"> + Following them! + <button @click="unfollowUser"> + Unfollow! + </button> + </span> + <span v-if="!user.following" > + <button @click="followUser"> + Follow! + </button> + </span> + </div> + </div> </div> </div> <div class="panel-body"> @@ -37,6 +55,21 @@ 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])) } } } diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index eaa5396d..2ceb13ec 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -5,3 +5,20 @@ </template> <script src="./user_profile.js"></script> + +<style lang="scss"> + .user-profile { + flex: 2; + flex-basis: 500px; + } + + .user-info { + .following-info { + display: flex; + + div { + flex: 1; + } + } + } +</style> |
