Add an option to disable use of <button>

i.e. Latest version of Chrome (~v80) can’t render Pirate Flag (🏴‍☠️) on a <button>
release
Etienne Lemay 2020-03-16 11:44:02 -04:00
parent 22ffd5b85e
commit 17cf50f7ba
No known key found for this signature in database
GPG Key ID: EE7CF89146BB28E9
7 changed files with 10 additions and 1 deletions

View File

@ -48,6 +48,7 @@ import { Picker } from 'emoji-mart'
| **showPreview** | | `true` | Display preview section | | **showPreview** | | `true` | Display preview section |
| **showSkinTones** | | `true` | Display skin tones picker. Disable both this and `showPreview` to remove the footer entirely. | | **showSkinTones** | | `true` | Display skin tones picker. Disable both this and `showPreview` to remove the footer entirely. |
| **emojiTooltip** | | `false` | Show emojis short name when hovering (title) | | **emojiTooltip** | | `false` | Show emojis short name when hovering (title) |
| **useButton** | | `true` | When clickable, render emojis with a `<button>`. Some browsers have issues rendering certain emojis on a button, so you might want to disable this. It is better for accessibility to use buttons. |
| **skin** | | | Forces 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` | | **defaultSkin** | | `1` | Default skin color: `1, 2, 3, 4, 5, 6` |
| **skinEmoji** | | | The emoji used to pick a skin tone. Uses an emoji-less skin tone picker by default | | **skinEmoji** | | | The emoji used to pick a skin tone. Uses an emoji-less skin tone picker by default |

View File

@ -45,6 +45,7 @@ class Example extends React.Component {
emoji: 'point_up', emoji: 'point_up',
title: 'Pick your emoji…', title: 'Pick your emoji…',
custom: CUSTOM_EMOJIS, custom: CUSTOM_EMOJIS,
useButton: false,
} }
} }

View File

@ -184,7 +184,7 @@ const NimbleEmoji = (props) => {
props: {}, props: {},
} }
if (props.onClick) { if (props.onClick && props.useButton) {
Tag.name = 'button' Tag.name = 'button'
Tag.props = { Tag.props = {
type: 'button', type: 'button',

View File

@ -521,6 +521,7 @@ export default class NimblePicker extends React.PureComponent {
showPreview, showPreview,
showSkinTones, showSkinTones,
emojiTooltip, emojiTooltip,
useButton,
include, include,
exclude, exclude,
recent, recent,
@ -601,6 +602,7 @@ export default class NimblePicker extends React.PureComponent {
forceSize: native, forceSize: native,
tooltip: emojiTooltip, tooltip: emojiTooltip,
backgroundImageFn: backgroundImageFn, backgroundImageFn: backgroundImageFn,
useButton: useButton,
onOver: this.handleEmojiOver, onOver: this.handleEmojiOver,
onLeave: this.handleEmojiLeave, onLeave: this.handleEmojiLeave,
onClick: this.handleEmojiClick, onClick: this.handleEmojiClick,

View File

@ -7,6 +7,7 @@ const EmojiDefaultProps = {
native: false, native: false,
forceSize: false, forceSize: false,
tooltip: false, tooltip: false,
useButton: true,
backgroundImageFn: (set, sheetSize) => backgroundImageFn: (set, sheetSize) =>
`https://unpkg.com/emoji-datasource-${set}@${EMOJI_DATASOURCE_VERSION}/img/${set}/sheets-256/${sheetSize}.png`, `https://unpkg.com/emoji-datasource-${set}@${EMOJI_DATASOURCE_VERSION}/img/${set}/sheets-256/${sheetSize}.png`,
} }
@ -36,6 +37,7 @@ const PickerDefaultProps = {
matchMedia('(prefers-color-scheme: dark)').matches matchMedia('(prefers-color-scheme: dark)').matches
), ),
emojiTooltip: EmojiDefaultProps.tooltip, emojiTooltip: EmojiDefaultProps.tooltip,
useButton: EmojiDefaultProps.useButton,
autoFocus: false, autoFocus: false,
enableFrequentEmojiSort: false, enableFrequentEmojiSort: false,
custom: [], custom: [],

View File

@ -10,6 +10,7 @@ const EmojiPropTypes = {
native: PropTypes.bool, native: PropTypes.bool,
forceSize: PropTypes.bool, forceSize: PropTypes.bool,
tooltip: PropTypes.bool, tooltip: PropTypes.bool,
useButton: PropTypes.bool,
skin: PropTypes.oneOf([1, 2, 3, 4, 5, 6]), skin: PropTypes.oneOf([1, 2, 3, 4, 5, 6]),
sheetSize: PropTypes.oneOf([16, 20, 32, 64]), sheetSize: PropTypes.oneOf([16, 20, 32, 64]),
sheetColumns: PropTypes.number, sheetColumns: PropTypes.number,
@ -39,6 +40,7 @@ const PickerPropTypes = {
showPreview: PropTypes.bool, showPreview: PropTypes.bool,
showSkinTones: PropTypes.bool, showSkinTones: PropTypes.bool,
emojiTooltip: EmojiPropTypes.tooltip, emojiTooltip: EmojiPropTypes.tooltip,
useButton: EmojiPropTypes.useButton,
include: PropTypes.arrayOf(PropTypes.string), include: PropTypes.arrayOf(PropTypes.string),
exclude: PropTypes.arrayOf(PropTypes.string), exclude: PropTypes.arrayOf(PropTypes.string),
recent: PropTypes.arrayOf(PropTypes.string), recent: PropTypes.arrayOf(PropTypes.string),

View File

@ -63,6 +63,7 @@ storiesOf('Picker', module)
showPreview={boolean('Show preview', true)} showPreview={boolean('Show preview', true)}
showSkinTones={boolean('Show skin tones', true)} showSkinTones={boolean('Show skin tones', true)}
enableFrequentEmojiSort={boolean('Enable frequent sort', false)} enableFrequentEmojiSort={boolean('Enable frequent sort', false)}
useButton={false}
custom={CUSTOM_EMOJIS} custom={CUSTOM_EMOJIS}
/> />
)) ))