diff --git a/src/core/islands/Panel.mjs b/src/core/islands/Panel.mjs index 9cf4e33..3ff913b 100644 --- a/src/core/islands/Panel.mjs +++ b/src/core/islands/Panel.mjs @@ -1,4 +1,3 @@ -1; /** * notion-enhancer * (c) 2023 dragonwocky (https://dragonwocky.me/) @@ -23,7 +22,7 @@ function Panel({ _setWidth, _getOpen, _setOpen, - minWidth = 260, + minWidth = 250, maxWidth = 640, transitionDuration = 300, ...props @@ -66,12 +65,14 @@ function Panel({ ${$resizeHandle}
<${Select} + popupMode="dropdown" + maxWidth="${maxWidth}" class="w-full text-left" ...${{ _get, _set, values, maxWidth: maxWidth - 56 }} /> diff --git a/src/core/menu/islands/Popup.mjs b/src/core/menu/islands/Popup.mjs index ac74b3d..94496e6 100644 --- a/src/core/menu/islands/Popup.mjs +++ b/src/core/menu/islands/Popup.mjs @@ -4,23 +4,34 @@ * (https://notion-enhancer.github.io/) under the MIT license */ -function Popup({ trigger, ...props }, ...children) { - const { html, extendProps, setState, useState } = globalThis.__enhancerApi; +function Popup( + { trigger, mode = "left", width = 250, maxWidth, ...props }, + ...children +) { + const { html, extendProps, setState, useState } = globalThis.__enhancerApi, + // known values for mode: + // dropdown => panel switcher + isDropdown = mode === "dropdown", + // left => menu option select + isLeft = mode === "left"; extendProps(props, { class: `notion-enhancer--menu-popup group/popup - absolute top-0 left-0 w-full h-full z-20 text-left - flex-(& col) justify-center items-end font-normal - pointer-events-none`, + absolute top-0 left-0 z-20 text-left font-normal + flex-(& col) justify-center pointer-events-none + items-end w-full ${isDropdown ? "" : "h-full"}`, }); const $popup = html`
-
+
${children}
diff --git a/src/core/menu/islands/Select.mjs b/src/core/menu/islands/Select.mjs index f3a9bfe..3fc7b33 100644 --- a/src/core/menu/islands/Select.mjs +++ b/src/core/menu/islands/Select.mjs @@ -37,6 +37,7 @@ function Select({ _get, _set, _requireReload = true, + popupMode = "left", maxWidth = 256, ...props }) { @@ -66,6 +67,7 @@ function Select({ ${$select} <${Popup} trigger=${$select} + mode=${popupMode} onbeforeclose=${() => { $select.style.width = `${$select.offsetWidth}px`; $select.style.background = "transparent";