Skip to content

Commit

Permalink
Add defaultSkin prop to Picker and allow forcing skin tone with `sk…
Browse files Browse the repository at this point in the history
…in` prop [Ref missive#165]
  • Loading branch information
EtienneLem committed Mar 2, 2018
1 parent b075376 commit af2fdc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ import { Picker } from 'emoji-mart'
| **emojisToShowFilter** | | ```((emoji) => true)``` | A Fn to choose whether an emoji should be displayed or not |
| **showPreview** | | `true` | Display preview section |
| **emojiTooltip** | | `false` | Show emojis short name when hovering (title) |
| **skin** | | `1` | Default skin color: `1, 2, 3, 4, 5, 6` |
| **skin** | | | Forces skin color: `1, 2, 3, 4, 5, 6` |
| **defaultSkin** | | `1` | Default skin color: `1, 2, 3, 4, 5, 6` |
| **style** | | | Inline styles applied to the root element. Useful for positioning |
| **title** | | `Emoji Mart™` | The title shown when no emojis are hovered |

Expand Down
9 changes: 6 additions & 3 deletions src/components/picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class Picker extends React.PureComponent {

this.i18n = deepMerge(I18N, props.i18n)
this.state = {
skin: store.get('skin') || props.skin,
skin: props.skin || store.get('skin') || props.defaultSkin,
firstRender: true,
}

Expand Down Expand Up @@ -152,8 +152,10 @@ export default class Picker extends React.PureComponent {
}

componentWillReceiveProps(props) {
if (props.skin && !store.get('skin')) {
if (props.skin) {
this.setState({ skin: props.skin })
} else if (props.defaultSkin && !store.get('skin')) {
this.setState({ skin: props.defaultSkin })
}
}

Expand Down Expand Up @@ -566,7 +568,8 @@ Picker.defaultProps = {
emoji: 'department_store',
color: '#ae65c5',
set: Emoji.defaultProps.set,
skin: Emoji.defaultProps.skin,
skin: null,
defaultSkin: Emoji.defaultProps.skin,
native: Emoji.defaultProps.native,
sheetSize: Emoji.defaultProps.sheetSize,
backgroundImageFn: Emoji.defaultProps.backgroundImageFn,
Expand Down
2 changes: 1 addition & 1 deletion stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ storiesOf('Picker', module)
perLine={number('Per line', 9)}
title={text('Idle text', 'Your Title Here')}
emoji={text('Idle emoji', 'department_store')}
skin={number('Skin tone', 1)}
defaultSkin={number('Default skin tone', 1)}
color={color('Highlight color', '#ae65c5')}
showPreview={boolean('Show preview', true)}
custom={CUSTOM_EMOJIS}
Expand Down

0 comments on commit af2fdc7

Please sign in to comment.