v0.19.0 55a688e

overlays.templ RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5import "strings"
6
7// OverlayHelp is the keyboard map panel; the keys of the merge request page
8// show on that page only.
9templ OverlayHelp(mr bool) {
10	<dialog id="panel-help" class="panel modal" aria-label="Keyboard shortcuts" hx-on:keydown="event.key === 'Escape' && (event.preventDefault(), this.close())" hx-on:click="event.target === this && this.close()">
11		<div class="panel-head"><h2>Keyboard shortcuts</h2><button type="button" class="panel-x" aria-label="Close" hx-on:click="closest('dialog').close()"><kbd>esc</kbd> close</button></div>
12		<dl class="keys">
13			<div><dt><kbd>ctrl k</kbd> <kbd>:</kbd></dt><dd>go to a section, branch, tag, file or repository</dd></div>
14			<div><dt><kbd>?</kbd></dt><dd>this list</dd></div>
15			<div><dt><kbd>j</kbd> <kbd>k</kbd></dt><dd>move the row cursor down / up</dd></div>
16			<div><dt><kbd>enter</kbd></dt><dd>open the row under the cursor</dd></div>
17			<div><dt><kbd>l</kbd> <kbd>h</kbd></dt><dd>into the side panel (on a merge request, its files) / back to the content; there j k move between its controls</dd></div>
18			<div><dt><kbd>g g</kbd> <kbd>G</kbd></dt><dd>first / last row</dd></div>
19			<div><dt><kbd>/</kbd></dt><dd>filter the list; on Files, find a file in the repository</dd></div>
20			<div><dt><kbd>b</kbd></dt><dd>{ "switch" } branch or tag</dd></div>
21			<div><dt><kbd>s</kbd> <kbd>t</kbd> <kbd>c</kbd> <kbd>r</kbd> <kbd>m</kbd></dt><dd>tabs: summary, files, commits, branches &amp; tags, merge requests</dd></div>
22			<div><dt><kbd>g h</kbd></dt><dd>home</dd></div>
23			<div><dt><kbd>y</kbd></dt><dd>copy a permalink pinned to the commit</dd></div>
24			<div><dt><kbd>d</kbd> <kbd>u</kbd> <kbd>x</kbd></dt><dd>diff: split / unified / collapse or expand all</dd></div>
25			<div><dt><kbd>n</kbd></dt><dd>merge request: next note in the diff</dd></div>
26			if mr {
27				<div><dt><kbd>g f</kbd></dt><dd>merge request: the list of files (j k move, enter opens, esc back)</dd></div>
28				<div><dt><kbd>M</kbd></dt><dd>merge request: the merge menu; there 1–3 pick the mode, D deletes the branch, enter merges</dd></div>
29				<div><dt><kbd>R</kbd></dt><dd>merge request: mark the head read</dd></div>
30			}
31			<div><dt><kbd>esc</kbd></dt><dd>close a dialog, leave a field</dd></div>
32		</dl>
33	</dialog>
34}
35
36// OverlayRefs is the ref switcher. It exists only inside a repository.
37templ OverlayRefs(l Layout) {
38	if l.Ref != "" {
39		<dialog id="panel-refs" class="panel modal" aria-label="Switch ref" hx-on:keydown="event.key === 'Escape' && (event.preventDefault(), this.close())" hx-on:click="event.target === this && this.close()">
40			<div class="panel-head">
41				<label for="refs-filter" class="sr">filter branches and tags</label>
42				<input
43					id="refs-filter"
44					type="search"
45					placeholder="Switch branch or tag…"
46					autocomplete="off"
47					data-pick="#panel-refs li"
48					hx-on:input="ermite.filter(this)"
49				/>
50				<button type="button" class="panel-x" aria-label="Close" hx-on:click="closest('dialog').close()"><kbd>esc</kbd></button>
51			</div>
52			<div class="panel-cols" data-picklist>
53				<section aria-label="Branches">
54					<h2>Branches <span class="count">{ itoa(len(l.Heads)) }</span></h2>
55					<ul>
56						for _, r := range l.Heads {
57							@refItem(r)
58						}
59					</ul>
60				</section>
61				<section aria-label="Tags">
62					<h2>Tags <span class="count">{ itoa(len(l.Tags)) }</span></h2>
63					<ul>
64						for _, r := range l.Tags {
65							@refItem(r)
66						}
67					</ul>
68				</section>
69			</div>
70		</dialog>
71	}
72}
73
74templ refItem(r RefItem) {
75	<li>
76		<a
77			href={ templ.SafeURL(r.Href) }
78			if r.Current {
79				aria-current="true"
80			}
81		>
82			<span class="mark" aria-hidden="true">
83				if r.Current {
84					●
85				} else {
86					&nbsp;
87				}
88			</span>{ r.Name }
89		</a>
90	</li>
91}
92
93// OverlayCmd is the ":" command line: one filterable list mixing sections,
94// refs and repos.
95templ OverlayCmd(items []CmdItem) {
96	<dialog id="panel-cmd" class="panel modal" aria-label="Go to" hx-on:close="ermiteFinder.paletteClose()" hx-on:keydown="event.key === 'Escape' && (event.preventDefault(), this.close())" hx-on:click="event.target === this && this.close()">
97		<div class="panel-head">
98			<label for="cmd-q" class="sr">go to</label>
99			<input
100				id="cmd-q"
101				type="search"
102				placeholder="Go to a section, branch, tag, file or repository…"
103				autocomplete="off"
104				spellcheck="false"
105				aria-controls="cmd-list"
106				hx-on:input="ermite.cmdFilter(this); ermiteFinder.palette(this)"
107				hx-on:keydown="ermite.cmdKey(event)"
108			/>
109			<button type="button" class="panel-x" aria-label="Close" hx-on:click="closest('dialog').close()"><kbd>esc</kbd></button>
110		</div>
111		<ul id="cmd-list" class="cmd-list" aria-label="Targets">
112			for i, c := range items {
113				<li data-k={ strings.ToLower(c.Kind + " " + c.Label) } data-cursor?={ i == 0 }><a href={ templ.SafeURL(c.Href) } tabindex="-1"><span class="lbl">{ c.Label }</span><span class="k">{ c.Kind }</span></a></li>
114			}
115		</ul>
116		<p class="panel-foot"><span><kbd>↑</kbd><kbd>↓</kbd> move</span><span><kbd>enter</kbd> open</span><span><kbd>esc</kbd> close</span></p>
117	</dialog>
118}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 45

↑↓ moveenter openesc close