make emoji picker more scalable
This commit is contained in:
parent
6846b4fe8a
commit
8981448448
|
@ -106,6 +106,9 @@ const EmojiPicker = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inject: ['popoversZLayer'],
|
inject: ['popoversZLayer'],
|
||||||
|
mounted () {
|
||||||
|
this.updateEmojiSize()
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
keyword: '',
|
keyword: '',
|
||||||
|
@ -120,6 +123,7 @@ const EmojiPicker = {
|
||||||
groupRefs: {},
|
groupRefs: {},
|
||||||
emojiRefs: {},
|
emojiRefs: {},
|
||||||
filteredEmojiGroups: [],
|
filteredEmojiGroups: [],
|
||||||
|
emojiSize: 0,
|
||||||
width: 0
|
width: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -130,6 +134,23 @@ const EmojiPicker = {
|
||||||
Popover
|
Popover
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
updateEmojiSize () {
|
||||||
|
const css = window.getComputedStyle(this.$refs.popover.$el)
|
||||||
|
const emojiSize = css.getPropertyValue('--emojiSize')
|
||||||
|
const emojiSizeUnit = emojiSize.replace(/[0-9,.]+/, '')
|
||||||
|
const emojiSizeValue = emojiSize.replace(/[^0-9,.]+/, '')
|
||||||
|
const fontSize = css.getPropertyValue('font-size').replace(/[^0-9,.]+/, '')
|
||||||
|
|
||||||
|
let emojiSizeReal
|
||||||
|
if (emojiSizeUnit.endsWith('em')) {
|
||||||
|
emojiSizeReal = emojiSizeValue * fontSize
|
||||||
|
} else {
|
||||||
|
emojiSizeReal = emojiSizeValue
|
||||||
|
}
|
||||||
|
|
||||||
|
const fullEmojiSize = emojiSizeReal + (2 * 0.2 * fontSize)
|
||||||
|
this.emojiSize = fullEmojiSize
|
||||||
|
},
|
||||||
showPicker () {
|
showPicker () {
|
||||||
this.$refs.popover.showPopover()
|
this.$refs.popover.showPopover()
|
||||||
this.onShowing()
|
this.onShowing()
|
||||||
|
@ -268,14 +289,25 @@ const EmojiPicker = {
|
||||||
minItemSize () {
|
minItemSize () {
|
||||||
return this.emojiHeight
|
return this.emojiHeight
|
||||||
},
|
},
|
||||||
|
// used to watch it
|
||||||
|
fontSize () {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.updateEmojiSize()
|
||||||
|
})
|
||||||
|
return this.$store.getters.mergedConfig.fontSize
|
||||||
|
},
|
||||||
emojiHeight () {
|
emojiHeight () {
|
||||||
return 32 + 4
|
return this.emojiSize
|
||||||
},
|
},
|
||||||
emojiWidth () {
|
emojiWidth () {
|
||||||
return 32 + 4
|
return this.emojiSize
|
||||||
},
|
},
|
||||||
itemPerRow () {
|
itemPerRow () {
|
||||||
return this.width ? Math.floor(this.width / this.emojiWidth - 1) : 6
|
console.log(
|
||||||
|
this.emojiWidth,
|
||||||
|
this.width
|
||||||
|
)
|
||||||
|
return this.width ? Math.floor(this.width / this.emojiWidth) : 6
|
||||||
},
|
},
|
||||||
activeGroupView () {
|
activeGroupView () {
|
||||||
return this.showingStickers ? '' : this.activeGroup
|
return this.showingStickers ? '' : this.activeGroup
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
$emoji-picker-header-height: 36px;
|
|
||||||
$emoji-picker-header-picture-width: 32px;
|
|
||||||
$emoji-picker-header-picture-height: 32px;
|
|
||||||
$emoji-picker-emoji-size: 32px;
|
|
||||||
|
|
||||||
.emoji-picker {
|
.emoji-picker {
|
||||||
width: 25em;
|
width: 25em;
|
||||||
max-width: calc(100vw - 20px); // popover gives 10px margin from window edge
|
max-width: calc(100vw - 20px); // popover gives 10px margin from window edge
|
||||||
|
@ -13,10 +8,10 @@ $emoji-picker-emoji-size: 32px;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: $emoji-picker-header-picture-width;
|
width: var(--emoji-size);
|
||||||
max-width: $emoji-picker-header-picture-width;
|
max-width: var(--emoji-size);
|
||||||
height: $emoji-picker-header-picture-height;
|
height: var(--emoji-size);
|
||||||
max-height: $emoji-picker-header-picture-height;
|
max-height: var(--emoji-size);
|
||||||
|
|
||||||
.still-image {
|
.still-image {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
@ -30,7 +25,7 @@ $emoji-picker-emoji-size: 32px;
|
||||||
.keep-open,
|
.keep-open,
|
||||||
.too-many-emoji,
|
.too-many-emoji,
|
||||||
.hide-custom-emoji {
|
.hide-custom-emoji {
|
||||||
padding: 7px;
|
padding: 0.5em;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,13 +39,13 @@ $emoji-picker-emoji-size: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.keep-open-label {
|
.keep-open-label {
|
||||||
padding: 0 7px;
|
padding: 0 0.5em;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 10px 7px 5px;
|
padding: 10px 0.5em 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
@ -71,7 +66,7 @@ $emoji-picker-emoji-size: 32px;
|
||||||
display: flex;
|
display: flex;
|
||||||
border-left: 1px solid;
|
border-left: 1px solid;
|
||||||
border-left-color: var(--border);
|
border-left-color: var(--border);
|
||||||
padding-left: 7px;
|
padding-left: 0.5em;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,13 +77,13 @@ $emoji-picker-emoji-size: 32px;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
|
|
||||||
&-item {
|
&-item {
|
||||||
padding: 0 7px;
|
padding: 0 0.5em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 1.85em;
|
font-size: 1.85em;
|
||||||
width: $emoji-picker-header-picture-width;
|
width: var(--emoji-size);
|
||||||
max-width: $emoji-picker-header-picture-width;
|
max-width: var(--emoji-size);
|
||||||
height: $emoji-picker-header-picture-height;
|
height: var(--emoji-size);
|
||||||
max-height: $emoji-picker-header-picture-height;
|
max-height: var(--emoji-size);
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
@ -98,7 +93,7 @@ $emoji-picker-emoji-size: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.toggled {
|
&.toggled {
|
||||||
border-bottom: 4px solid;
|
border-bottom: 0.2em solid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +120,7 @@ $emoji-picker-emoji-size: 32px;
|
||||||
|
|
||||||
.emoji {
|
.emoji {
|
||||||
&-search {
|
&-search {
|
||||||
padding: 5px;
|
padding: 0.3em;
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
|
@ -139,6 +134,7 @@ $emoji-picker-emoji-size: 32px;
|
||||||
flex: 1 1 1px;
|
flex: 1 1 1px;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
scrollbar-gutter: stable both-edges;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
mask:
|
mask:
|
||||||
linear-gradient(to top, white 0, transparent 100%) bottom no-repeat,
|
linear-gradient(to top, white 0, transparent 100%) bottom no-repeat,
|
||||||
|
@ -165,13 +161,13 @@ $emoji-picker-emoji-size: 32px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
padding-left: 5px;
|
|
||||||
justify-content: left;
|
justify-content: left;
|
||||||
|
|
||||||
&-title {
|
&-title {
|
||||||
font-size: 0.85em;
|
font-size: 0.85em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
padding-left: 0.3em;
|
||||||
|
|
||||||
&.disabled {
|
&.disabled {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -180,14 +176,14 @@ $emoji-picker-emoji-size: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-item {
|
&-item {
|
||||||
width: $emoji-picker-emoji-size;
|
width: var(--emoji-size);
|
||||||
height: $emoji-picker-emoji-size;
|
height: var(--emoji-size);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
line-height: $emoji-picker-emoji-size;
|
line-height: var(--emoji-size);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
margin: 4px;
|
margin: 0.2em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
.emoji-picker-emoji.-custom {
|
.emoji-picker-emoji.-custom {
|
||||||
|
@ -197,7 +193,7 @@ $emoji-picker-emoji-size: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emoji-picker-emoji.-unicode {
|
.emoji-picker-emoji.-unicode {
|
||||||
font-size: 24px;
|
font-size: 20.2em;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue