Skip to content

Commit b109897

Browse files
committed
Merge branch 'master' into build
2 parents d886539 + a39dee4 commit b109897

File tree

5 files changed

+80
-46
lines changed

5 files changed

+80
-46
lines changed

README.md

+44-25
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,26 @@
22

33
[![codecov](https://codecov.io/gh/serebrov/emoji-mart-vue/branch/master/graph/badge.svg)](https://codecov.io/gh/serebrov/emoji-mart-vue)
44

5-
This project is a fork of https://github.com/jm-david/emoji-mart-vue with many performance fixes, tests and some structural code changes.
5+
This project is a fork of https://github.com/jm-david/emoji-mart-vue with many performance fixes, tests and structural code changes.
6+
See the [changelog](#changelog) for details.
67

78
The original component was [very slow to show/destroy](https://github.com/jm-david/emoji-mart-vue/pull/47), around 2 seconds to show and even a bit longer to destroy, so it was unusable in a popup.
89

910
This was the reason to fork and change it, the demo is [here](https://serebrov.github.io/emoji-mart-vue/), use the "Show / hide the picker" button to see create/destroy performance
1011

11-
Major changes are:
12-
13-
- Reworked emoji index class: use same index (so same data) for all components.
14-
- Render emojis in categories without `Emoji` component, there are a lot of emojis to render and there is a noticeable slow down when we render a component per emoji.
15-
- Frozen objects with emoji data to disable Vue change tracking
16-
- Do not create `EmojiIndex` globally, before it was loaded (along with the emoji data) even when it was not actually used
17-
- Extract CSS into external file, use less inline styles to reduce the amount of generated HTML
18-
- Fixes in CSS for native unicode emojis ported from the [original react project](https://github.com/missive/emoji-mart)
19-
- Excluded ./data/all.json from the js bundle (it was always loaded within the bundle even if it is not needed)
20-
- Updated to babel 7
21-
- Added tests
22-
- Updated to emojis v12 (see the breaking change note below)
23-
24-
Breaking change in v6: removed `Emoji` and `Picker` [wrappers](#convenience-wrappers), renamed `NimbleEmoji` to `Emoji` and `NimblePicker` to `Picker`.
25-
See the `Convenience Wrappers` section below for details.
26-
27-
Breaking change in v7: switched to Unicode v12 emoji set which results in several breaking changes:
28-
- Removed 'emojione' set (removed from [emoji-datasource](https://github.com/iamcal/emoji-data) by [JoyPixels request](https://github.com/iamcal/emoji-data/blob/master/CHANGES.md#2018-07-05--v410))
29-
- Removed 'messenger' set - it was [merged](https://github.com/iamcal/emoji-data/blob/master/CHANGES.md#2020-01-10--v500) into 'facebook' set
30-
- Changed emoji categories: removed 'Smileys & People', added 'Smileys & Emotions' and 'People & Body' instead
31-
32-
> The original project has been forked from [emoji-mart](https://www.npmjs.com/package/emoji-mart) which was written for React
12+
> The original project has been forked from [emoji-mart](https://www.npmjs.com/package/emoji-mart) which was written for React.
3313
3414
<div align="center">
3515
<br><b>Emoji Mart (Vue)</b> is a Slack-like customizable<br>emoji picker component for VueJS
3616
<br><a href="https://serebrov.github.io/emoji-mart-vue">Demo</a> • <a href="https://github.com/serebrov/emoji-mart-vue/releases">Changelog</a>
3717
<br><img src="https://cloud.githubusercontent.com/assets/436043/17186519/9e71e8fe-5403-11e6-9314-21365c56a601.png">
3818
</div>
3919

20+
## Demo app
21+
22+
Live demo app: https://serebrov.github.io/emoji-mart-vue/
23+
Demo application code is [under the ./docs folder](./docs).
24+
4025
## Installation
4126

4227
Install from npm: `npm install --save emoji-mart-vue-fast`.
@@ -45,6 +30,14 @@ It is also possible to install directly from github (could be useful for forks):
4530

4631
Here is the list of [releases](https://github.com/serebrov/emoji-mart-vue/releases).
4732

33+
## Vue 3 Support
34+
35+
Component works with Vue 3, [here is a simple demo app](https://github.com/serebrov/emoji-mart-vue3-demo).
36+
37+
Live demo: https://serebrov.github.io/emoji-mart-vue3-demo/.
38+
39+
See also: [#88](https://github.com/serebrov/emoji-mart-vue/issues/88).
40+
4841
## Quick Example
4942

5043
```
@@ -100,6 +93,9 @@ export default {
10093
</style>
10194
```
10295

96+
## Not opinionated
97+
98+
**Emoji Mart** doesn’t automatically insert anything into a text input, nor does it show or hide itself. It simply returns an `emoji` object. It’s up to the developer to mount/unmount (it’s fast!) and position the picker. You can use the returned object as props for the `EmojiMart.Emoji` component. You could also use `emoji.colons` to insert text into a textarea or `emoji.native` to use the emoji.
10399

104100
## Components
105101

@@ -667,9 +663,32 @@ export default {
667663
</script>
668664
```
669665

670-
## Not opinionated
666+
## Changelog
667+
668+
Major changes comparing to the original emoji-mart-vue:
669+
670+
- Reworked emoji index class: use same index (so same data) for all components.
671+
- Render emojis in categories without `Emoji` component, there are a lot of emojis to render and there is a noticeable slow down when we render a component per emoji.
672+
- Frozen objects with emoji data to disable Vue change tracking
673+
- Do not create `EmojiIndex` globally, before it was loaded (along with the emoji data) even when it was not actually used
674+
- Extract CSS into external file, use less inline styles to reduce the amount of generated HTML
675+
- Fixes in CSS for native unicode emojis ported from the [original react project](https://github.com/missive/emoji-mart)
676+
- Excluded ./data/all.json from the js bundle (it was always loaded within the bundle even if it is not needed)
677+
- Updated to babel 7
678+
- Added tests
679+
- Updated to emojis v12 (see the breaking change note below)
680+
681+
Breaking change in v6: removed `Emoji` and `Picker` [wrappers](#convenience-wrappers), renamed `NimbleEmoji` to `Emoji` and `NimblePicker` to `Picker`.
682+
See the `Convenience Wrappers` section below for details.
683+
684+
Breaking change in v7: switched to Unicode v12 emoji set which results in several breaking changes:
685+
- Removed 'emojione' set (removed from [emoji-datasource](https://github.com/iamcal/emoji-data) by [JoyPixels request](https://github.com/iamcal/emoji-data/blob/master/CHANGES.md#2018-07-05--v410))
686+
- Removed 'messenger' set - it was [merged](https://github.com/iamcal/emoji-data/blob/master/CHANGES.md#2020-01-10--v500) into 'facebook' set
687+
- Changed emoji categories: removed 'Smileys & People', added 'Smileys & Emotions' and 'People & Body' instead
688+
689+
Breaking change in v8:
690+
- The `StaticPicker` component is now default (exported as `Picker`), previous default component renamed to `VirtualScrollPicker`
671691

672-
**Emoji Mart** doesn’t automatically insert anything into a text input, nor does it show or hide itself. It simply returns an `emoji` object. It’s up to the developer to mount/unmount (it’s fast!) and position the picker. You can use the returned object as props for the `EmojiMart.Emoji` component. You could also use `emoji.colons` to insert text into a textarea or `emoji.native` to use the emoji.
673692

674693
## Development
675694

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "emoji-mart-vue-fast",
3-
"version": "8.0.1",
3+
"version": "8.0.2",
44
"description": "Customizable Slack-like emoji picker for VueJS, fast version",
55
"main": "dist/emoji-mart.js",
66
"repository": {

spec/picker-spec.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ describe('Picker', () => {
4242
})
4343

4444
it('renders 10 categories', () => {
45-
// Due to the virtual scroller, not all the categories
46-
// are rendered at once
4745
let categories = picker.findAll(Category)
48-
// StaticPicker change (8 -> 10)
4946
expect(categories.length).toBe(11)
5047
// Hidden category with search results
5148
expect(categories.at(0).vm.name).toBe('Search')
@@ -57,7 +54,6 @@ describe('Picker', () => {
5754
expect(categories.at(6).vm.name).toBe('Activities')
5855
expect(categories.at(7).vm.name).toBe('Travel & Places')
5956
expect(categories.at(8).vm.name).toBe('Objects')
60-
// StaticPicker change (Symbols and Flags)
6157
expect(categories.at(9).vm.name).toBe('Symbols')
6258
expect(categories.at(10).vm.name).toBe('Flags')
6359
})
@@ -207,21 +203,31 @@ describe('anchors', () => {
207203
])
208204
})
209205

210-
it('can be clicked to scroll to the category', () => {
206+
it('can be clicked to scroll to the category', async () => {
211207
let anchors = picker.find(Anchors)
212208

213209
let anchorsCategories = anchors.findAll('span.emoji-mart-anchor')
214210
let symbols = anchorsCategories.at(8)
215211
expect(symbols.element.attributes['data-title'].value).toBe('Symbols')
216212

213+
// The `recent` category is selected initially.
214+
expect(picker.vm.activeCategory.id).toBe('recent')
215+
expect(anchors.vm.activeCategory.id).toBe('recent')
216+
217217
symbols.trigger('click')
218218
let events = anchors.emitted().click
219219
expect(events.length).toBe(1)
220+
220221
let category = events[0][0]
221222
expect(category.id).toBe('symbols')
222223
expect(category.name).toBe('Symbols')
223224

224-
// StaticPicker change - the check below fails (although works in demo app)
225+
await picker.vm.$nextTick()
226+
227+
// Picker change - the check below fails (although works in demo app)
228+
// scrollTop if 0 for all categories and activeCategory is changed in the
229+
// onScroll handler, need to find a way to thes this.
230+
// expect(picker.vm.activeCategory.id).toBe('symbols')
225231
// expect(anchors.vm.activeCategory.id).toBe('symbols')
226232
})
227233
})

src/components/Picker.vue

+22-13
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ export default {
197197
},
198198
onScrollPaint() {
199199
this.waitingForPaint = false
200-
let scrollTop = this.$refs.scroll.scrollTop,
201-
activeCategory = this.filteredCategories[0]
200+
let scrollTop = this.$refs.scroll.scrollTop
201+
let activeCategory = this.filteredCategories[0]
202202
for (let i = 0, l = this.filteredCategories.length; i < l; i++) {
203-
let category = this.filteredCategories[i],
204-
component = this.$refs['categories_' + i]
203+
let category = this.filteredCategories[i]
204+
let component = this.getCategoryComponent(i)
205205
// The `-50` offset switches active category (selected in the
206206
// anchors bar) a bit eariler, before it actually reaches the top.
207207
if (component && component.$el.offsetTop - 50 > scrollTop) {
@@ -216,17 +216,17 @@ export default {
216216
// No categories are shown when search is active.
217217
return
218218
}
219-
let i = this.filteredCategories.indexOf(category),
220-
component = this.$refs['categories_' + i],
221-
scrollToComponent = () => {
222-
if (component) {
223-
let top = component.$el.offsetTop
224-
if (category.first) {
225-
top = 0
226-
}
227-
this.$refs.scroll.scrollTop = top
219+
let i = this.filteredCategories.indexOf(category)
220+
let component = this.getCategoryComponent(i)
221+
let scrollToComponent = () => {
222+
if (component) {
223+
let top = component.$el.offsetTop
224+
if (category.first) {
225+
top = 0
228226
}
227+
this.$refs.scroll.scrollTop = top
229228
}
229+
}
230230
if (this.infiniteScroll) {
231231
scrollToComponent()
232232
} else {
@@ -253,6 +253,15 @@ export default {
253253
254254
this.$emit('skin-change', skin)
255255
},
256+
getCategoryComponent(index) {
257+
let component = this.$refs['categories_' + index]
258+
if ('0' in component) {
259+
// Vue 2 has $refs under v-for as an array.
260+
return component['0']
261+
}
262+
// Vue 3 does not support $refs as array.
263+
return component
264+
},
256265
},
257266
components: {
258267
Anchors,

0 commit comments

Comments
 (0)