// SPDX-License-Identifier: AGPL-3.0-or-later package web // Tree is a directory as a tree: the file finder on top, then the entries // with their last commit, and the notes on what is left out. A directory opens // in place (files.js); the keyboard walks the rows (j k l h, the arrows). templ Tree(l Layout, p TreePage) { @Shell(l, nil) {

{ p.Path } if p.Up != "" { .. } { itoa(len(p.Rows)) } { p.Unit() }
if len(p.Rows) == 0 {

this directory is empty.

} for _, n := range p.Notes {

{ n }

}
} } // TreeRows is the rows of a directory alone: what files.js inserts under a // directory it opens in place. When the directory has more entries than are // listed, the last row links to its page. templ TreeRows(p TreePage) { for _, r := range p.Rows { @TreeRowView(r) } if p.More != "" {
  • more entries: open the directory
  • } } // TreeRowView is one entry of a directory, a row of the tree: the guides of // its depth (t-twig), its node, its name, then its last commit. A directory // carries data-expand, the URL of its rows, and aria-expanded; files.js sets // the depth of the rows it inserts (data-depth, --depth, aria-level). // aria-posinset and aria-setsize count the entries of the row's own directory // (setsize -1: the listing is cut and the total unknown), so the positions // stay right once the rows of a directory are inserted into the flat list. The // node is drawn by the stylesheet from data-kind, which is aria-hidden: the // type of a directory, a link or a submodule is said in text for screen readers // (the .sr span, part of the name of the treeitem) and in a tooltip. templ TreeRowView(r TreeRow) { }