Repository navigation
sidebar toggle: slide animation, navbar button, [ hotkey - #1573
Merged
Merged
Conversation
The sidebar toggle button switched the sidebar off with d-none and swapped the grid classes of the content column from javascript. That had a few rough edges: - the state was only applied once the stimulus controller connected, so a hidden sidebar flashed up on every full page load - the change was abrupt, and datatables kept their old column widths (and fixed header width) until the window was resized - the button stayed at the window border, far away from the sidebar it belongs to, and had no accessible name or state The state is now a single class on the root element. A tiny inline script at the start of the body applies it from localStorage before the sidebar is rendered, and as turbo only swaps the body it also survives navigations. The sliding itself is plain css (only for md and up, so the collapsing sidebar on small screens is untouched), the button sits on the edge of the sidebar and moves with it. When the transition has finished a resize event is dispatched, so that datatables and everything else that depends on the available width recalculates. The storage key is unchanged, so existing preferences are kept.
The toggle was a 10px wide outlined chevron, which is nearly invisible (especially in dark mode): nobody finds it. It is now a filled 18x64px tab, vertically centered on the edge of the sidebar, highlighted on hover.
The handle is a small target; a key is quicker when switching between browsing the tree and reading a wide table. Like the search hotkey it is ignored while typing in a field, and it does nothing on small screens, where the button is not shown.
The check whether the button is shown used offsetParent, which is always null for a position: fixed element, so the key was ignored everywhere.
Member
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1573 +/- ##
============================================
+ Coverage 62.97% 64.44% +1.46%
- Complexity 10071 10210 +139
============================================
Files 748 762 +14
Lines 32315 32711 +396
============================================
+ Hits 20351 21081 +730
+ Misses 11964 11630 -334 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The tab on the sidebar's edge was fixed over the first pixels of the content column, in both states. As a button at the start of the navbar it covers nothing, does not move when the sidebar slides, and no longer needs to track the sidebar's width per breakpoint. The [ key and the persisted state are unchanged.
The table-columns icon read as a table or layout setting, not as the sidebar. Font Awesome Free has no sidebar icon, so the usual glyph is drawn inline: a window outline with a left pane, which is filled while the sidebar is shown and empty while it is hidden, so the button also shows the state.
Contributor
Author
Member
|
Thanks. I think that looks better. And i really like the color change of the symbol ;) |
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.



The sidebar toggle button already hides the left sidebar, but it had a few rough edges:
This PR reworks it:
[anywhere outside a text field toggles the sidebar (ignored on small screens, where the button is not shown). The tooltip mentions the key.No new translation strings: the existing
sidebar.big.toggleis reused.Update: an earlier version of this PR used a filled tab on the sidebar's edge. As noted in the review it was too prominent and overlapped the main content, so it was replaced by the navbar button described above.