0.2.27 β€’ Published 1 year ago

react-emoji-popup-lister v0.2.27

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Emoji Popup Lister

Slack-lick emoji list and select via keyboard

NPM

Recording

πŸ“ About

Type and insert emojis within your inputs, via their shortcode values. Written in Typescript.
:cool: :cool:

⌨️ Install

❗ ESM only package

npm i -s react-emoji-popup-lister

πŸš€ Usage

1. Basic

import EmojiPopup from "react-emoji-popup-lister"

export default function ExampleA () {
  return <EmojiPopup />
}

2. Custom styling with props

import EmojiPopup from "react-emoji-popup-lister"

export default function ExampleB () {
  return (
    <EmojiPopup
      listMax={40}
      maxHeight="200px"
      maxWidth="300px"
      placeholder="Add a profile description"
      theme="light"
      ariaLabel="Profile description input"
    />
  );
}

3. Provide an input component, state, and events from your parent component

Also wrap in a container div, to align the input and popup

import { useState, useEffect } from "react";
import EmojiPopup from "react-emoji-popup-lister"

// Your input with props passed, including input value state
function Input (props: any) {
	
  useEffect(() => { }, [props.value]);
  
  return (
    <input
      // Required. Anything after is optional, and will override values
      {...props}
      // Override or extend default values
      className="your-class-name"
      placeholder="Your placeholder text"
      style={{ ...props.style, width: "100%" }}
    />
  );
}

// Parend component with state, passed input, events, etc.
export default function ExampleC () {
	
  const [text, setText] = useState("");
  useEffect(() => { }, [inputText]);
  
  const handleChange = function (e: React.ChangeEvent) { };

  return (
    {/* Container to align input and popup together */}
    <div style={{ maxWidth: "400px", margin: "1rem auto 0"}}>
      <EmojiPopup
        input={Input}
        value={text}
        setValue={setText}
        onChange={handleChange}
      >
        <div>Child content...</div>
      </EmojiPopup>
    </div>
  );
}

πŸ—ƒοΈ Prop Options

All are optional

PropTypeDefaultDescription
inputinput/textarea component<input>Pass your own input element or component
valueuseState string value""Store state in your parent component
setValueuseState functionsetStateSet value from inside Emoji component
listMaxnumber6Max number of emoji matches to display
themestringautoPopup display theme style. light dark auto
strictbooleantrueStrict mode will ignore a:b, πŸ‘‹:ab
maxWidthnumber/string400pxScroll container width cap
maxHeightnumber/string250pxScroll container height cap
footerbooleantrueDisplay or hide footer info bar
placeholderstring""Input placeholder value
ariaLabelstring""Input aria-label value

πŸͺ… Prop Events

Place on <EmojiPopup> component, Not your custom <input> - as this will override necessary events

PropDescription
onClickInput element Click event (* Not emoji list)
onChangeInput value Change event
onKeyDownInput KeyDown event
onKeyUpInput KeyUp event
onFocusInput Focus event
onBlurInput Blur event

πŸ—ΊοΈ Shortcuts

These will preventDefault in the input while the popup is active

KeyFunction
ArrowUpUp in emoji list
ArrowDownDown in emoji list
HomeStart of emoji list
EndEnd of emoji list
Enter or TabChoose highlighted emoji

πŸ—οΈ Todo

Feature

  • Add CSS classes for user styling
  • Option to turn off Home/End shortcut
  • Option to replace full emoji string automatically (2 colons)
  • Add better positioning support

Bugs

  • Cursor over list, while using keyboard navigation still triggers hover change
  • Deleting "combo" emojis on Firefox doesn't remove the entire emoji
  • Escape to hide gets reset on successive typing
  • Cursor changing caret position not triggering changes

πŸ–ŠοΈ License

MIT Β© nicfontaine

0.2.27

1 year ago

0.2.26

1 year ago

0.2.25

1 year ago

0.2.24

1 year ago

0.2.22

1 year ago

0.2.21

1 year ago

0.2.20

1 year ago

0.2.19

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.16

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.16

1 year ago

0.1.15

1 year ago

0.1.14

1 year ago

0.1.13

1 year ago

0.1.12

1 year ago

0.1.11

1 year ago

0.1.9

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago