Support :colons: syntax

i.e. 👍, 👍:skin-tone-3:
nolan/hinaloe-test
Etienne Lemay 2016-11-01 11:10:16 -04:00
parent 97b20acc7f
commit c4604741d9
2 changed files with 13 additions and 1 deletions

View File

@ -100,7 +100,8 @@ Sheets are served from [unpkg](https://unpkg.com), a global CDN that serves file
import { Emoji } from 'emoji-mart'
<Emoji emoji={{ id: 'santa', skin: 3 }} />
<Emoji set='emojione' emoji='santa' />
<Emoji emoji=':santa::skin-tone-3:' />
<Emoji emoji='santa' set='emojione' />
```
| Prop | Required | Default | Description |

View File

@ -1,5 +1,6 @@
import data from '../../data'
const COLONS_REGEX = /^(?:\:([^\:]+)\:)(?:\:skin-tone-(\d)\:)?$/
const SKINS = [
'1F3FA', '1F3FB', '1F3FC',
'1F3FD', '1F3FE', '1F3FF',
@ -39,6 +40,16 @@ function getData(emoji, skin, set) {
var emojiData = {}
if (typeof emoji == 'string') {
let matches = emoji.match(COLONS_REGEX)
if (matches) {
emoji = matches[1]
if (matches[2]) {
skin = parseInt(matches[2])
}
}
if (data.short_names.hasOwnProperty(emoji)) {
emoji = data.short_names[emoji]
}