Skip to content

feat(sidebar): adjustable sidebar width with min/max clamp (fixes #38) - #45

Merged
charandeep-reddy merged 1 commit into
charandeep-reddy:mainfrom
webdevsamran:feat/adjustable-sidebar-width
Aug 20, 2026
Merged

charandeep-reddy merged 1 commit into
charandeep-reddy:mainfrom
webdevsamran:feat/adjustable-sidebar-width

Conversation

@webdevsamran

Copy link
Copy Markdown
Contributor

Summary

Closes #38

Implements a draggable resize handle on the sidebar so users can adjust its width between a configurable minimum and maximum.

Changes

New files

  • src/lib/sidebar-width.ts – Constants (DEFAULT_SIDEBAR_WIDTH = 270, MIN_SIDEBAR_WIDTH = 220, MAX_SIDEBAR_WIDTH = 420) and pure helpers clampSidebarWidth and parseSidebarWidth.
  • src/components/sidebar/use-sidebar-width.ts – useStoredSidebarWidth() hook built on useSyncExternalStore + the existing local-storage helpers so the stored value is SSR-safe and updates reactively across tabs. setStoredSidebarWidth() companion setter.
  • tests/sidebar-width.test.ts – Unit tests covering clamping, default fallback, NaN/Infinity/non-numeric strings.

Modified

  • src/components/sidebar/sidebar.tsx
    • Replaced the hardcoded w-[270px] with a dynamic width derived from useStoredSidebarWidth().
    • Drag is tracked with dragWidth local state (null when idle) so there is no extra render cycle on mouse-up; the persisted value takes over immediately via useSyncExternalStore.
    • A resize handle div with role="separator" is positioned absolutely on the right edge, visible only on lg: breakpoint, with cursor-col-resize and hover/active accent tints.
    • Transition duration is set to 0ms while dragging so the sidebar tracks the cursor frame-perfectly.

Testing

  • bun run test — 40 test files, 390 passed, 1 skipped (pre-existing)
  • bun run typecheck — Types generated successfully, no errors
  • bun run lint — No warnings or errors

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

@webdevsamran is attempting to deploy a commit to the charan Team on Vercel.

A member of the Team first needs to authorize it.

@charandeep-reddy charandeep-reddy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified locally — typecheck, lint, and the new tests all pass on the branch. Clean implementation, matches the existing sidebar-collapse pattern well. Two minor follow-ups (drag not canceling if the mouseup happens outside the window, and no keyboard resize) — merging and will patch those directly.

@charandeep-reddy
charandeep-reddy merged commit f9b24f4 into charandeep-reddy:main Aug 20, 2026
1 of 2 checks passed
charandeep-reddy added a commit that referenced this pull request Aug 20, 2026
…a full-height bar

The full-height colored rail from #45 read as a second border rather
than a control. The hit target stays full-height for an easy grab, but
now only a small centered pill is ever painted — transparent at rest,
tinted on hover, solid while dragging.

Also cancels the drag if the window loses focus mid-drag (alt-tab, an
OS dialog stealing the mouseup) instead of leaving it to self-heal on
whatever the next unrelated click in the window happens to be, and
drops the now-dead lg:w-0 class the inline width style already covers.
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.

Adjustable sidebar width, with a min and max

2 participants