diff --git a/changelog.d/emoji-picker.add b/changelog.d/emoji-picker.add new file mode 100644 index 00000000..d0ddb18e --- /dev/null +++ b/changelog.d/emoji-picker.add @@ -0,0 +1 @@ +fixed occasional overflows in emoji picker and made header scrollable diff --git a/src/components/emoji_picker/emoji_picker.js b/src/components/emoji_picker/emoji_picker.js index ae48139a..9f415f79 100644 --- a/src/components/emoji_picker/emoji_picker.js +++ b/src/components/emoji_picker/emoji_picker.js @@ -135,21 +135,38 @@ const EmojiPicker = { Popover }, methods: { + groupScroll (e) { + e.currentTarget.scrollLeft += e.deltaY + e.deltaX + }, updateEmojiSize () { const css = window.getComputedStyle(this.$refs.popover.$el) + const fontSize = css.getPropertyValue('font-size') const emojiSize = css.getPropertyValue('--emojiSize') + + const fontSizeUnit = fontSize.replace(/[0-9,.]+/, '') + const fontSizeValue = Number(fontSize.replace(/[^0-9,.]+/, '')) + const emojiSizeUnit = emojiSize.replace(/[0-9,.]+/, '') const emojiSizeValue = Number(emojiSize.replace(/[^0-9,.]+/, '')) - const fontSize = css.getPropertyValue('font-size').replace(/[^0-9,.]+/, '') + + let fontSizeMultiplier + if (fontSizeUnit.endsWith('em')) { + fontSizeMultiplier = fontSizeValue + } else { + fontSizeMultiplier = fontSizeValue / 14 + } + console.log('Multiplier', fontSizeMultiplier) + console.log('Result', fontSizeMultiplier * 14) let emojiSizeReal if (emojiSizeUnit.endsWith('em')) { - emojiSizeReal = emojiSizeValue * fontSize + emojiSizeReal = emojiSizeValue * fontSizeMultiplier * 14 } else { emojiSizeReal = emojiSizeValue } + console.log(emojiSizeReal) - const fullEmojiSize = emojiSizeReal + (2 * 0.2 * fontSize) + const fullEmojiSize = emojiSizeReal + (2 * 0.2 * fontSizeMultiplier * 14) this.emojiSize = fullEmojiSize }, showPicker () { @@ -304,6 +321,7 @@ const EmojiPicker = { return this.emojiSize }, itemPerRow () { + console.log('CALC', this.emojiSize, this.width) return this.width ? Math.floor(this.width / this.emojiSize) : 6 }, activeGroupView () { diff --git a/src/components/emoji_picker/emoji_picker.scss b/src/components/emoji_picker/emoji_picker.scss index 12c09388..0c9a6600 100644 --- a/src/components/emoji_picker/emoji_picker.scss +++ b/src/components/emoji_picker/emoji_picker.scss @@ -49,6 +49,7 @@ .heading { display: flex; + flex-direction: column; padding: 0.7em 0.5em 0; } @@ -129,7 +130,7 @@ .emoji { &-search { - padding: 0.3em; + padding-bottom: 0.5em; flex: 0 0 auto; input { @@ -166,24 +167,6 @@ } } - &-group { - display: flex; - align-items: center; - flex-wrap: wrap; - justify-content: left; - - &-title { - font-size: 0.85em; - width: 100%; - margin: 0; - padding-left: 0.3em; - - &.disabled { - display: none; - } - } - } - &-item { width: var(--emoji-size); height: var(--emoji-size); @@ -206,9 +189,38 @@ } .emoji-picker-emoji.-unicode { - font-size: 1.6em; + font-size: calc(var(--emoji-size) * 0.8); overflow: hidden; } } + + &-group { + display: grid; + grid-template-columns: repeat(var(--__amount), 1fr); + align-items: center; + justify-items: center; + justify-content: center; + grid-template-rows: repeat(1, auto); + + &.first-row { + grid-template-rows: repeat(2, auto); + + .emoji-item { + grid-row: 2; + } + } + + &-title { + font-size: 0.85em; + grid-column: span var(--__amount); + width: 100%; + margin: 0; + padding-left: 0.3em; + + &.disabled { + display: none; + } + } + } } } diff --git a/src/components/emoji_picker/emoji_picker.vue b/src/components/emoji_picker/emoji_picker.vue index a3dc8f9e..2a2e260f 100644 --- a/src/components/emoji_picker/emoji_picker.vue +++ b/src/components/emoji_picker/emoji_picker.vue @@ -8,7 +8,19 @@ @close="onPopoverClosed" >