gab-social/app/javascript/gabsocial/components/autosuggest_emoji/index.js

36 lines
804 B
JavaScript
Raw Normal View History

import unicodeMapping from '../../features/emoji/emoji_unicode_mapping_light';
import './index.scss';
2019-07-02 08:10:25 +01:00
const assetHost = process.env.CDN_HOST || '';
export default class AutosuggestEmoji extends PureComponent {
2019-07-02 08:10:25 +01:00
static propTypes = {
emoji: PropTypes.object.isRequired,
};
render () {
const { emoji } = this.props;
let url;
if (emoji.custom) {
url = emoji.imageUrl;
} else {
const mapping = unicodeMapping[emoji.native] || unicodeMapping[emoji.native.replace(/\uFE0F$/, '')];
if (!mapping) return null;
2019-07-02 08:10:25 +01:00
url = `${assetHost}/emoji/${mapping.filename}.svg`;
}
return (
<div className='autosuggest-emoji'>
<img className='emojione' src={url} alt={emoji.native || emoji.colons} />
2019-07-02 08:10:25 +01:00
{emoji.colons}
</div>
);
}
}