Giter Site home page Giter Site logo

joeattardi / picmo Goto Github PK

View Code? Open in Web Editor NEW
1.2K 9.0 111.0 21.5 MB

JavaScript emoji picker. Any app, any framework.

Home Page: https://picmojs.com

License: MIT License

JavaScript 26.42% CSS 12.43% TypeScript 60.26% Shell 0.11% HTML 0.78%
javascript emoji emoji-picker vanilla-javascript twemoji

picmo's Introduction

PicMo

Add a fully featured emoji picker to your app with a few lines of code!

Formerly known as Emoji Button.

PicMo screenshot

Features at a glance

  • It's just JavaScript, no frameworks or libraries required. This means you can use it in any app under any framework.
  • Emoji data is loaded once from a CDN and cached in the browser for subsequent sessions.
  • Use the default operating system emoji images or use an alternative renderer to use, for example, images from Twemoji.
  • Emojis are searchable by name or tags
  • Full support for skin tone variations where applicable
  • Remembers recently used emojis
  • Fully keyboard accessible
  • Includes light and dark themes, with the ability to extend them to create your own
  • Add custom images and GIFs!
  • Render inline on the page or as a popup

Demos and documentation

Demos and full documentation, including the API and usage guide, is available at https://picmojs.com.

Installation

At a minimum, you need the core picker package. This gives you a picker that you can insert inline into an element on the page.

npm install picmo

Basic usage

import { createPicker } from 'picmo';

// The picker must have a root element to insert itself into
const rootElement = document.querySelector('#pickerContainer');

// Create the picker
const picker = createPicker({ rootElement });

// The picker emits an event when an emoji is selected. Do with it as you will!
picker.addEventListener('emoji:select', event => {
  console.log('Emoji selected:', event.emoji);
});

Packages

PicMo is made up of three packages:

Contributors

Thank you so much to everyone who has contributed code to PicMo!

picmo's People

Contributors

baune8d avatar boyanio avatar dependabot[bot] avatar edm00se avatar frost avatar fuwasegu avatar henrykhelsky avatar ianknauer avatar jmlee2k avatar joeattardi avatar justsnoopy30 avatar mattdsteele avatar mehedih avatar mjromka avatar mnz2000 avatar roderickhsiao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picmo's Issues

Improved keyboard navigation

Currently it is possible to cycle through all emojis with the Tab key. This can be cumbersome if there are a lot of emojis. It would be nice to support navigating the grid of emojis with the arrow keys.

Two Emoji are undefined/missing

Hey there, the two following emoji are running into rendering issues for both Firefox and chrome on OSX (they seem to be fine in Safari). I've checked the unicode listing and relaxed doesn't seem to exist? White frowning face does exist, so i'm not sure what would cause the rendering issues here.

  1. Relaxed

relaxed

  1. white_frowning_face

white_frowning_face

Emoji-button for HTML/CSS and Javascript

Hello !
I really love Emoji-Button.
I have a question, can we add it to html page ?
I see in documentation that it's for Vanilla Javascript... but does it work for html page ?
Thanks a lot !

Not showing up when being removed

There is a delay between "closing" the emoji picker and its div being removed from the DOM (for the nice fade out animation effect).

If showPicker is called while this animation takes place, the picker does not show up. I guess it's because the div is removed from the DOM a few milliseconds after.

As far as I understand, a check on whether the visible class is present on the DOM in showPicker could fix the issue.

Or maybe adapting the code I use to call the picker?

this.picker.pickerVisible
      ? this.picker.hidePicker()
      : this.picker.showPicker(this.emojiButton.nativeElement);

Spacing issues with emoji listing on Linux

Hey there, i'm not sure if you intend to support Linux (specifically Ubuntu 18.04) but we're seeing some visual problems with the layout of emoji that have multiple icons within them. The icons seem to be wider so they're overlapping.

Screenshot from 2019-10-31 10-13-18

Option to not autofocus search bar

Hi πŸ˜ƒ

on mobile I experience that keyboard opens up right after click on emoji-button. This is because its search bar gets autofocus. Especially on small screens this situation covers much of the screen. Maybe users want to click/browse through emojis instead of searching for them on first hand.

How about making it optional that searchbar gets autofocus on open.

