// Package side is an app's side panel ([estilo-side]) and the frame that // puts it under the bar, beside
([estilo-side-frame]). Its rows // ([estilo-side-item]) are an icon and a label ([estilo-side-label]) with // an optional shortcut ([estilo-side-key]); page rows sit under section // headings ([estilo-side-head]), and the foot ([estilo-side-foot]) is // pinned to the bottom with the fold, which turns the side into a rail of // icons and back. // // Mapa built it (its level-up spec, §3.2) and Contra is the second app to // use it, so it moved here when Contra adopted it (AGENTS.md, decisions // table). The values and the behaviour are Mapa's, copied; changing them // is a design decision. // // Widths: from 80rem the side is open by default and below it a rail; // the State (a cookie the app keeps) overrides that from 800px. Below // 800px there is no side: its places belong in the bar's Menu sheet // (chrome.Bar.Nav), and the bar's own nav is hidden from 800px on a page // with a frame, because the side carries the places there. // // Script line: everything works with scripts off. Rows are links; the // fold is a form that POSTs the new state (SetState stores it), and the // frame draws it on the next page. JS() only folds in place, with the // same cookie, and adds ⌘\ (Ctrl+\ elsewhere). // // It carries no strings. Callers supply every label in their locale. package side import ( "embed" "html/template" "net/http" ) //go:embed side.css var css []byte //go:embed side.js var js []byte //go:embed templates/*.html var templateFS embed.FS // CSS returns side.css. Link it after chrome.css: the side's private // notes use chrome's [estilo-visually-hidden], and it sizes itself by // chrome's --estilo-bar-block-size. func CSS() []byte { return append([]byte(nil), css...) } // JS returns side.js, an optional classic script (defer) that folds the // side in place: any control with data-estilo-side-fold (the fold's own // buttons, or an app's menu row) and ⌘\ or Ctrl+\ switch the frame // between open and rail and set the fold's cookie. Focus stays on // screen: a fold button hands it to the other one, a menu row to its // menu's title, and a row the rail hides to the lit place (or the // fold). Escape dismisses a rail tooltip until the next hover or focus. // A page with no frame or no Fold has nothing to fold, and the script // leaves the shortcut alone. Without it the fold posts and the next page // is drawn folded. func JS() []byte { return append([]byte(nil), js...) } // Templates holds estilo-side, estilo-side-item, estilo-side-fold and the // side's two icons (estilo-icon-panel-left, estilo-icon-lock). Parse it // into the app's page templates with ParseFS(Templates(), "templates/*.html"). func Templates() embed.FS { return templateFS } // Side is estilo-side's data. // // The frame is the app's own markup, around the side and
: // //
// {{template "estilo-side" .}} //
…
//
type Side struct { // Label is the side's accessible name: the app's name ("Mapa"). Label string // State is what the side shows: "open", "rail", or "" to let the // width decide (open from 80rem). Write it as the frame's // estilo-side-frame value. Read it with State. State string // Places are the app's sections. They stay on the rail, as icons. Places []Item // Sections are lists of page rows under a heading ("Pinned", // "Recently edited"). The rail hides them. A section with no items // draws nothing, heading included. Sections []Section // Foot is app markup drawn at the top of the foot, before the fold // (Mapa's New team page): estilo-side-item rows the app rendered // itself, with estilo-side-label around each label so the rail can // make it the tooltip. Trusted markup, never user input. Foot template.HTML // Fold is the fold to a rail; nil leaves the side always as the // width draws it. Fold *Fold } // Section is one heading and its page rows. type Section struct { Heading string Items []Item } // Item is one row. type Item struct { Href, Label string // Icon is the row's glyph: the app's own inline