From 04a06282e7cdf394b79f641a83e7d008df8e646d Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 7 Feb 2024 14:12:13 -0800 Subject: [PATCH] make the keyboard as wide and tall as we can without going over the other cvontent --- .../components/Keymap.js | 3 ++- .../components/Keymap.js | 4 ++++ src/renderer/screens/Editor.js | 23 +++++++++++++++++-- .../screens/Editor/components/KeyPicker.js | 9 +++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/api/hardware-keyboardio-atreus2/components/Keymap.js b/src/api/hardware-keyboardio-atreus2/components/Keymap.js index 8004b6876..5e9ff1af8 100644 --- a/src/api/hardware-keyboardio-atreus2/components/Keymap.js +++ b/src/api/hardware-keyboardio-atreus2/components/Keymap.js @@ -94,13 +94,14 @@ const Keymap = (props) => { ); }; - const { classes } = props; + const { classes, maxHeight } = props; return ( { clipRule="evenodd" viewBox="0 0 875 435" className={props.className || "layer"} + preserveAspectRatio="xMinYMin meet" + style={{ + maxHeight: props.maxHeight || "100%", + }} > { const [dialogOpen, setDialogOpen] = useState(false); const drawerHeightInRem = 20; + const [maxKeyboardHeight, setMaxKeyboardHeight] = useState("auto"); + + useEffect(() => { + function updateMaxKeyboardHeight() { + const remInPixels = parseFloat(getComputedStyle(document.documentElement).fontSize); + const maxHeightValue = window.innerHeight - (drawerHeightInRem + 3) * remInPixels; + setMaxKeyboardHeight(`${maxHeightValue}px`); + } + + // Set the initial maxHeight + updateMaxKeyboardHeight(); + + // Add event listener for window resize + window.addEventListener("resize", updateMaxKeyboardHeight); + + // Remove event listener on cleanup + return () => window.removeEventListener("resize", updateMaxKeyboardHeight); + }, []); + const { t } = useTranslation(); const maybeOpenMacroEditor = (state) => { @@ -388,7 +407,6 @@ const Editor = (props) => { } else { title = t("app.menu.colormapEditor"); } - console.log(theme); const currentKey = selectorKey || keymap.custom[currentLayer][currentKeyIndex]; @@ -410,6 +428,7 @@ const Editor = (props) => { mainWidget = ( { {macros && } - + {layerNames.storageSize > 0 && } {mainWidget} diff --git a/src/renderer/screens/Editor/components/KeyPicker.js b/src/renderer/screens/Editor/components/KeyPicker.js index 677152f1f..daeb60e6a 100644 --- a/src/renderer/screens/Editor/components/KeyPicker.js +++ b/src/renderer/screens/Editor/components/KeyPicker.js @@ -124,7 +124,14 @@ export const KeyPicker = (props) => { - +