bigbuffet-rw/app/soapbox/components/autosuggest_emoji.js

43 lines
953 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import PropTypes from 'prop-types';
import unicodeMapping from '../features/emoji/emoji_unicode_mapping_light';
2021-09-04 11:11:46 -07:00
import { join } from 'path';
2021-09-05 11:21:39 -07:00
import { FE_SUBDIRECTORY } from 'soapbox/build_config';
2020-03-27 13:59:38 -07:00
export default class AutosuggestEmoji extends React.PureComponent {
static propTypes = {
emoji: PropTypes.object.isRequired,
};
render() {
2020-03-27 13:59:38 -07:00
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;
}
2021-09-05 11:21:39 -07:00
url = join(FE_SUBDIRECTORY, 'emoji', `${mapping.filename}.svg`);
2020-03-27 13:59:38 -07:00
}
return (
<div className='autosuggest-emoji'>
<img
className='emojione'
src={url}
alt={emoji.native || emoji.colons}
/>
{emoji.colons}
</div>
);
}
}