# react-discord-components

> Discord's UI elements created in React.

Latest version **1.0.0** (published 2022-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-discord-components
pnpm add react-discord-components
yarn add react-discord-components
bun add react-discord-components
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-04-24 |
| First published | 2022-04-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=12 |
| Dependencies | 3 |
| Unpacked size | 3.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | fowlerro |
| Maintainers | fowlerro |
| Keywords | react, discord, components, emoji, picker |

## Links

- npm: https://www.npmjs.com/package/react-discord-components
- Repository: https://github.com/fowlerro/react-discord-components
- Homepage: https://github.com/fowlerro/react-discord-components#readme
- Issues: https://github.com/fowlerro/react-discord-components/issues
- npm.io page: https://npm.io/package/react-discord-components

## Dependencies (3)

- [react-popper](https://npm.io/package/react-popper.md) ^2.2.5
- [@popperjs/core](https://npm.io/package/@popperjs/core.md) ^2.11.5
- [styled-components](https://npm.io/package/styled-components.md) ^5.3.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-04-24
- 0.0.4 — 2022-04-24
- 0.0.3 — 2022-04-24

## README

# React Discord Components

Discord's UI elements created in React.

## Things to note!

> There is only Emoji Picker component available for now, but I am planning to add more in the future.
>
> I mainly created this repo for my other project, which needs Discord's Emoji Picker and I wanted to learn something new :).
>
> This is my first ever library and I made this in a little rush, so be aware that things can break or work not properly!

## Demo

![image](https://user-images.githubusercontent.com/54778147/164888923-1d06a0ab-415b-4d88-a7bd-45e9fc31988a.png)

## Installation

```
npm i react-discord-components
yarn add react-discord-components
```

## Emoji Picker

It should display emojis correctly, but they will not look like Discord's emojis primarily.

In order to get Discord's emojis style, you need to import font [Twemoji Mozilla](https://github.com/mozilla/twemoji-colr), just grab the .ttf file and import it to your website with `font-family: Twemoji;`!

Custom Emojis need an id (valid ID from Discord) and name to be displayed.

### Example

```jsx
import React from 'react';
import { Emoji, EmojiPicker, DefaultEmoji, CustomEmoji } from 'react-discord-components';

const App = () => {
  const [open, setOpen] = React.useState(false);
  const [emoji, setEmoji] = React.useState<DefaultEmoji | CustomEmoji>();

  const handleEmojiClick = (emoji: DefaultEmoji | CustomEmoji) => {
    setEmoji(emoji);
    setOpen(false);
  }

  return (
    <div>
      <Emoji ref={setAnchorEl} onClick={() => setOpen(!open)} emoji={emoji} />
      <EmojiPicker open={open} anchorEl={anchorEl} onEmojiClick={handleEmojiClick} />
    </div>
  );
}
```

### Props

|        Prop        |                                                                                                             Type                                                                                                             | Description                                     |
| :----------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ----------------------------------------------- |
|       `open`       |                                                                                                          `boolean`                                                                                                           | Indicates if Picker is open                     |
|     `anchorEl`     |                                                                                                          `Element`                                                                                                           | It needs element for proper positioning         |
|    `placement`     | `"auto" \| "auto-start" \| "auto-end"` <br> `"top" \| "top-start" \| "top-end"` <br> `"bottom" \| "bottom-start" \| "bottom-end"` <br> `"left" \| "left-start" \| "left-end"` <br> `"right" \| "right-start" \| "right-end"` | Emoji Picker's placement relatively to anchorEl |
| `placementOffsets` |                                                                                                      `[number, number]`                                                                                                      | Distance between Emoji Picker and anchorEl      |
|      `theme`       |                                                                                                     `"dark" \| "light"`                                                                                                      | Theme Mode                                      |
|  `categoryNames`   |                                                                                        `{ people: "People", nature: "Nature", ... }`                                                                                         | Custom category names                           |
|   `customEmojis`   |                                                                             `[ { name: "Server name", iconURL: "url", emojis: CustomEmoji[] } ]`                                                                             | Custom Emojis                                   |

### Styling

I am using styled-components for styling and this creates some issues when you try style with plain CSS, so I recommend to use styled-components.

You can export styles classes from the package and use them to style different parts of component.

```jsx
import { EmojiPicker, EmojiPickerClasses } from 'react-discord-components';
import styled from 'styled-components';

const StyledEmojiPicker = styled(EmojiPicker)({
  `.${EmojiPickerCLasses.root}`: {
    // some custom styles
  },

  `.${EmojiPickerClasses.inputSearch}`: {
    // ...
  }
});
```

---
_Source: https://npm.io/package/react-discord-components · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
