emoji-reaction-component

Emoji reaction component for React

Usage no npm install needed!

<script type="module">
  import emojiReactionComponent from 'https://cdn.skypack.dev/emoji-reaction-component';
</script>

README

emoji-reaction

Emoji reaction component for React

Install

npm install --save emoji-reaction
yarn add emoji-reaction

Basic Usage

import React, { Component } from 'react'

import EmojiReaction, {
  TitledReaction,
  AngryReaction,
  CryReaction
} from 'emoji-reaction'

class App extends Component {
  constructor () {
    this.state = { feedback: 'loading' }
  }

  takeWithAPinchOfSalt (reaction) {
    console.log(`Oof! ${reaction}`)
  }

  render () {
    return (
      <EmojiReaction
        onReact={this.takeWithAPinchOfSalt}
        reactions={[
          <TitledReaction title={'Grr'} reaction={AngryReaction} />,
          <TitledReaction title={'Grr'} reaction={HappyReaction} />
        ]}
        {/* optional progress indicator
          valid states - pending/loading/success/err*/}
        progress={this.state.feedback}
        progressIndicator={ProgressIndicator}
      />
    )
  }
}

Demo

Standard

With loading states

TODO

  • Implement and document component themeing
  • resetting the state of the component after submission
  • textual feedback option
  • Prettierify + lint config updates
  • Update the example + fix example build

Acknowledgments

License

MIT © TobyColeman