I would be happy to contribute PR if you're interested.

Have a nice week
midzer

Small vertical margin quirck

It looks like #12 is back in my project:

image

Removing the margin-top: 0.5em fixes the issue for me:

image

What do you think is the best way to fix it?

Dependency warning on popperjs

The last yarn update I did, I got this warning:

warning @joeattardi/emoji-button > [email protected]: Popper changed home, find its new releases at @popperjs/core

Looks like the popperjs dependency should be updated :)

Adding new emojis

Hi, I forked your library, updated the emoji-datasource library to the most recent version (5.0.1) and run the processEmojiData.js.

Apart from some problems with the categories array, that I manually fixed, now I have many empty emojis and also emojis composed by multiple ones. Any suggestions on how to fix it? Is there anything else I should update to make it work?

Schermata 2020-01-23 alle 11 53 10

It would be amazing if you could update the library, adding all the new missing emojis.
Thanks!

Z-index not working

  • The z-index option needs to be included in the outer most div (class="wrapper"), not the div just inside that (class="emoji-picker"). I'm guessing the outer-most div is being created by the popper, in which case not all of the options (i.e. the z-index) are getting passed.

  • Passing additional options in the togglePicker seems to have no effect. Looking at the code, didn't seem like the parameter was being used.

Suggestions + error

I would like to thank you for this, it's really cool ! :)

My suggestions after implementation:

  • Put the "emoji-button-3.0.3.min.js" file, in the source.zip in the future for releases. It's easier to update for large websites. Also name it always the same "emoji-button.min.js".
    image

  • Some emojies go outside the grid which creates a scrollbar in X. Could be cool to be able to control column properties tho.
    image

  • I have an error in the console when I hide the searchBar (showSearch: false).
    image
    Solution : Goes away when I add "autoFocusSearch: false". Logic !
    So maybe should set "autoFocusSearch" to "false" automatically if "showSearch" is set to "false".

Best regards mate !

Filtred categories appear on search

Hello,

I was using your component from the last couple of days and it's perfect πŸ‘

One small thing I saw is that when I created a picker with some categories, let's say this :

    const picker = new EmojiButton({
      categories: ['smileys', 'animals', 'objects', 'people']
    });

I still can see other categories when searching (for example flags) :
image

This could be confusing from an user end.

Colon emojis

Hi, I would like to know if there is already a feature to use emojis with :colon: or if there is good advice as how to integrate this.
thanks

Cannot find an option to show or hide tabs

Is there an option to show or hide specific categories tabs?
I tried to find an option to do that in the documentation but I couldn't find any.

Thank you for this amazing bundle.

Need help getting it working with site's CSP

Hi, I am having a problem getting this loaded with my site's Content Security Policy below which is sent in header by Apache. I added URL to script in CSP's style-src and script-src sections.

Header set Content-Security-Policy "default-src 'none'; base-uri 'self'; frame-ancestors 'self'; frame-src 'self' https://discordapp.com; media-src 'self' https://ssl.gstatic.com; img-src 'self' https://www.google-analytics.com https://www.googletagmanager.com https://www.gstatic.com; connect-src 'self' https://www.google-analytics.com; font-src 'self' https://fonts.googleapis.com http://fonts.gstatic.com https://fonts.gstatic.com https://www.google-analytics.com https://maxcdn.bootstrapcdn.com http://maxcdn.bootstrapcdn.com; form-action 'self' https://api.sandbox.paypal.com https://www.sandbox.paypal.com https://secure.paypal.com https://www.paypal.com; style-src 'self' https://fonts.googleapis.com http://maxcdn.bootstrapcdn.com https://maxcdn.bootstrapcdn.com https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js; script-src 'self' https://kellypublishing.com https://www.google-analytics.com https://www.googletagmanager.com https://cdn.jsdelivr.net/momentjs/2.13.0/moment.min.js https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js; report-uri https://XXXXXX.com/scripts/cspReport.php;"

I tried loading it like:

<script src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js"></script>

get following error

image

I tried adding a single integrity hash calculated at https://www.srihash.org/.

<script src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js" integrity="sha384-2+4ak+EZAvYSg5sqFl6/fu1wxegjxZl52L8+Y4WQSSPlCUYia+2w33MeX9moB58o" crossorigin="anonymous"></script>

