-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support providing a fallback to unsupported emojis [Fix #157]
- Loading branch information
1 parent
d17c8a5
commit 3fa0331
Showing
3 changed files
with
40 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,12 +149,29 @@ import { Emoji } from 'emoji-mart' | |
| **onClick** | | | Params: `(emoji, event) => {}` | | ||
| **onLeave** | | | Params: `(emoji, event) => {}` | | ||
| **onOver** | | | Params: `(emoji, event) => {}` | | ||
| [**fallback**](#unsupported-emojis-fallback) | | | Params: `(emoji) => {}` | | ||
| **set** | | `apple` | The emoji set: `'apple', 'google', 'twitter', 'emojione'` | | ||
| **sheetSize** | | `64` | The emoji [sheet size](#sheet-sizes): `16, 20, 32, 64` | | ||
| **backgroundImageFn** | | ```((set, sheetSize) => `https://unpkg.com/[email protected]/sheet_${set}_${sheetSize}.png`)``` | A Fn that returns that image sheet to use for emojis. Useful for avoiding a request if you have the sheet locally. | | ||
| **skin** | | `1` | Skin color: `1, 2, 3, 4, 5, 6` | | ||
| **tooltip** | | `false` | Show emoji short name when hovering (title) | | ||
|
||
#### Unsupported emojis fallback | ||
Certain sets don’t support all emojis (i.e. Messenger & Facebook don’t support `:shrug:`). By default the Emoji component will not render anything so that the emojis’ don’t take space in the picker when not available. When using the standalone Emoji component, you can however render anything you want by providing the `fallback` props. | ||
|
||
To have the component render `:shrug:` you would need to: | ||
|
||
```js | ||
<Emoji | ||
set={'messenger'} | ||
emoji={'shrug'} | ||
size={24} | ||
fallback={(emoji) => { | ||
return `:${emoji.short_names[0]}:` | ||
}} | ||
/> | ||
``` | ||
|
||
## Custom emojis | ||
You can provide custom emojis which will show up in their own category. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters