Skip to content

Expose sidebar width as CSS custom property and enable global resize#1

Closed
pierrefardel wants to merge 1 commit into
FRAMEWORK_6_0from
feature/sidebar-css-vars
Closed

Expose sidebar width as CSS custom property and enable global resize#1
pierrefardel wants to merge 1 commit into
FRAMEWORK_6_0from
feature/sidebar-css-vars

Conversation

@pierrefardel

Copy link
Copy Markdown
Owner

Horde computes the sidebar width in JavaScript and applies it as an inline style, which prevents themes from overriding it in pure CSS. This exposes the width as a CSS custom property (--horde-sidebar-width) on so themes can consume it directly.

It also adds a global drag-to-resize on the existing #horde-slideleftcursor handle — previously only IMP could resize the sidebar. The width is clamped between --horde-sidebar-min-width / --horde-sidebar-max-width and persisted in localStorage.

No existing behaviour is removed: the custom property is inert until a theme consumes it, so the default theme is unaffected.

cc @jcdelepine

Horde computes the sidebar width in JavaScript and applies it as an inline
style, which prevents themes from overriding it in pure CSS. This exposes the
width as a CSS custom property (--horde-sidebar-width) on <html> so themes can
consume it directly.

It also adds a global drag-to-resize on the existing #horde-slideleftcursor
handle — previously only IMP could resize the sidebar. The width is clamped
between --horde-sidebar-min-width / --horde-sidebar-max-width and persisted in
localStorage.

No existing behaviour is removed: the custom property is inert until a theme
consumes it, so the default theme is unaffected.
Copilot AI review requested due to automatic review settings June 16, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Horde sidebar initialization to expose the sidebar width as a CSS custom property (--horde-sidebar-width) on <html> and adds a global drag-to-resize behavior using the existing #horde-slideleftcursor handle, persisting the chosen width in localStorage.

Changes:

  • Initialize --horde-sidebar-width from the current sidebar width or a saved localStorage value.
  • Add a global mousedown/mousemove/mouseup drag handler to update --horde-sidebar-width and persist it.
  • Clamp drag-resized widths using --horde-sidebar-min-width / --horde-sidebar-max-width with JS fallbacks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread js/sidebar.js
Comment on lines +62 to +66
var saved = localStorage.getItem('horde_sidebar_width');
var w = saved
? parseInt(saved)
: (s.offsetWidth || parseInt(s.style.width) || 250);
document.documentElement.style.setProperty('--horde-sidebar-width', w + 'px');
Comment thread js/sidebar.js
document.documentElement.style.setProperty('--horde-sidebar-width', w + 'px');
}

/* Drag-resize sidebar globale */
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.

2 participants