{% from "_macros.html" import icon, section_toggle %} {# A folder and everything under it. Recursive: a folder includes this same template for each of its children, so nesting has no fixed depth limit. Open/closed state is kept on the folder (`folder.collapsed`), written by app.js as the toggle is pressed (`POST /api/preferences/section`, key `folder:`) -- the same mechanism every other section heading uses. Kept only in the browser (Alpine), a folder somebody shut would open again on the next page, and on every out-of-band swap of the tree. The press is applied at once in the browser; the post costs nothing anybody waits for. Two shapes. A root folder (`nested` false, from `_sidebar_tree.html`) is a section of the sidebar like `[ CHATS ]` and each device: its name in brackets as the heading, which is what folds it, and its actions beside it in the heading's own icon-button boxes. A child folder (`nested` true) is an indented row under its parent. There is no `[ FOLDERS ]` label above them all: a heading that names the kind of the headings below it is a row that says nothing. The + is always shown, as every section's is -- it is the one thing done here most. Rename, settings and delete come up on hover or focus, the way a chat row's actions do, so four boxes do not crowd the name out of a 17.5rem sidebar; on a touchscreen they always show (`hover: none`, app.css). #} {% macro folder_actions(folder, box) -%} {# Start a chat already filed here, and already carrying whatever the folder seeds. Without this the only way into a folder is to make the chat somewhere else and move it. #} {{ icon("plus", "icon--sm") }} {%- endmacro %} {% macro folder_tools(folder, box) -%} {{ icon("sliders", "icon--sm") }} {%- endmacro %} {% set body_id = "section-folder-" ~ folder.id %} {% set is_open = not folder.collapsed %} {#- The whole folder is a drop target for a chat (js/dnd.js): the nearest one to the pointer wins, so a child folder inside it takes its own. -#} {% if nested %}
{% else %}