Skip to content

feat(oc-docs): resizable, collapsible docs and playground sidebars - #139

Merged
bijin-bruno merged 8 commits into
opencollection-dev:mainfrom
sundram-bruno:feat/oc-docs-resizable-sidebars
Jul 23, 2026
Merged

feat(oc-docs): resizable, collapsible docs and playground sidebars#139
bijin-bruno merged 8 commits into
opencollection-dev:mainfrom
sundram-bruno:feat/oc-docs-resizable-sidebars

Conversation

@sundram-bruno

@sundram-bruno sundram-bruno commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

JIRA : BRU-3753

Summary

Make both sidebars drag-resizable and collapsible: the docs sidebar (AppShell) and the playground sidebar (PlaygroundBody).

Behaviour

  • Drag the right edge of either sidebar to resize its width (200-480px).
  • Widths are independent per sidebar and persist per browser tab via sessionStorage: restored on reload, cleared when the tab or browser is closed.
  • Dragging narrower sticks at the 200px minimum; keep dragging ~100px past it to collapse the sidebar. Within the same held gesture, dragging back to the minimum re-expands it.
  • The resize handle shows a 2px highlight (--oc-border-border2) on hover, and stays highlighted for the whole drag (even when the pointer outruns the handle at max width).
  • The resize cursor is held for the entire gesture and text selection is blocked while dragging.

Implementation

  • New useResizableSidebar hook: sessionStorage-backed width (read once via areaFor, persisted only when the drag settles) plus a collapse threshold.
  • Extended the shared useDockResize hook: added a leading edge (left sidebars grow rightward), onCollapse / onExpand handoff, drag listeners on window so the gesture survives the handle unmounting on collapse, a body cursor/selection lock, and requestAnimationFrame-coalesced width writes (at most one setSize per frame). Docks keep their previous behaviour via the trailing default.
  • Docs sidebar width is scoped via an inline --sidebar-width on .appshell-body; the playground scopes its own inline --sidebar-width, so the two stay independent. Collapse reuses the existing affordances to reopen (docs expand chevron, playground sidebar toggle).

Both sidebars can be drag-resized from their right edge (200-480px,
sessionStorage-persisted per tab, restored on reload). Dragging past the
min collapses the sidebar VS Code-style; dragging back within the same
held gesture re-expands it, with the resize cursor held throughout.

Adds useResizableSidebar (sessionStorage width + collapse threshold) and
extends useDockResize with a leading edge and collapse/expand handoff on
window listeners so the drag survives the handle unmounting.
Draws a 2px border2 line on the resize handle while hovered or actively
dragging (kept lit for the whole held gesture via data-dragging, so it
does not flicker when the pointer outruns the handle at max width). No
transition, so the highlight tracks fast hover changes during a resize.
Export areaFor from useStorage and call it from useResizableSidebar
instead of a duplicated SSR guard. Memoise the initial stored-width read
so it does not re-run on every render (once per pointer move during a
drag). Use the --z-sidebar token for the playground resizer z-index to
match AppShell.
…rame

Route the drag width update through requestAnimationFrame (cancel-prior)
so multiple pointermoves in a frame trigger at most one setSize, instead
of a re-render per dispatched move. Collapse/expand stay synchronous so
their timing is unchanged; the pending frame is cancelled on unmount.
…ble-sidebars

# Conflicts:
#	packages/oc-docs/src/components/Playground/PlaygroundBody/PlaygroundBody.tsx
Cover both sidebars: drag to widen, clamp at max, persist width across
reload (sessionStorage), overshoot-to-collapse with reopen, and
re-expand within the same held drag. Adds resize drag helpers to the
sidebar and playground page-object components.
Move the shared grab / movePointerToX / releasePointer trio (and the
drag-y state) onto BaseComponent so the sidebar and playground page
objects no longer duplicate them; each keeps only its handle-specific
grab wrapper.
@sundram-bruno
sundram-bruno marked this pull request as ready for review July 22, 2026 13:20
Comment thread packages/oc-docs/src/components/Playground/PlaygroundBody/StyledWrapper.ts Outdated
Address PR review: express the resize handle width, offset and hover
line in rem instead of px, matching the repo's rem-based sizing.
@bijin-bruno
bijin-bruno merged commit 912a721 into opencollection-dev:main Jul 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants