ZacharyCrespin / fluentui-emoji-js

A JavaScript wrapper for Microsoft's Fluent Emojis

Home Page:https://www.npmjs.com/package/fluentui-emoji-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fluentui-emoji-js

A JavaScript wrapper for Microsoft's Fluent Emojis.

NPM | Github | Live Demo

Install

npm install fluentui-emoji-js

Usage

Common JS

const emoji = require('fluentui-emoji-js')

emoji.fromGlyph('πŸ‘‹','3D').then((emojiFile) => {
  console.log(emojiFile)
})

ES Module

import * as emoji from 'fluentui-emoji-js'

const emojiFile = await emoji.fromGlyph('πŸ‘‹','3D')
console.log(emojiFile)

Displaying the emoji

Both fromGlyph() and fromCode() return the location of the emoji image relative to the base emoji folder. You can download the assets folder from the fluentui-emoji repo or use a service like jsdelivr to get the emoji image.

Getting emoji image via jsdelivr
const emojiImage = document.querySelector('#emojiImage');
const emoji = 'πŸ•';

emoji.fromGlyph(emoji,'3D').then((emojiFile) => {
  emojiImage.src = `https://cdn.jsdelivr.net/gh/microsoft/fluentui-emoji@latest/assets${emojiFile}`
})

More Info

fluentui-emoji-js has 2 main functions fromGlyph() and fromCode(). Both require an emoji and style to be specified and return the location of the emoji image relative to the base emoji folder.

fromGlyph()

  • glyph: String containing a single emoji
  • style: String '3D', 'Color', 'Flat', or 'High Contrast'

fromCode()

  • code: String containing the striped unicode of an emoji
    • code should be just the hex code. ex.'1f44b' not 'U+1F44B'
  • style: String '3D', 'Color', 'Flat', or 'High Contrast'

About

A JavaScript wrapper for Microsoft's Fluent Emojis

https://www.npmjs.com/package/fluentui-emoji-js

License:MIT License


Languages

Language:JavaScript 74.1%Language:Python 25.9%