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 🙏

© 2024 – Pkg Stats / Ryan Hefner

solid-emoji-picker

v0.3.0

Published

Emoji Picker for Solid

Downloads

348

Readme

solid-emoji-picker

Unstyled Emoji Picker component for SolidJS

NPM JavaScript Style Guide Open in CodeSandbox

Install

npm i solid-emoji-picker
yarn add solid-emoji-picker
pnpm add solid-emoji-picker

Usage

Simplest example

import { EmojiPicker } from 'solid-emoji-picker';

function App() {
  function pickEmoji(emoji) {
    console.log('You clicked', emoji.name);
  }

  return (
    <EmojiPicker onEmojiClick={pickEmoji} />
  );
}

Emoji Data

The emoji data is based on unicode-emoji-json.

Events

All event properties receives the emoji item data and the accompanying event value.

  • onEmojiClick - "click" event
  • onEmojiFocus - "focus" event
  • onEmojiHover - "mouseover" event

Styling

The emoji picker has the following structure:

<div class="emoji-picker">
  <div class="emoji-section">
    <span class="emoji-section-title"></span>
    <div class="emoji-items">
      <button class="emoji-button">
        <!-- user-defined -->
      </button>
    </div>
  </div>
</div>

You can refer to these classes for styling the parts of the emoji picker.

Skin Tones

You can define your selected skin tone with the skinTone property for EmojiPicker. The skinTone property has the following possible values: "light", "medium-light", "medium", "medium-dark" and "dark". By default, it is undefined.

<EmojiPicker skinTone="medium" />

Take note that some emojis might not correctly apply the skin tone, this depends on the emoji support.

Filtering

filter allows conditionally rendering each emoji item. filter receives the emoji item data which shall then return a boolean. This is useful for emulating emoji search.

<EmojiPicker filter={(emoji) => emoji.name.includes('hand')} />

Custom rendering

renderEmoji allows emoji to be rendered in a user-defined way. renderEmoji receives the emoji item data, the components (used for skin tone reference) and the currently selected skin tone, in which renderEmoji must return a JSX.Element.

Here's an example with twemoji:

import twemoji from 'twemoji';
import {
  convertSkinToneToComponent,
  getEmojiWithSkinTone,
} from 'solid-emoji-picker';

function getTwemoji(
  emojis,
  emoji,
  components,
  tone,
) {
  const skinTone = convertSkinToneToComponent(components, tone);
  const tonedEmoji = getEmojiWithSkinTone(emojis, emoji, skinTone);
  return twemoji.parse(tonedEmoji);
}

function renderTwemoji(
  emojis,
  emoji,
  components,
  tone,
) {
  return <span innerHTML={getTwemoji(emojis, emoji, components, tone)} />;
}

<EmojiPicker renderEmoji={renderTwemoji} />

If renderEmoji is unspecified, it renders the following:

<span class="emoji">{emojiCodeWithSkinTone}</span>

Custom CDN

By default, solid-emoji-picker loads the emoji data from unicode-emoji-json's UNPKG. You can use the following to modify the data handling:

  • setCDN - sets the base CDN path, defaults to "https://unpkg.com/unicode-emoji-json/"
  • setEmojiURL - specify the full path of the emoji data JSON. If not set, it defaults to selected CDN path + "data-by-emoji.json".
  • setGroupURL - specify the full path of the group data JSON. If not set, it defaults to selected CDN path + "data-by-group.json".
  • setComponentsURL - specify the full path of the component JSON. If not set, it defaults to selected CDN path + "data-emoji-components.json".
  • loadEmojiData - Fetch the emoji data.
  • loadEmojiComponents - Fetch the components data.
  • loadEmojiGroupData - Fetch the emoji group data.
  • setEmojiData - Set the emoji data.
  • setEmojiComponents - Set the components data.
  • setEmojiGroupData - Set the emoji group data.

Suspense

<EmojiPicker> uses createResource for data fetching. Wrapping it in <Suspense> is recommended.

To directly access these resource primitives, you can use useEmojiData, useEmojiGroupData and useEmojiComponents, both returns the data resource.

Sponsors

Sponsors

License

MIT © lxsmnsyc