mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-25 01:24:02 -05:00
1e02ba111a
* Add emoji autosuggest Some credit goes to glitch-soc/mastodon#149 * Remove server-side shortcode->unicode conversion * Insert shortcode when suggestion is custom emoji * Remove remnant of server-side emojis * Update style of autosuggestions * Fix wrong emoji filenames generated in autosuggest item * Do not lazy load emoji picker, as that no longer works * Fix custom emoji autosuggest * Fix multiple "Custom" categories getting added to emoji index, only add once
38 lines
768 B
JavaScript
38 lines
768 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { unicodeMapping } from '../emojione_light';
|
|
|
|
const assetHost = process.env.CDN_HOST || '';
|
|
|
|
export default class AutosuggestEmoji extends React.PureComponent {
|
|
|
|
static propTypes = {
|
|
emoji: PropTypes.object.isRequired,
|
|
};
|
|
|
|
render () {
|
|
const { emoji } = this.props;
|
|
let url;
|
|
|
|
if (emoji.custom) {
|
|
url = emoji.imageUrl;
|
|
} else {
|
|
const [ filename ] = unicodeMapping[emoji.native];
|
|
url = `${assetHost}/emoji/${filename}.svg`;
|
|
}
|
|
|
|
return (
|
|
<div className='autosuggest-emoji'>
|
|
<img
|
|
className='emojione'
|
|
src={url}
|
|
alt={emoji.native || emoji.colons}
|
|
/>
|
|
|
|
{emoji.colons}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
}
|