mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 18:43:41 -05:00
web/menu: read emoji picker height from css
This commit is contained in:
parent
af2fe22ec0
commit
1a0f79108e
2 changed files with 13 additions and 1 deletions
|
@ -91,6 +91,7 @@
|
|||
--timeline-status-size: 4rem;
|
||||
|
||||
--image-picker-width: 22rem;
|
||||
/* Note: this must be a constant rem or px value (no references to other variables or anything else) */
|
||||
--image-picker-height: 34rem;
|
||||
--image-picker-category-rows: 3;
|
||||
|
||||
|
|
|
@ -50,7 +50,18 @@ export const usePrimaryItems = (
|
|||
closeModal()
|
||||
}
|
||||
const onClickReact = (mevt: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const emojiPickerHeight = 34 * 16
|
||||
const bodyStyle = getComputedStyle(document.body)
|
||||
const rawHeight = bodyStyle.getPropertyValue("--image-picker-height")
|
||||
let emojiPickerHeight: number
|
||||
if (rawHeight.endsWith("px")) {
|
||||
emojiPickerHeight = +rawHeight.slice(0, -2)
|
||||
} else if (rawHeight.endsWith("rem")) {
|
||||
const fontSize = +bodyStyle.getPropertyValue("font-size").replace("px", "")
|
||||
emojiPickerHeight = +rawHeight.slice(0, -3) * fontSize
|
||||
} else {
|
||||
console.warn("Invalid --image-picker-height value", rawHeight)
|
||||
emojiPickerHeight = 34 * 16
|
||||
}
|
||||
setForceOpen?.(true)
|
||||
openModal({
|
||||
content: <EmojiPicker
|
||||
|
|
Loading…
Add table
Reference in a new issue