-
Notifications
You must be signed in to change notification settings - Fork 195
[feat]: Integration of layout-agnostic resizable partials #1128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
leecalcote
merged 4 commits into
layer5io:master
from
banana-three-join:feature/banana-three-join/resizable-element
Jun 28, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9c08c3a
[chore]: integration of layout-agnostic resizable partials, clean-up …
banana-three-join 74c4ccb
[chore]: addition of script to head script to base templates + additi…
banana-three-join 70181c0
[fix]: correct resizable width persistence, harden pointer handling, …
hortison a3692a2
Merge remote-tracking branch 'origin/master' into feature/banana-thre…
hortison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| (function () { | ||
| "use strict"; | ||
|
|
||
| function clamp(v, min, max) { return Math.max(min, Math.min(max, v)); } | ||
|
|
||
| function init(el) { | ||
| if (el.__resizableReady) return; | ||
|
|
||
| var side = el.dataset.resizableSide || "right"; | ||
| var key = el.dataset.resizableKey; | ||
| if (!key) return; | ||
| var storeKey = "resizable:" + key; | ||
| var min = parseFloat(el.dataset.resizableMin) || 0; | ||
| var max = parseFloat(el.dataset.resizableMax) || Infinity; | ||
| var def = parseFloat(el.dataset.resizableDefault) || min || 280; | ||
| var handle = el.querySelector(":scope > .resizable__handle"); | ||
| if (!handle) return; | ||
|
|
||
| el.__resizableReady = true; | ||
|
|
||
| function setWidth(px) { | ||
| var w = clamp(px, min, max); | ||
| el.style.setProperty("--resizable-w", w + "px"); | ||
| handle.setAttribute("aria-valuenow", String(Math.round(w))); | ||
| } | ||
|
|
||
| function save() { | ||
| localStorage.setItem(storeKey, parseFloat(getComputedStyle(el).width)); | ||
| } | ||
|
|
||
| var saved = parseFloat(localStorage.getItem(storeKey)); | ||
| setWidth(isNaN(saved) ? def : saved); | ||
|
|
||
| var startX = 0, startW = 0; | ||
|
|
||
| function onMove(e) { | ||
| var delta = side === "right" ? e.clientX - startX : startX - e.clientX; | ||
| setWidth(startW + delta); | ||
| } | ||
| function onUp(e) { | ||
| // Capture may already be released (e.g. the element was detached); guard it | ||
| // so a stray pointercancel can't leave listeners and is-resizing state stuck. | ||
| if (handle.hasPointerCapture(e.pointerId)) handle.releasePointerCapture(e.pointerId); | ||
| window.removeEventListener("pointermove", onMove); | ||
| window.removeEventListener("pointerup", onUp); | ||
| window.removeEventListener("pointercancel", onUp); | ||
| el.classList.remove("is-resizing"); | ||
| document.body.classList.remove("is-resizing"); | ||
| save(); | ||
| } | ||
|
|
||
| handle.addEventListener("pointerdown", function (e) { | ||
| e.preventDefault(); | ||
| startX = e.clientX; | ||
| startW = el.getBoundingClientRect().width; | ||
| handle.setPointerCapture(e.pointerId); | ||
| el.classList.add("is-resizing"); | ||
| document.body.classList.add("is-resizing"); | ||
| window.addEventListener("pointermove", onMove); | ||
| window.addEventListener("pointerup", onUp); | ||
| window.addEventListener("pointercancel", onUp); | ||
| }); | ||
|
|
||
| handle.addEventListener("dblclick", function () { setWidth(def); save(); }); | ||
|
|
||
| // Keyboard accessibility | ||
| handle.setAttribute("role", "separator"); | ||
| handle.setAttribute("aria-orientation", "vertical"); | ||
| handle.setAttribute("aria-label", "Resize " + key + " panel"); | ||
| handle.setAttribute("aria-valuemin", String(Math.round(min))); | ||
| if (isFinite(max)) handle.setAttribute("aria-valuemax", String(Math.round(max))); | ||
| handle.setAttribute("tabindex", "0"); | ||
| handle.addEventListener("keydown", function (e) { | ||
| var grow = side === "right" ? "ArrowRight" : "ArrowLeft"; | ||
| var shrink = side === "right" ? "ArrowLeft" : "ArrowRight"; | ||
| var step = e.shiftKey ? 40 : 12; | ||
| var w = parseFloat(getComputedStyle(el).width); | ||
| if (e.key === grow) w += step; | ||
| else if (e.key === shrink) w -= step; | ||
| else return; | ||
| e.preventDefault(); | ||
| setWidth(w); | ||
| save(); | ||
| }); | ||
| } | ||
|
|
||
| function initAll() { | ||
| document.querySelectorAll("[data-resizable]").forEach(init); | ||
| } | ||
|
|
||
| if (document.readyState === "loading") | ||
| document.addEventListener("DOMContentLoaded", initAll); | ||
| else initAll(); | ||
| })(); | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* resizable-bootstrap-overrides.scss — load ONLY in Bootstrap/Docsy consumers. | ||
| Reason: Bootstrap applies `.row > * { width:100%; max-width:100%; padding-inline }` | ||
| to every direct row child. Since .resizable is now a direct child of .row, | ||
| that rule overrides the component's own width. These selectors are 0,2,0, | ||
| so they win over `.row > *` (0,1,0) without !important. | ||
| Do NOT fold these into resizable.scss — they assume a Bootstrap `.row`. */ | ||
|
|
||
| .row > .resizable { | ||
| flex: 0 0 auto; | ||
| width: var(--resizable-w, 260px); | ||
| max-width: var(--resizable-max, 480px); | ||
| min-width: 0; | ||
| padding-inline: 0; // clear Bootstrap's gutter padding on the wrapper | ||
| } | ||
|
|
||
| /* Sidebar(s) are now fixed-px wrappers, not percentage columns, so main must | ||
| absorb the remaining space instead of holding col-xl-8's 66.66% max-width. */ | ||
| .row > main { | ||
| flex: 1 1 0; | ||
| max-width: none; | ||
| width: auto; | ||
| } | ||
|
|
||
| /* ── Sidebar wrapper inherits the sticky + full-height role ── | ||
| .td-sidebar was sticky as a direct .row child. Now .resizable is the | ||
| direct .row child, so the wrapper must carry sticky/height. Values match | ||
| .td-sidebar's originals (top: 5.5rem, height: calc(100vh - 5.5rem)). */ | ||
| [data-resizable-key="sidebar"] { | ||
| position: sticky; | ||
| top: 5.5rem; | ||
| height: calc(100vh - 5.5rem); | ||
| align-self: flex-start; // stick instead of stretching to row height | ||
| overflow: hidden; // wrapper clips; the aside scrolls internally | ||
| } | ||
|
|
||
| [data-resizable-key="sidebar"] .resizable__inner { | ||
| height: 100%; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| /* Demote the aside: the wrapper is sticky now, so .td-sidebar becomes a | ||
| plain full-height scroll panel. Keeps its gradient + padding; only the | ||
| positioning role moves up to the wrapper. */ | ||
| [data-resizable-key="sidebar"] .td-sidebar { | ||
| position: static; | ||
| height: 100%; // fill wrapper, not 100vh | ||
| top: auto; | ||
| // background-image, padding-top, overflow-y: auto, overflow-x: hidden | ||
| // all remain from the base rule and still apply. | ||
| } | ||
|
|
||
| @media screen and (max-width: 768px) { | ||
| /* Break the nowrap row so children can stack on their own lines. */ | ||
| .row.flex-xl-nowrap { | ||
| flex-wrap: wrap; | ||
| } | ||
|
|
||
| /* Sidebar: its own full-width row, on top, not resizable. */ | ||
| .row > .resizable[data-resizable-key="sidebar"] { | ||
| position: relative; /* NOT static — keeps handle anchored if shown; prevents overlap */ | ||
| flex: 1 1 100%; /* full row */ | ||
| top: auto; | ||
| width: 100%; | ||
| max-width: none; | ||
| height: auto; /* was fit-content — auto is safer for stacked flow */ | ||
| overflow: visible; | ||
| order: 0; /* ensure it comes before main */ | ||
| box-sizing: border-box; /* padding counts inside the 100%, not added to it */ | ||
| padding-inline: 0; /* clear Bootstrap's gutter that returns at mobile */ | ||
| } | ||
|
|
||
| /* Inner + aside follow the auto height instead of the desktop 100vh. */ | ||
| [data-resizable-key="sidebar"] .resizable__inner { height: auto; overflow: visible; } | ||
| [data-resizable-key="sidebar"] .td-sidebar { height: auto; } | ||
|
|
||
| .row > main { | ||
| flex: 1 1 100%; | ||
| max-width: none; | ||
| order: 1; /* after the sidebar */ | ||
| } | ||
|
|
||
| .resizable .resizable__handle { | ||
| display: none; | ||
| pointer-events: none; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor Resizable Initialization for Robustness and Adherence to Style Rules
This refactoring addresses several critical areas of improvement:
--resizable-min,--resizable-max,--resizable-default) directly fromgetComputedStyle(el)instead of hardcoding fallback values in JavaScript, adhering to the general rules.localStorageAccess: Wraps alllocalStoragereads and writes intry-catchblocks to prevent script crashes in environments where local storage is blocked or unavailable (e.g., private browsing, iframe previews).el.dataset.resizableKeyandhandlebefore settingel.__resizableReady = trueto avoid marking invalid elements as ready.pointercancelto ensure event listeners are cleaned up and resizing state is reset if the gesture is interrupted.References