Fork of the emoji-button package to remove FontAwesome.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Joe Attardi 5db38f63f5
Add CI workflow
5 years ago
css Add skin tone variants 5 years ago
examples Remove referenceEl from constructor 5 years ago
scripts Add skin tone variants 5 years ago
src Prettify, configure eslint to use prettier 5 years ago
.babelrc initial commit 5 years ago
.eslintrc.js Prettify, configure eslint to use prettier 5 years ago
.gitignore initial commit 5 years ago
.prettierrc Prettify, configure eslint to use prettier 5 years ago
LICENSE Create LICENSE 5 years ago
README.md Add development instructions to README 5 years ago
nodejs.yml Add CI workflow 5 years ago
package-lock.json Prettify, configure eslint to use prettier 5 years ago
package.json Prettify, configure eslint to use prettier 5 years ago
rollup.config.js inject css into bundle 5 years ago
screenshot.png add screenshot 5 years ago

README.md

Emoji Button

Vanilla JavaScript emoji picker 😎

npm package

Screenshot

Emoji Button turns an ordinary button into an emoji picker. When the target button is clicked, the emoji picker will be shown and a callback will be executed when an emoji is picked.

Demo

https://joeattardi.github.io/emoji-button

Features

  • 💻 Vanilla JS, use with any framework
  • 🔎 Emoji search
  • 👍🏼 Skin tone variations
  • ⏱ Recently used emojis

Installation

npm install --save emoji-button

Basic usage

  import EmojiButton from 'emoji-button';

  const button = document.querySelector('#emoji-button');
  const picker = new EmojiButton();

  picker.on('emoji', emoji => {
    document.querySelector('input').value += emoji;
  });

  button.addEventListener('click', () => {
    picker.pickerVisible ? picker.hidePicker() : picker.showPicker(button);
  });

API

new EmojiButton(options)

Creates an Emoji Button emoji picker.

Options

  • position: The position to display the picker relative to the reference element. Valid values are:
    • auto
    • auto-start
    • auto-end
    • top
    • top-start
    • top-end
    • right
    • right-start
    • right-end
    • bottom
    • bottom-start
    • bottom-end
    • left
    • left-start
    • left-end

showPicker(referenceElement)

Shows the picker, positioning it relative to the given reference element. The reference element is usually the button or other element that was clicked to open the picker.

hidePicker()

Hides the picker.

pickerVisible (property)

Will be true if the picker is currently visible, and false if not.

on(event, callback)

Adds an event listener. Currently there is only one event:

  • emoji: Fired when an emoji is picked. The callback is called with a single argument, the emoji character that was picked.

Development

The easiest way to hack on Emoji Button is to use the examples page.

Clone the repository

git clone https://github.com/joeattardi/emoji-button.git

From the repository root

Install dependencies

npm install
npm link

Start the build/watch loop

npm run build:watch

From the examples subdirectory

Install dependencies

npm install
npm link emoji-button

Start the dev server

npm start

Open the page

http://localhost:5000