get the same error

image

with the three integrity hashes in above error message

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js" integrity="sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= sha256-j+uGzTtOAr9ui9u6vep2KJDVEj8Ob+QZwv2PG/URCVc= sha256-UTjtaAWWTyzFjRKbltk24jHijlTbP20C1GUYaWPqg7E=" crossorigin="anonymous"></script>

get different error with a different hash

image

tried adding the fourth hash referenced in above error with

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js" integrity="sha256-2zBSl0N0+jv0CCZBDFVUySEiCCsPhfowMQL7NFMdNXA= sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= sha256-j+uGzTtOAr9ui9u6vep2KJDVEj8Ob+QZwv2PG/URCVc= sha256-UTjtaAWWTyzFjRKbltk24jHijlTbP20C1GUYaWPqg7E=" crossorigin="anonymous"></script>

and get following error

image

which is the same error as when I just use

<script src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js"></script>

Then I tried like below.

<script src="https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js" /></script>

and adding 'unsafe-inline to style-src and script-src section of CSP and do not get any error.

I get all the same results above whether loaded locally or remotely.

Is it possible to get this working without having to add unsafe-inline to CSP? I recall awhile back I was not able to use Google's reCaptcha service due to I believe some inline code in the file they required, might this be the same reason this is not working with a CSP that does not allow unsafe-inline? If so, any workarounds or is such essential to this and likely other similar type emoji pickers?

Get emoji shortname / code?

I'm using the twemoji, along with a parser in a textarea that converts all the :smile: etc to twemojis, and want to use this. I've found that the twemoji outputs html, but it would be really helpful if it included the name as a data- attribute, or anything that I could extract from the html.

[feature] Customizable z-index

When using inside a mat-dialog in Angular, the picker does not show because it is hidden behind the dialog component.

I fixed this a global css style:

.emoji-picker {
  z-index: 1001; // Show over mat-dialog
}

It would be nice to be able to customize the z-index through the config object.

i18n for Recents category

Hello,
Currently is not possible translate the Recents category.
Is not part of the type Category as in the past versions.

It's weird about position not work.

I use Rails + yarn install this project, and use
javascript code

const post_emoji_button = $('#post_emoji_picker');
const post_picker = new EmojiButton({
    style: 'twemoji',
    position: 'top',
});

post_emoji_button.on('click', () => {
    post_picker.togglePicker(post_emoji_button);
});

html code

<div id="post_emoji_picker">
    <i class="fa fa-smile">
    </i>
</div>

to create a simple EmojiButton, but the position is incorrect, it seems that createPopper cannot create at right position, the .wrapper just display on the html page's bottom whatever the position value.
Is there any tool to debug this?
emoji1

Error displaying windows 7 emojis

Hello, thanks for this plugin!
I have only one doubt!
How can I use it on older systems? For example, I'm trying to view on windows 7

image

Couple of suggestions

Hey, great library, thanks!

Here are two suggestions:

  • the picker could not close after an emoji is clicked -> it makes sense that people want to click multiple emojis;
  • the messages/placeholders could be configurable in order to achieve internalization

Tab icons not displayed correctly using bootstrap

Hello. Great component.
Using this with angular 8 and bootstrap 4 I that the tab icons are not showed correctly, like this:
image

This is caused by _reboot.scss:

*, ::after, ::before {
box-sizing: border-box;
}

I fixed this issue with this css:

.emoji-picker__tab svg {
    box-sizing: content-box;
}

I shared it for maybe include that in the default css in next versions.

Question about "smiling face" emoji

Hi, do you know why when I select a colored emoji to be inserted into a form field most show the exact colored emoji in the form field while at least one named "smiling face" shows a colorless version? My script inserts the comma before it and it occurs whether that is done or not. I tried in latest Chrome and Firefox. I have <meta charset="UTF-8"> in documents head section. I included a screen capture that loops twice below.

example

Auto hide not working as expected

Hi,

I'm trying to keep the picker shown and to be closed manually
the current autoHide property seems not to work either the showPreview

moreover, it would be nice if there's an option to remove the categories bar at all

Screen Shot 2020-04-05 at 1 16 20 AM

Hardcode extra icons to reduce bundle size

Hi,

