Expose sidebar width as CSS custom property and enable global resize#1
Closed
pierrefardel wants to merge 1 commit into
Closed
Expose sidebar width as CSS custom property and enable global resize#1pierrefardel wants to merge 1 commit into
pierrefardel wants to merge 1 commit into
Conversation
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.
There was a problem hiding this comment.
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-widthfrom the current sidebar width or a savedlocalStoragevalue. - Add a global
mousedown/mousemove/mouseupdrag handler to update--horde-sidebar-widthand persist it. - Clamp drag-resized widths using
--horde-sidebar-min-width/--horde-sidebar-max-widthwith JS fallbacks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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'); |
| document.documentElement.style.setProperty('--horde-sidebar-width', w + 'px'); | ||
| } | ||
|
|
||
| /* Drag-resize sidebar globale */ |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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