web/menu: read emoji picker height from css
Some checks are pending
Go / Lint Go (old) (push) Waiting to run
Go / Lint Go (latest) (push) Waiting to run
JS / Lint JS (push) Waiting to run

This commit is contained in:
Tulir Asokan 2025-04-18 00:53:28 +03:00
parent af2fe22ec0
commit 1a0f79108e
2 changed files with 13 additions and 1 deletions

View file

@ -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;

View file

@ -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