Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added include and exclude props to filter emoji categories #53

Merged
merged 1 commit into from
Apr 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added include and exclude props to filter emoji categories
  • Loading branch information
madshargreave committed Apr 1, 2017
commit 5602d3a3e427ebb53d557dabed0ec200154ed168
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { Picker } from 'emoji-mart'
| ---- | :------: | ------- | ----------- |
| **color** | | `#ae65c5` | The top bar anchors select and hover color |
| **emoji** | | `department_store` | The emoji shown when no emojis are hovered |
| **include** | | `['People', 'Flags']` | Only load included categories |
| **exclude** | | `['Animals', 'Objects']` | Don't load excluded catagories |
| **emojiSize** | | `24` | The emoji width and height |
| **onClick** | | | Params: `(emoji, event) => {}` |
| **perLine** | | `9` | Number of emojis per line. While there’s no minimum or maximum, this will affect the picker’s width. This will set *Frequently Used* length as well (`perLine * 4`) |
Expand Down
6 changes: 6 additions & 0 deletions src/components/picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export default class Picker extends React.Component {
let filteredCategories = [];

for (let hash of data.categories) {
let isIncluded = props.include == undefined ? true : props.include.indexOf(hash.name) > -1
let isExcluded = props.exclude == undefined ? false : props.exclude.indexOf(hash.name) > -1
if (!isIncluded || isExcluded) { continue; }

let new_emojis = [];
for (let emoji of hash.emojis) {
let unified = data.emojis[emoji].unified;
Expand Down Expand Up @@ -348,6 +352,8 @@ Picker.propTypes = {
backgroundImageFn: Emoji.propTypes.backgroundImageFn,
sheetSize: Emoji.propTypes.sheetSize,
emojisToShowFilter: React.PropTypes.func,
include: React.PropTypes.arrayOf(React.PropTypes.string),
exclude: React.PropTypes.arrayOf(React.PropTypes.string)
}

Picker.defaultProps = {
Expand Down