Skip to content

Commit

Permalink
Merge pull request #637 from SoftwareEngineeringDaily/feat/634-new-us…
Browse files Browse the repository at this point in the history
…er-route

[#634] Comment mentions (user tags)
  • Loading branch information
sterlingrules committed Feb 14, 2020
2 parents fdcfaf0 + fdb9e3f commit 37f7f83
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 81 deletions.
27 changes: 0 additions & 27 deletions index.html
Expand Up @@ -27,33 +27,6 @@
bottom: 0;
position: fixed!important;
}
.tribute-container li {
background: white;
padding: 10px 20px;
list-style: none;
border-bottom: 1px solid rgb(238, 238, 238);
box-shadow: 0 3px 10px rgb(238, 238, 238), 0 3px 10px rgb(238, 238, 238);
}
ul.tribute-container {
border-radius: 5px;
}
.tribute-container li.highlight {
background: rgb(238, 238, 238);
padding: 10 20px;
}

.tribute-container li:hover {
background: rgb(238, 238, 238);
cursor: pointer;
padding: 10 20px;
}

.tribute-container li.no-match {
display: none;
}
.tribute-container img {
padding-right: 5px;
}

</style>
</head>
Expand Down
45 changes: 0 additions & 45 deletions src/components/VueTribute.js

This file was deleted.

17 changes: 10 additions & 7 deletions src/components/comment/CommentForm.vue
@@ -1,6 +1,11 @@
<template>
<div v-if="me" class="comment-container">
<vue-tribute
<!-- <span class="active-without-border" v-if="isLoggedIn">
<router-link class="profile-img-link" to="/profile">
<img class="profile-img" :src="errorImg || avatarUrl" @error="imgOnError">
</router-link>
</span> -->
<CommentTribute
class="comment-box__container"
:options="options"
@tribute-replaced="tributeReplaced"
Expand All @@ -13,8 +18,7 @@
type="text"
v-model="commentContent"
/>
</vue-tribute>

</CommentTribute>
<div v-if="isLoggedIn" style="align-self: flex-end;">
<div v-if="isSubmitting">
<spinner :show="true"></spinner>
Expand All @@ -26,7 +30,6 @@
@click="submitComment">
{{submitButtonText}}
</button>

<button v-if="showCancel" class='btn-cancel btn btn-link'
:disabled="isSubmitting"
@click='cancelPressed'><i class="fa fa-times"/></button>
Expand All @@ -39,7 +42,7 @@
</template>

<script>
import VueTribute from "@/components/VueTribute.js";
import CommentTribute from "@/components/comment/CommentTribute";
import ProfileLabel from "@/components/profile/ProfileLabel";
import { debounce, each, map } from "lodash";
import Spinner from "@/components/Spinner";
Expand Down Expand Up @@ -88,7 +91,7 @@ export default {
},
},
components: {
VueTribute,
CommentTribute,
ProfileLabel,
Spinner
},
Expand All @@ -105,7 +108,7 @@ export default {
} </span>`;
},
noMatchTemplate: "",
allowSpaces: true,
allowSpaces: false,
values: []
},
mentionedUsers: this.existingMentions,
Expand Down
81 changes: 81 additions & 0 deletions src/components/comment/CommentTribute.vue
@@ -0,0 +1,81 @@
<script>
import Tribute from 'tributejs'
export default {
name: 'vue-tribute',
props: {
options: {
type: Object,
required: true
}
},
data() {
return {
tribute: null
}
},
mounted() {
const $el = this.$slots.default[0].elm
this.tribute = new Tribute(this.options)
this.tribute.attach($el)
$el.addEventListener('tribute-replaced', e => {
this.$emit('tribute-replaced', e)
})
$el.addEventListener('tribute-no-match', e => {
this.$emit('tribute-no-match', this.tribute.current.mentionText)
})
},
render(h) {
return h(
'div',
{
staticClass: 'v-tribute'
},
this.$slots.default
)
}
}
</script>

<style>
.tribute-container ul {
max-height: 240px;
overflow: auto;
padding: 0;
margin: 10px;
border: 1px solid #c5c5c5;
}
.tribute-container li {
background: white;
padding: 10px;
list-style: none;
box-shadow: 0 3px 10px rgb(238, 238, 238), 0 3px 10px rgb(238, 238, 238);
}
.tribute-container li:not(:last-child) {
border-bottom: 1px solid #c5c5c5;
}
ul.tribute-container {
border-radius: 5px;
}
.tribute-container li.highlight {
background: #a591ff;
}
.tribute-container li:hover {
background: #a591ff;
cursor: pointer;
}
.tribute-container li.no-match {
display: none;
}
.tribute-container img {
border-radius: 3px;
width: 26px;
background: #fff;
margin-right: 5px;
}
</style>
4 changes: 2 additions & 2 deletions src/store/actions/user.actions.js
Expand Up @@ -24,8 +24,8 @@ export default {
})
},

searchUsers: ({ commit, state, getters }, { name }) => {
return axios.get(`${BASE_URL}/users/search?name=${name}`)
searchUsers: (_, { name }) => {
return axios.get(`${BASE_URL}/users/search/names?name=${name}`)
.then(({data}) => {
return data
})
Expand Down

0 comments on commit 37f7f83

Please sign in to comment.