Files
wekan/client/components/settings/leftMenu.jade
T
Lauri Ojansivu 920d42b6db The left menu is resized by dragging its inner edge.
The menu's inner edge - the right one while reading left to right, the left one
under a right-to-left language - now carries a grip, and dragging it changes the
width. It is the same control the right board sidebar has on its own inner edge:
the same 6px strip, the same col-resize cursor, the same nodragscroll so a drag
resizes the menu instead of panning the page behind it, and the same sign flip
on the delta so the widening drag mirrors under RTL rather than needing a second
rule kept in step.

ONE number, on <html>. The width is a CSS custom property,
--wekan-left-menu-width, and everything that needs it reads that: the Admin
Panel's menu, the All Boards one - whose grid track is auto, so the track
follows the menu - and the grip itself, which sits at calc(width - 3px) from the
row's inline start. An inline width on one element could not have done that: the
menu is a different element in a different template on each page.

The default is the number in the stylesheet, and a breakpoint that wants a
different default overrides the VARIABLE, never the menu's width - a rule naming
.side-menu would beat a dragged width, which arrives as an inline property on
<html>, at exactly that one screen size. For the same reason the client REMOVES
the property when nobody has dragged it rather than writing the default into it.
The Admin Panel menu's own width was min(250px, 32vw), which only ever resolved
to 250px above the 800px breakpoint; it is the shared 260px now, because the two
pages draw one menu and a menu has one width.

The grip is positioned against the row/grid around the menu, not inside it: the
menu is its own scroll area, and a handle within it would scroll away with the
entries. Being absolutely positioned it is neither a flex item nor a grid item,
so it adds no column and no gap - which is why the shared menu template can
carry it as a second root and every Admin Panel pane gets it without naming it.

Clamped to 160px..min(600px, window - 240px), with no drag on a phone, where the
menu is full width above the content, and none while it is folded, where there
is no edge to drag. The All Boards menu also takes max-width:100% now, because
the phone rules cap its track at 210px and a fixed width ran out past it.

Remembered in the same three layers as the fold: a Session value first, then
profile.leftMenuWidth, then the wekan-left-menu-width COOKIE when nobody is
signed in - the same cookie mechanism the fold uses rather than the localStorage
the right sidebar's width uses, so one reader's menu is not remembered in two
different places. Saved once, when the drag ends; while dragging, the property
is written directly so the edge follows the pointer without a database write per
pixel. The server method clamps again and refuses NaN, which passes
check(width, Number) and would otherwise store a width no page could recover
from.

Thanks to xet7 !
2026-08-01 22:13:03 +03:00

136 lines
6.3 KiB
Plaintext

