You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
931 B
35 lines
931 B
import { TinyEmitter as Emitter } from 'tiny-emitter';
|
|
|
|
import { Emoji } from './emoji';
|
|
import { createElement } from './util';
|
|
|
|
import { EmojiButtonOptions, EmojiRecord } from './types';
|
|
|
|
const CLASS_EMOJI_CONTAINER = 'emoji-picker__emojis';
|
|
|
|
export class EmojiContainer {
|
|
private emojis: EmojiRecord[];
|
|
|
|
constructor(emojis: EmojiRecord[], private showVariants: boolean, private events: Emitter, private options: EmojiButtonOptions) {
|
|
this.emojis = emojis.filter(
|
|
e => !e.ver || parseFloat(e.ver) <= parseFloat(options.emojiVersion as string)
|
|
);
|
|
}
|
|
|
|
render(): HTMLElement {
|
|
const emojiContainer = createElement('div', CLASS_EMOJI_CONTAINER);
|
|
this.emojis.forEach(emoji =>
|
|
emojiContainer.appendChild(
|
|
new Emoji(
|
|
emoji,
|
|
this.showVariants,
|
|
true,
|
|
this.events,
|
|
this.options
|
|
).render()
|
|
)
|
|
);
|
|
|
|
return emojiContainer;
|
|
}
|
|
}
|
|
|