first of all, great library πŸ‘
I've implemented it already in one of my websites :)

Can we reduce reduce bundle size somehow? Right now it is almost ~200kb which is kinda heavy. I realized emoji-button uses

"@fortawesome/fontawesome-svg-core": "^1.2.22",
"@fortawesome/free-regular-svg-icons": "^5.10.2",
"@fortawesome/free-solid-svg-icons": "^5.10.2",

for all used icons (in tabs and search).

We could get rid of those extra packages by extracting respective svg html for each icon and put it directly in code. I guess it wont change too often ;)

Would be happy to contribute to this cool project!

Have a nice weekend
midzer

edit:
I found out in dist rollup bundler extracts only icons which are necessary. So removing @FortAwesome packages from bundle will have only minor effect. Maybe there are other possibilities to optimize?

Some tabs is hard to click 😐

image

When I try to click it, I have to click the place which is right away from it ( about 5px ). And the third tab is the most difficult one to click.

picker to be too large

My project itself uses rem, which causes the picker to be too large. How to solve it?

The theme option seems to be useless

I have installed: "@joeattardi/emoji-button": "^3.0.0",

But when I call it with:

    public emoji(): void {
        const chatBox = <HTMLElement>document.querySelector('.chat-box');
        const input = <HTMLTextAreaElement>document.getElementById('chatInput');
        if(!this.picker) {
            this.picker = new EmojiButton();
            this.picker.on('emoji', emoji => {
                input.value += emoji;
            });
        }
        this.picker.togglePicker(chatBox, {
            position: 'top-start',
            zIndex: 20,
            theme: 'dark'
        });
    }

It still displays the light theme.

Category shown by default

Hi, I noticed the picker scrolls by default down past the first category of Recent Emojis to the second category Smileys & Emotion. I understand one can click the Recent Emoji icon to get there but is there a way to specify the default category it goes to as I would like it to start at the top or Recent Emojis without any user action.

Setting autoFocusSearch to false does not prevent focus in search field

Hi,

thanks a lot for your project, I like it a lot!
I was stumbling upon an issue though: I was trying to prevent the automatic change of focus to the search field by setting the autoFocusSearch option to false - but unfortunately the search field gets focused anyway.

Cannot say for sure, but maybe it's due to what happens here?
https://github.com/joeattardi/emoji-button/blob/master/src/index.ts#L140

This expression anyway resolves to true, or am I missing something?
Thanks!

Compile error with latest version

This compile error started popping up in my Angular project after updating to latest version:

ERROR in src/app/shared/custom-forms/components/inputs-complex/input-emoji/input-emoji.component.ts:3:8 - error TS1259: Module '"/home/mic/dev/qontrol/product/frontend/node_modules/@joeattardi/emoji-button/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag
    
    3 import EmojiButton from '@joeattardi/emoji-button';
             ~~~~~~~~~~~
    
      node_modules/@joeattardi/emoji-button/index.d.ts:3:1
        3 export = EmojiButton;
          ~~~~~~~~~~~~~~~~~~~~~
        This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

Playing around with allowSyntheticDefaultImports in my tsconfig.json didn't fix the error.

Typescript doc mentions it's just for type-checking.

Any idea on how to fix that?

Weird almost blank right column

I have a blank column on the right, with only a handful of icons showing up in some lines:

image

image

aaaah I think I understand. They are "combined" emojis that are not properly taken into account by the emoji font I have (you can see the plane under the pilot too, or the mic below):

image

Hum. Not sure how to handle that?

Emoji always appended after the text

Really nice work, I love it!

After testing it, I noticed that the emojis are always appended after the text. If I want to place emojis in the middle of a text (where I leave the cursor) I have to copy/paste, which is tedious work. I assume this is not intended behaviour of the app.

I would be nice also to have the option to display emoji short names, i.e. : smile : for db storage. Older versions of MySQL configured with utf8 charset (and not utf8mb4) struggle with 4-byte unicode characters.

Poffen

Extends out of the box

What an amazing work, thanks!

Ran into this glitch (notice the last line bleeding below the separation line):

image

Simply using this in my code solved the issue for me:

.emoji-picker__tab-body {
  margin-top: 0px !important;
}

Any idea what could be causing this, and if it is the right way to fix the issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.