//- The ONE left menu used by every Admin Panel page.
//- Design + the list of pages that use it: docs/Design/Page/Left-Menu.md
//-
//- "Left" is the reading order, not a side: under a right-to-left language the
//- whole panel mirrors and this menu sits on the RIGHT. That comes from logical
//- CSS on .side-menu, not from anything here — see the design doc.
//-
//- The three icon shapes below are the ones the pages already used, reproduced
//- exactly so converting a page changes no pixel:
//- emoji:true an empty span.emoji-icon before the icon (Settings,
//- Features) — the span carries its own font-size rule
//- iconWrapCls:'text-red' the icon wrapped in a coloured span.emoji-icon
//- (People → Locked users)
//- neither a bare i.fa (Problems, People, Translation, Info)
//-
//- Data context: { items } from buildMenuItems() in models/lib/leftMenu.js.
template(name="leftMenu")
//- TWO roots, and the handle is the second on purpose: it is positioned
against the ROW (.content-body), not against the menu, because the menu is
its own scroll area and a handle inside it would scroll away with the
entries. Here rather than in each page's template, so a new Admin Panel page
cannot draw the menu and forget the handle.
docs/Design/Page/Left-Menu.md
.side-menu(class="{{#if isLeftMenuCollapsed}}collapsed{{/if}}")
+leftMenuCollapse
ul
each items
if separator
li.left-menu-separator
hr
else if heading
//- A group title: text, not a row. No anchor, so there is nothing to
//- click and nothing for the page's click handler to read a data-id from.
li.left-menu-heading
if labelKey
| {{_ labelKey}}
else
| {{label}}
else
li(class="{{#if active}}active{{/if}} {{cls}}")
a.js-left-menu-item(class="{{jsClass}}" data-id="{{id}}")
if iconWrapCls
span.emoji-icon(class="{{iconWrapCls}}")
i.fa(class="{{icon}}")
else
if emoji
span.emoji-icon
i.fa(class="{{icon}}")
if labelKey
| {{_ labelKey}}
else
| {{label}}
+leftMenuResize
//- The grip that changes the menu's width, on its INNER edge - the right one
//- while reading left to right, the left one under a right-to-left language,
//- which the CSS mirrors by itself. It is the same gesture the right board
//- sidebar has on its own inner edge (sidebar.jade), and it is dragged the same
//- way: press, move, and the width is saved when let go.
//-
//- `nodragscroll` for the same reason the sidebar's has it: the board pages
//- drag-scroll on mousedown, and without it a drag on the grip would pan the
//- page instead of resizing the menu.
//-
//- It is positioned against the ROW around the menu rather than against the
//- menu, so it does not scroll with a long list of entries, and it follows the
//- menu because both read the same `--wekan-left-menu-width`.
//- client/components/settings/leftMenu.js, docs/Design/Page/Left-Menu.md
template(name="leftMenuResize")
.left-menu-resize-handle.js-left-menu-resize.nodragscroll(
title="{{_ 'drag-to-resize-left-menu'}}"
aria-label="{{_ 'drag-to-resize-left-menu'}}"
role="separator"
aria-orientation="vertical")
//- The title of the open pane, at the top of the content beside the menu. Its text
//- is the ACTIVE menu entry's own label (paneTitle() in models/lib/leftMenu.js), so
//- every Admin Panel pane has a heading, in the same words as the row that opened
//- it and - through the one .admin-pane-title class - at the same size. The shared
//- table page puts that class on its own title, so a table pane and a form pane
//- look the same.
//-
//- FOLDED, this heading is also the way back: the menu is gone entirely - no
//- column, no strip - so the caret moves here, to the inline start of the title,
//- and the caret AND the title are one target that brings the menu back. The
//- whole heading is inside the anchor for exactly that reason.
//-
//- It is drawn even when there is no title. paneTitle() returns {} when no menu
//- entry is active, and an empty heading is better than a folded menu with
//- nothing left to unfold it.
//-
//- Data context: { titleKey } or { label } from paneTitle().
template(name="paneTitle")
if isLeftMenuCollapsed
h1.admin-pane-title.admin-pane-title-folded
+leftMenuCollapse(paneTitleKey=titleKey paneLabel=label)
else if titleKey
h1.admin-pane-title {{_ titleKey}}
else if label
h1.admin-pane-title {{label}}
//- The caret that folds the menu away.
//-
//- The same control a LIST has on a board (listHeader.jade): a caret pointing
//- DOWN while the thing is open and RIGHT once it is folded, clicked to switch.
//- It is the collapse gesture WeKan already has, so there is nothing new to
//- learn, and it uses the same two words - Collapse / Uncollapse - in its
//- tooltip.
//-
//- It is drawn TWICE, and only ever one of them is on screen, because the menu
//- itself is not drawn while it is folded:
//- * at the top of the menu, where it points down and folds the menu away;
//- * at the inline start of the pane title, where it points right and brings
//- the menu back - see `paneTitle` above, which passes the pane's title in
//- so that caret and title are ONE target rather than two.
//- One template for both places and both pages, so the carets cannot drift.
//- client/components/settings/leftMenu.js
template(name="leftMenuCollapse")
a.left-menu-collapse-indicator.js-collapse-left-menu(
title="{{collapseLabel}}"
aria-label="{{collapseLabel}}"
role="button"
tabindex="0")
if isLeftMenuCollapsed
i.fa.fa-caret-right
else
i.fa.fa-caret-down
//- The pane's own title, when this is the caret beside it. `paneTitleKey` /
//- `paneLabel` rather than the `titleKey` / `label` paneTitle() itself uses,
//- so the caret in the MENU - which inherits whatever data context the menu
//- sits in - can never pick a title up by accident.
if paneTitleKey
span.left-menu-collapse-title {{_ paneTitleKey}}
else if paneLabel
span.left-menu-collapse-title {{paneLabel}}