npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2021 – Pkg Stats / Ryan Hefner

react-headzoo-emoji

v0.2.2

Published

React component wrapper for the twemoji library which converts unicode codepoints into emoji images.

Downloads

12

Readme

React Emoji Component

React component wrapper for the twemoji library which converts unicode emoji codepoints into emoji images.

A demo is available at http://headzoo.io/react-headzoo-emoji.

Build Status MIT License

Installation

npm install --save react-headzoo-emoji

Usage

Wrap content where emoji should be converted into images. By default the emoji are converted into images which are hosted from maxcdn.com.

var React = require('react');
var Emoji = require('react-headzoo-emoji');

var Component = React.createClass({
    render: function() {
        return (
            <div>
                <Emoji>
                    Hello, World! 😀
                </Emoji>
            </div>
        )
    }
});

Will produce the following HTML.

<div>
    <span>
        Hello, World! <img src="https://twemoji.maxcdn.com/72x72/1f600.png" class="emoji" alt="😀" />
    </span>
</div>

Properties

size Default = 72, Possible values: 16, 36, and 72
The emoji images are available in three sizes: 16x16, 36x36, and 72x72. The value of this prop determines which size to use.

<Emoji size={16}>
    Hello, World! 😀
</Emoji>

base Default = 'https://twemoji.maxcdn.com'
Changes the base URL for the emoji images. Can be an absolute URL or a path.

<Emoji base="http://yoursite.com/images/emoji">
    Hello, World! 😀
</Emoji>

ext Default = '.png', Possible values: '.png', '.gif', '.jpg', '.jpeg', '.bmp', '.webp', '.svg', '.svgz'
Specifies the file extension for self hosted emoji images.

<Emoji ext=".gif">
    Hello, World! 😀
</Emoji>

tag Default = 'SPAN'
By default the component wraps it's children in a <span> tag, but any tag may be used.

<Emoji tag="div">
    Hello, World! 😀
</Emoji>

imgClassName Default = 'emoji'
Specifies the name of a CSS class which will be added to each created <img> tag.

<Emoji imgClassName="site-emoji">
    Hello, World! 😀
</Emoji>

Outputs.

<span>
    Hello, World! <img src="https://twemoji.maxcdn.com/72x72/1f600.png" class="site-emoji" alt="😀" />
</span>

Note: Use the className property to specify the CSS class added to the <span> container.

imgStyle Default = {}
Specifies CSS styles which will be applied to each created <img> tag.

<Emoji imgStyle={{paddingTop: '1rem', width: '16px', height: '16px'}}>
    Hello, World! 😀
</Emoji>

Outputs.

<span>
    Hello, World! <img src="https://twemoji.maxcdn.com/72x72/1f600.png" style="padding-top:1rem;width:16px;height:16px;" class="emoji" alt="😀" />
</span>

imgTitle Default = ''
Specifies the title that will be added to each created <img> tag.

<Emoji imgTitle="Emoji">
    Hello, World! 😀
</Emoji>

Outputs.

<span>
    Hello, World! <img src="https://twemoji.maxcdn.com/72x72/1f600.png" title="Emoji" class="emoji" alt="😀" />
</span>

onParse Default = function(){}
While the component parses it's children, it calls this function for each unicode codepoint it finds. The callback receives an object with the following properties: icon, base, size, and ext. Altering the values in the callback changes the parsed output. The icon value contains the hex value of the codepoint, which is also used as the image filename, sans extension.

onComplete Default = function(){}
Called when parsing is finished. The callback receives an array of DOM nodes for each <img> that was created. Provides the chance to alter the images further, add event listeners, etc. Always called when parsing finishes, even when no emoji were found.

onError Default = function(){}
Called each time an emoji image fails to load. The callback receives an object describing the error.

Any other properties are added to the <span> container.

<Emoji className="emoji-wrapper" imgClassName="site-emoji" style={{opacity: 0.8}} imgStyle={{width: '16px', height: '16px'}}>
    Hello, World! 😀
</Emoji>

Outputs.

<span class="emoji-wrapper" style="opacity: 0.8;">
    Hello, World! <img src="https://twemoji.maxcdn.com/72x72/1f600.png" style="width:16px;height:16px;" class="site-emoji" alt="😀" />
</span>

Global Properties

The component includes the setGlobalProps() method, which is used to change the default props used on each component. For instance rather than setting the base prop on every component instance (a value which may change in the future) you can instead set it once in your bootstrap process use setGlobalProps().

var Emoji = require('react-headzoo-emoji');

Emoji.setGlobalProps({
    base: 'http://yoursite.com/images/emoji'
});

Test

npm run test

Build

npm run build