| 1 | {{/* The frame's pieces (level-up spec §3), rendered by frame.go: the |
| 2 | menu bar and the lead go into estilo's bar slots; the sidebar and the |
| 3 | shortcuts dialog are drawn by shell.html. */}} |
| 4 | |
| 5 | {{/* mapa-menubar: File, Edit, Insert, View, Help. Each menu is a |
| 6 | <details> in estilo's exclusive group, so it opens with no script |
| 7 | (Docs' editor_bar.html gives the reasoning). A command row is |
| 8 | disabled until mapa.js binds it; a form row is a real POST, so the |
| 9 | View rows work with scripts off. Data: menuBar. */}} |
| 10 | {{define "mapa-menubar"}}<nav estilo-menubar aria-label="{{.Label}}"> |
| 11 | {{- range .Menus}}<details estilo-menubar-menu name="estilo-menus" id="mapa-menu-{{.ID}}"> |
| 12 | <summary estilo-menubar-title>{{.Title}}</summary> |
| 13 | <div estilo-menu>{{template "mapa-menu-items" .Items}} |
| 14 | </div> |
| 15 | </details>{{end}} |
| 16 | </nav>{{end}} |
| 17 | |
| 18 | {{/* mapa-menu-items: a menu's rows, the bar's and a sidebar row's ⋯ |
| 19 | alike (build note 88). Data: []menuEntry. */}} |
| 20 | {{define "mapa-menu-items"}} |
| 21 | {{- range .}} |
| 22 | {{- if eq .Kind "divider"}}<hr> |
| 23 | {{- else if eq .Kind "link"}}<a estilo-menu-item{{if .Danger}}="danger"{{end}} href="{{.Href}}">{{template "mapa-menu-body" .}}</a> |
| 24 | {{- else if eq .Kind "form"}}<form method="post" action="{{.Action}}">{{range $name, $value := .Fields}}<input type="hidden" name="{{$name}}" value="{{$value}}">{{end}}<button estilo-menu-item type="submit"{{with .Command}} data-mapa-command="{{.}}"{{end}}>{{template "mapa-menu-body" .}}</button></form> |
| 25 | {{- else if eq .Kind "dialog"}}<button estilo-menu-item type="button" commandfor="{{.Dialog}}" command="show-modal">{{template "mapa-menu-body" .}}</button> |
| 26 | {{- else}}<button estilo-menu-item type="button" data-mapa-command="{{.Command}}" disabled>{{template "mapa-menu-body" .}}</button> |
| 27 | {{- end}} |
| 28 | {{- end}} |
| 29 | {{- end}} |
| 30 | {{define "mapa-menu-body"}}<span estilo-menu-label>{{.Label}}</span>{{with .Key}}<kbd estilo-menu-key aria-hidden="true">{{.}}</kbd>{{end}}{{end}} |
| 31 | |
| 32 | {{/* mapa-lead: presence on a team page, the save status on the editor, |
| 33 | and a daily note's ‹ Today › pill (§3.1, §4.4). Data: leadView. */}} |
| 34 | {{define "mapa-lead"}} |
| 35 | {{- with .Editing}}<span mapa-presence>{{range $i, $who := .}}{{if $i}}, {{end}}{{$who}}{{end}} {{if eq (len .) 1}}is{{else}}are{{end}} editing</span>{{end}} |
| 36 | {{- if .Status}}{{template "estilo-save-status" saveStatus}}{{end}} |
| 37 | {{- with .Day}}{{template "mapa-day-pill" .}}{{end}} |
| 38 | {{- end}} |
| 39 | |
| 40 | {{/* mapa-day-pill: ‹ Today ›. The middle names the day on screen and |
| 41 | opens the month (a <details>, so it works with no script). Data: |
| 42 | dayPill. */}} |
| 43 | {{define "mapa-day-pill"}}<nav mapa-day aria-label="Days"> |
| 44 | <a mapa-day-step href="/d/{{.Prev}}" aria-label="Previous day, {{longDate .Prev}}">{{icon "chevron-left"}}</a> |
| 45 | <details mapa-calendar name="estilo-menus"{{if .Open}} open{{end}}> |
| 46 | <summary mapa-day-now aria-label="{{longDate .Date}}: choose a day">{{icon "calendar"}}<span>{{if eq .Date .Today}}Today{{else}}{{shortDate .Date}}{{end}}</span></summary> |
| 47 | {{with .Month}}{{template "mapa-month" .}}{{end}} |
| 48 | </details> |
| 49 | <a mapa-day-step href="/d/{{.Next}}" aria-label="Next day, {{longDate .Next}}">{{icon "chevron-right"}}</a> |
| 50 | </nav>{{end}} |
| 51 | |
| 52 | {{/* mapa-month: a month of links, weeks from the reader's locale's |
| 53 | first day (§4.4, build note 85). A dot is a |
| 54 | day you wrote a note; today is ringed; the day on screen is filled. |
| 55 | ‹ › page the month with ?month=. Data: MonthView. */}} |
| 56 | {{define "mapa-month"}}<div mapa-month> |
| 57 | <div mapa-month-head> |
| 58 | <strong>{{.Title}}</strong> |
| 59 | <a mapa-icon-link href="?month={{.Prev}}" aria-label="Previous month">{{icon "chevron-left"}}</a> |
| 60 | <a mapa-icon-link href="?month={{.Next}}" aria-label="Next month">{{icon "chevron-right"}}</a> |
| 61 | </div> |
| 62 | <table mapa-month-grid> |
| 63 | <thead><tr>{{range .Heads}}<th abbr="{{.Name}}">{{.Letter}}</th>{{end}}</tr></thead> |
| 64 | <tbody>{{range .Weeks}}<tr>{{range .}}<td><a href="/d/{{.Date}}" aria-label="{{longDate .Date}}{{if .Wrote}}, a note you wrote{{end}}{{if .Today}}, today{{end}}"{{if .Current}} aria-current="date"{{end}}{{if .Today}} mapa-today{{end}}{{if .Wrote}} mapa-wrote{{end}}{{if .Outside}} mapa-outside{{end}}>{{.Number}}</a></td>{{end}}</tr>{{end}}</tbody> |
| 65 | </table> |
| 66 | <div mapa-month-foot><span><span mapa-dot aria-hidden="true"></span> A note you wrote</span><a rst-btn href="/">Today</a></div> |
| 67 | </div>{{end}} |
| 68 | |
| 69 | {{/* mapa-links-panel: the Links panel (§4.3), Docs' inspector glass at |
| 70 | the inline end from 64rem; at narrower widths and with the panel |
| 71 | off the same lists are at the page's foot, and on a phone this is a |
| 72 | sheet. Its state is the mapa-links cookie, rendered. Data: dict |
| 73 | Page (PageView), Week (*WeekView or nil), State. */}} |
| 74 | {{define "mapa-links-panel"}}{{$page := .Page}}<aside mapa-links id="mapa-links" aria-label="Links"{{if eq .State "closed"}} hidden{{end}}> |
| 75 | <button mapa-peek type="button" hidden aria-expanded="false" aria-controls="mapa-links-body"><span mapa-grabber aria-hidden="true"></span><span>{{icon "map"}}{{template "mapa-peek-line" .}}</span></button> |
| 76 | <div mapa-links-body id="mapa-links-body"> |
| 77 | {{with .Week}}{{template "mapa-week" .}}{{end}} |
| 78 | {{with $page.Around}}{{if not $.Week}}<section aria-labelledby="mapa-around-h"><h2 id="mapa-around-h">Around this page</h2>{{template "mapa-map" .Map}}</section>{{end}}{{end}} |
| 79 | {{template "mapa-panel-linked" dict "ID" "mapa-p-backlinks" "Heading" "Linked from" "Items" $page.Backlinks "Empty" (or (and .Week "Nothing links to this day yet.") "Nothing links here yet.") "Target" 0}} |
| 80 | {{if eq $page.Kind "page"}}{{template "mapa-panel-linked" dict "ID" "mapa-p-mentions" "Heading" "Mentioned without a link" "Items" $page.Mentions "Empty" "No unlinked mentions." "Target" $page.Public}}{{end}} |
| 81 | {{template "mapa-links-out" $page}} |
| 82 | </div> |
| 83 | </aside>{{end}} |
| 84 | {{define "mapa-peek-line"}}{{if .Week}}This week, and links out{{else}}Linked from {{number L (len .Page.Backlinks)}}{{if eq .Page.Kind "page"}}, mentioned in {{number L (len .Page.Mentions)}}{{end}}{{end}}{{end}} |
| 85 | |
| 86 | {{define "mapa-links-out"}}<section rst-stack rst-section aria-labelledby="mapa-out-h"><h2 id="mapa-out-h">Links out {{with .Around}}<small>{{number L (len .Out)}}</small>{{end}}</h2> |
| 87 | {{with .Around}}{{with .Out}}<p mapa-chips>{{range .}}<a mapa-chip="{{.Kind}}" href="{{.Href}}">{{if eq .Kind "date"}}{{icon "calendar"}}{{else if eq .Kind "pending"}}{{icon "file-plus"}}{{else}}{{pageIcon .Look "file"}}{{end}}<span>{{.Label}}</span>{{if eq .Kind "pending"}}<span mapa-sr>, page not written yet</span>{{end}}</a>{{end}}</p> |
| 88 | {{else}}<p mapa-meta>{{if eq $.Kind "daily"}}No links out yet.{{else}}This page links nowhere yet.{{end}}</p>{{end}}{{end}} |
| 89 | </section>{{end}} |
| 90 | |
| 91 | {{/* mapa-panel-linked: Linked from or Mentioned, as the panel lists |
| 92 | them: the page, then each block that does it. Keys as mapa-linked. */}} |
| 93 | {{define "mapa-panel-linked"}}<section aria-labelledby="{{.ID}}"> |
| 94 | <h2 id="{{.ID}}">{{.Heading}} <small>{{number L (len .Items)}}</small></h2> |
| 95 | {{if .Items}}{{$target := .Target}}<ul mapa-refs> |
| 96 | {{range .Items}}<li><a mapa-ref-src href="{{.Href}}">{{if eq .Kind "daily"}}{{icon "calendar"}}{{else if eq .Kind "scratch"}}{{icon "file"}}{{else}}{{pageIcon .Look "file-text"}}{{end}}<span>{{.Label}}</span>{{if ne .Kind "page"}}<span mapa-only-you>{{icon "lock"}}Only you</span>{{end}}</a> |
| 97 | {{$source := .Public}}{{range .Contexts}}<div mapa-ref-ctx>{{.HTML}} |
| 98 | {{if $target}}<form method="post" action="/p/{{$target}}/mentions"><input type="hidden" name="grammar" value="{{grammar}}"><input type="hidden" name="source" value="{{$source}}"><input type="hidden" name="block" value="{{.Block}}"><button rst-btn="sm" type="submit">{{icon "link"}}Link it</button></form>{{end}} |
| 99 | </div>{{end}}</li> |
| 100 | {{end}}</ul> |
| 101 | {{else}}<p mapa-meta>{{.Empty}}</p>{{end}} |
| 102 | </section>{{end}} |
| 103 | |
| 104 | {{/* mapa-map: around this page (§4.3). A picture of the lists that |
| 105 | follow it: its nodes are pointer shortcuts to links that are also in |
| 106 | the lists, so they take no tab stop. Data: MapView. */}} |
| 107 | {{define "mapa-map"}}<svg mapa-map viewBox="0 0 284 200"> |
| 108 | <g role="img" aria-label="{{.Label}}"><g mapa-map-edges>{{range .Edges}}<line x1="{{.X1}}" y1="{{.Y1}}" x2="{{.X2}}" y2="{{.Y2}}" mapa-map-edge="{{.Kind}}"/>{{end}}</g></g> |
| 109 | <g mapa-map-nodes aria-hidden="true">{{range .Nodes}}<a href="{{.Href}}" tabindex="-1"><circle cx="{{.X}}" cy="{{.Y}}" r="5.5" mapa-map-node="{{.Kind}}"/><text x="{{.LabelX}}" y="{{.LabelY}}" text-anchor="{{.Anchor}}">{{.Label}}</text></a>{{end}} |
| 110 | {{with .Here}}<circle cx="{{.X}}" cy="{{.Y}}" r="8" mapa-map-node="here"/><text x="{{.LabelX}}" y="{{.LabelY}}" text-anchor="middle" mapa-map-here>{{.Label}}</text>{{end}}</g> |
| 111 | </svg> |
| 112 | <p mapa-map-key aria-hidden="true"><span mapa-k="linked">Linked</span><span mapa-k="pending">Not written</span><span mapa-k="mentioned">Mentioned</span></p>{{end}} |
| 113 | |
| 114 | {{/* mapa-week: the panel on a daily note (§4.3, §4.4), then Linked |
| 115 | from and Links out, in a team page's order. Under the strip a key |
| 116 | says what the fill, the ring and the dot mean, as the month's foot |
| 117 | does; each mark is named in words for a screen reader, beside the |
| 118 | day links' own names. Data: WeekView. */}} |
| 119 | {{define "mapa-week"}}<section aria-labelledby="mapa-week-h"><h2 id="mapa-week-h">This week</h2> |
| 120 | <div mapa-week> |
| 121 | <a mapa-icon-link href="/d/{{.Prev}}" aria-label="Previous week">{{icon "chevron-left"}}</a> |
| 122 | <ol mapa-week-days>{{range .Days}}<li><a href="/d/{{.Date}}" aria-label="{{longDate .Date}}{{if .Wrote}}, a note you wrote{{end}}{{if .Today}}, today{{end}}"{{if .Current}} aria-current="date"{{end}}{{if .Today}} mapa-today{{end}}{{if .Wrote}} mapa-wrote{{end}}><abbr aria-hidden="true">{{.Letter}}</abbr><span aria-hidden="true">{{.Number}}</span></a></li>{{end}}</ol> |
| 123 | <a mapa-icon-link href="/d/{{.Next}}" aria-label="Next week">{{icon "chevron-right"}}</a> |
| 124 | </div> |
| 125 | <p mapa-week-key><span mapa-k="shown"><span mapa-sr>Filled: </span>Day shown</span><span mapa-k="today"><span mapa-sr>, ringed: </span>Today</span><span mapa-k="wrote"><span mapa-sr>, dot: </span>A note you wrote</span></p> |
| 126 | </section>{{end}} |
| 127 | |
| 128 | {{/* mapa-side: the sidebar, one grid per row (§3.2). In the rail the |
| 129 | labels stay in the accessibility tree and show as tooltips. One shown |
| 130 | row carries aria-current (build note 80): the page's own row, or its |
| 131 | place. A place holding a page that has its own row is drawn twice |
| 132 | (mapa-side-holds): unlit while the sidebar is open, lit in the rail, |
| 133 | which hides the page rows; CSS shows one. The lit copy is [hidden] |
| 134 | too, so with no CSS at all only the page's row is lit (review low |
| 135 | 4); the rail's CSS draws it all the same. The fold is two submit |
| 136 | buttons, one per state; CSS shows the one that fits what is on |
| 137 | screen, so it works with scripts off and with no cookie. |
| 138 | Data: sideView. */}} |
| 139 | {{define "mapa-side"}}<nav mapa-side aria-label="Mapa"> |
| 140 | {{- range .Places}} |
| 141 | {{- if .Holds}} |
| 142 | <a mapa-side-item mapa-side-holds="open" href="{{.Href}}">{{template "mapa-side-place" .}}</a> |
| 143 | <a mapa-side-item mapa-side-holds="rail" href="{{.Href}}" aria-current="page" hidden>{{template "mapa-side-place" .}}</a> |
| 144 | {{- else}} |
| 145 | <a mapa-side-item href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{template "mapa-side-place" .}}</a> |
| 146 | {{- end}} |
| 147 | {{- end}} |
| 148 | {{- with .Pinned}} |
| 149 | <h2 mapa-side-head>Pinned</h2> |
| 150 | {{- range .}}{{template "mapa-side-link" .}}{{end}} |
| 151 | {{- end}} |
| 152 | {{- with .Recent}} |
| 153 | <h2 mapa-side-head>Recently edited</h2> |
| 154 | {{- range .}}{{template "mapa-side-link" .}}{{end}} |
| 155 | {{- end}} |
| 156 | <div mapa-side-foot> |
| 157 | {{- /* New team page (§4.7) opens mapa-new-page, a popover. The link |
| 158 | is for an engine without popovers (frame.css shows it there). */}} |
| 159 | <button mapa-side-item type="button" popovertarget="mapa-new-page" mapa-new-page-open>{{icon "plus"}}<span mapa-side-label>New team page</span></button> |
| 160 | <a mapa-side-item href="/new" mapa-new-page-link>{{icon "plus"}}<span mapa-side-label>New team page</span></a> |
| 161 | <form method="post" action="/view/sidebar" mapa-fold> |
| 162 | <input type="hidden" name="return" value="{{.Return}}"> |
| 163 | <button mapa-side-item type="submit" name="state" value="rail" mapa-fold-to="rail" data-mapa-command="toggle-sidebar">{{icon "panel-left"}}<span mapa-side-label>Hide sidebar</span><kbd mapa-kbd aria-hidden="true">⌘\</kbd></button> |
| 164 | <button mapa-side-item type="submit" name="state" value="open" mapa-fold-to="open" data-mapa-command="toggle-sidebar">{{icon "panel-left"}}<span mapa-side-label>Show sidebar</span></button> |
| 165 | </form> |
| 166 | </div> |
| 167 | </nav>{{end}} |
| 168 | {{define "mapa-side-place"}}{{icon .Icon}}<span mapa-side-label>{{.Label}}</span>{{if eq .Href "/search"}}<kbd mapa-kbd aria-hidden="true">⌘K</kbd>{{end}}{{end}} |
| 169 | {{define "mapa-side-link"}}<div mapa-side-row{{if .Gutter}} mapa-side-gutter data-depth="{{.Depth}}"{{end}}>{{if .Gutter}}{{template "mapa-side-arrow" .}}{{end}}<a mapa-side-item mapa-side-page href="{{.Href}}"{{if .Current}} aria-current="page"{{end}}>{{pageIcon .Look .Icon}}<span mapa-side-label>{{.Label}}{{if .Private}}<span mapa-sr>, only you see this</span>{{end}}</span>{{if .Private}}<span mapa-side-lock aria-hidden="true">{{icon "lock"}}</span>{{end}}</a>{{template "mapa-row-menu" .}}</div>{{if .Open}}<ul mapa-side-inside id="{{.ListID}}" aria-label="Pages inside {{.Label}}"> |
| 170 | {{- range .Inside}}<li>{{template "mapa-side-link" .}}</li>{{end}} |
| 171 | {{- if .More}}<li><a mapa-side-all href="{{.Href}}/inside">See all pages inside ({{number L .All}})</a></li>{{end}} |
| 172 | </ul>{{end}}{{end}} |
| 173 | |
| 174 | {{/* mapa-side-arrow: a Pinned row's disclosure (columns and icons spec |
| 175 | §5.3), a form so it works with no script: POST /view/open sets the |
| 176 | cookie and comes back. A row with nothing inside keeps the empty |
| 177 | cell, so every icon in Pinned lines up. Data: sideLink. */}} |
| 178 | {{define "mapa-side-arrow"}}{{if .Arrow}}<form method="post" action="/view/open" mapa-side-arrow-form><input type="hidden" name="id" value="{{.Public}}"><input type="hidden" name="open" value="{{if .Open}}0{{else}}1{{end}}"><input type="hidden" name="return" value="{{.Return}}"><button type="submit" mapa-side-arrow aria-expanded="{{if .Open}}true{{else}}false{{end}}"{{if .Open}} aria-controls="{{.ListID}}"{{end}} aria-label="Pages inside {{.Label}}">{{icon "chevron-right"}}</button></form>{{else}}<span mapa-side-arrow-gap aria-hidden="true"></span>{{end}}{{end}} |
| 179 | |
| 180 | {{/* mapa-row-menu: a page row's ⋯ (build note 88), the link's sibling, |
| 181 | never inside it. A <details> in estilo's group, as the bar's menus |
| 182 | are, so it opens with no script; chrome.js adds Esc and a click |
| 183 | outside, mapa.js moves focus in. Its rows are pageVerbs', less what |
| 184 | needs the page on screen. Data: sideLink. */}} |
| 185 | {{define "mapa-row-menu"}}<details mapa-row-menu name="estilo-menus"> |
| 186 | <summary mapa-row-more aria-label="More actions for {{.Label}}">{{icon "ellipsis"}}</summary> |
| 187 | <div estilo-menu>{{template "mapa-menu-items" .Menu}} |
| 188 | </div> |
| 189 | </details>{{end}} |
| 190 | |
| 191 | {{/* mapa-new-page: New team page's popover (§4.7), opened by the |
| 192 | sidebar's button. In the top layer, so the sidebar's scrolling never |
| 193 | clips it, and the platform's own Esc, click outside and focus, with |
| 194 | no script. Drawn after <main>: WebKit gives the page's autofocus to |
| 195 | the first [autofocus] in the document, even a hidden one, so this |
| 196 | field must come after a screen's own. */}} |
| 197 | {{define "mapa-new-page"}}<div popover id="mapa-new-page" mapa-new-page role="dialog" aria-label="New team page"> |
| 198 | <form method="post" action="/pages" mapa-new-page-form> |
| 199 | <label for="mapa-new-title">Title of the new team page</label> |
| 200 | <input rst-input id="mapa-new-title" name="title" required maxlength="120" autocomplete="off" autofocus aria-describedby="mapa-new-page-said"> |
| 201 | <p rst-field-error mapa-new-page-error id="mapa-new-page-error" role="alert" hidden></p> |
| 202 | <p mapa-meta id="mapa-new-page-said">Everyone in the team can open it.</p> |
| 203 | <button rst-btn="primary" type="submit">Create page</button> |
| 204 | </form> |
| 205 | </div>{{end}} |
| 206 | |
| 207 | {{/* mapa-keys: Help → Keyboard shortcuts. A <dialog> estilo's invoker |
| 208 | command opens, with no script. */}} |
| 209 | {{define "mapa-keys"}}<dialog id="mapa-keys" mapa-dialog aria-labelledby="mapa-keys-title"> |
| 210 | <form method="dialog" mapa-dialog-head><h2 id="mapa-keys-title">Keyboard shortcuts</h2><button rst-btn="ghost" type="submit" aria-label="Close">{{icon "x"}}</button></form> |
| 211 | <dl mapa-keys> |
| 212 | <dt><kbd mapa-kbd>⌘K</kbd></dt><dd>Search, or create a page</dd> |
| 213 | <dt><kbd mapa-kbd>⌘\</kbd></dt><dd>Hide or show the sidebar</dd> |
| 214 | <dt><kbd mapa-kbd>⌘S</kbd></dt><dd>Save now</dd> |
| 215 | <dt><kbd mapa-kbd>[[</kbd></dt><dd>Link to a page while you write</dd> |
| 216 | <dt><kbd mapa-kbd>⌘L</kbd></dt><dd>Link the selected words to a page, or start a [[ link</dd> |
| 217 | <dt><kbd mapa-kbd>/</kbd></dt><dd>Choose a block: heading, list, checklist, quote, code, divider, date</dd> |
| 218 | <dt><kbd mapa-kbd>⌘B</kbd> <kbd mapa-kbd>⌘I</kbd> <kbd mapa-kbd>⌘E</kbd></dt><dd>Bold, italic, code</dd> |
| 219 | <dt><kbd mapa-kbd>⇧⌘K</kbd></dt><dd>Link the selected words to a web address</dd> |
| 220 | <dt><kbd mapa-kbd>⌥F10</kbd></dt><dd>Move to the selection's toolbar, Make team page included</dd> |
| 221 | <dt><kbd mapa-kbd>Tab</kbd> <kbd mapa-kbd>⇧Tab</kbd></dt><dd>In a list, indent or outdent the item</dd> |
| 222 | <dt><kbd mapa-kbd>Esc</kbd>, then <kbd mapa-kbd>Tab</kbd></dt><dd>Leave the page's text, even inside a list</dd> |
| 223 | <dt><kbd mapa-kbd>⌥⌘→</kbd> <kbd mapa-kbd>⌥⌘←</kbd></dt><dd>Move to the next or previous column</dd> |
| 224 | <dt><kbd mapa-kbd>⌘Z</kbd> <kbd mapa-kbd>⇧⌘Z</kbd></dt><dd>Undo, redo</dd> |
| 225 | <dt><kbd mapa-kbd>Esc</kbd></dt><dd>Close a menu, a list or this dialog</dd> |
| 226 | </dl> |
| 227 | </dialog>{{end}} |
| 228 | |