Sha256: 33acae8df5e0cf526236af7be0f24cf97eee87da3807960681aa8fc953f0fa34
Contents?: true
Size: 860 Bytes
Versions: 96
Compression:
Stored size: 860 Bytes
Contents
import { Controller } from "@hotwired/stimulus" import { Picker } from 'emoji-mart' export default class extends Controller { static targets = [ "input", "display" ] connect() { this.visible = false this.picker = new Picker({ data: async () => { const response = await fetch( 'https://cdn.jsdelivr.net/npm/@emoji-mart/data', ) return response.json() }, onEmojiSelect: (emoji) => { this.displayTarget.innerHTML = emoji.native this.inputTarget.value = emoji.native this.element.removeChild(this.picker) this.visible = false }, }) } toggle(event) { event.preventDefault() if (this.visible) { this.element.removeChild(this.picker) } else { this.element.appendChild(this.picker) } this.visible = !this.visible } }
Version data entries
96 entries across 96 versions & 1 rubygems