Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
Support emoji picker.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Aug 24, 2019
1 parent 5de037c commit 4e6515c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
"url": "git+https://github.com/halo-dev/halo-comment.git"
},
"author": "halo-dev",
"contributors": ["ruibaby","johnniang"],
"contributors": [
"ruibaby",
"johnniang"
],
"bugs": {
"url": "https://github.com/halo-dev/halo-comment/issues"
},
Expand All @@ -25,6 +28,7 @@
"md5": "^2.2.1",
"nprogress": "^0.2.0",
"simplemde": "^1.11.2",
"v-emoji-picker": "^1.1.5",
"vue": "^2.6.10"
},
"devDependencies": {
Expand Down
34 changes: 32 additions & 2 deletions src/components/CommentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
@click.self="close"
@keydown.esc.once="close"
>
<div class="comment-poster-editor-emoji">
<VEmojiPicker
:pack="pack"
@select="selectEmoji"
v-show="emojiDialogVisible"
labelSearch="搜索"
/>
</div>
<div class="comment-modal-container">
<div class="comment-poster-container active">
<ul class="comment-poster-controls">
Expand Down Expand Up @@ -81,6 +89,15 @@
@click="handlePreviewClick"
>预览</button>
</li>
<li class="editor-item-emoji">
<button
class="editor-btn-emoji"
type="button"
@click="toogleDialogEmoji"
>
😃
</button>
</li>
</ul>
</div>
</div>
Expand All @@ -94,11 +111,16 @@

<script>
import md5 from 'md5'
import VEmojiPicker from 'v-emoji-picker'
import packData from 'v-emoji-picker/data/emojis.json'
import { isEmpty } from '../utils/util'
import commentApi from '../apis/comment'
export default {
name: 'CommentEditor',
components: {
VEmojiPicker
},
props: {
targetId: {
type: Number,
Expand Down Expand Up @@ -126,11 +148,13 @@ export default {
},
data() {
return {
pack: packData,
emojiDialogVisible: false,
comment: {
author: null,
authorUrl: null,
email: null,
content: null
content: ''
}
}
},
Expand All @@ -153,14 +177,20 @@ export default {
this.comment.email = localStorage.getItem('comment-email')
},
methods: {
toogleDialogEmoji() {
this.emojiDialogVisible = !this.emojiDialogVisible
},
selectEmoji(emoji) {
this.comment.content += emoji.emoji
this.toogleDialogEmoji()
},
close() {
this.$emit('close', false)
},
exit() {
if (this.comment.content && !window.confirm('评论还未发布,是否放弃?')) {
return
}
this.$emit('exit', false)
},
handleAuthorInput() {
Expand Down
19 changes: 19 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,25 @@
cursor: pointer;
transition: all 0.4s ease-in-out;

&:hover {
background-color: #d7dfea;
transition: all 0.4s ease-in-out;
}
}
}
.editor-item-emoji {
.editor-btn-emoji {
font-size: inherit;
font-family: inherit;
color: #667c99;
padding: 0.5em 1em;
outline: none;
border: none;
background-color: #e8ecf3;
border-radius: 4px;
cursor: pointer;
transition: all 0.4s ease-in-out;

&:hover {
background-color: #d7dfea;
transition: all 0.4s ease-in-out;
Expand Down

0 comments on commit 4e6515c

Please sign in to comment.