pleroma/app/soapbox/components/emoji-selector.tsx

56 lines
1.4 KiB
TypeScript
Raw Normal View History

// import classNames from 'clsx';
import React from 'react';
import { HotKeys } from 'react-hotkeys';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { connect } from 'react-redux';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
import { EmojiSelector as RealEmojiSelector } from 'soapbox/components/ui';
2022-03-31 17:01:20 -07:00
import type { List as ImmutableList } from 'immutable';
import type { RootState } from 'soapbox/store';
const mapStateToProps = (state: RootState) => ({
allowedEmoji: getSoapboxConfig(state).allowedEmoji,
});
2022-03-31 17:01:20 -07:00
interface IEmojiSelector {
allowedEmoji: ImmutableList<string>,
2022-03-31 18:47:28 -07:00
onReact: (emoji: string) => void,
2022-03-31 17:01:20 -07:00
onUnfocus: () => void,
visible: boolean,
focused?: boolean,
}
class EmojiSelector extends ImmutablePureComponent<IEmojiSelector> {
2022-03-31 17:01:20 -07:00
static defaultProps: Partial<IEmojiSelector> = {
onReact: () => { },
onUnfocus: () => { },
visible: false,
2023-01-05 09:55:08 -08:00
};
2020-05-21 22:08:55 -07:00
handlers = {
open: () => { },
};
render() {
const { visible, focused, allowedEmoji, onReact, onUnfocus } = this.props;
return (
2022-03-31 18:32:53 -07:00
<HotKeys handlers={this.handlers}>
<RealEmojiSelector
emojis={allowedEmoji.toArray()}
onReact={onReact}
visible={visible}
focused={focused}
onUnfocus={onUnfocus}
/>
</HotKeys>
);
}
}
2022-03-31 17:01:20 -07:00
export default connect(mapStateToProps)(EmojiSelector);