v0.20.0 032b9ef

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>e</kbd> <kbd>E</kbd></dt><dd>diff: the whole file in view / every file, with the lines the hunks hide</dd></div>
26			<div><dt><kbd>n</kbd></dt><dd>merge request: next note in the diff</dd></div>
27			if mr {
28				<div><dt><kbd>g f</kbd></dt><dd>merge request: the list of files (j k move, enter opens, esc back)</dd></div>
29				<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>
30				<div><dt><kbd>R</kbd></dt><dd>merge request: mark the head read</dd></div>
31			}
32			<div><dt><kbd>esc</kbd></dt><dd>close a dialog, leave a field</dd></div>
33		</dl>
34	</dialog>
35}
36
37// OverlayRefs is the ref switcher. It exists only inside a repository.
38templ OverlayRefs(l Layout) {
39	if l.Ref != "" {
40		<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()">
41			<div class="panel-head">
42				<label for="refs-filter" class="sr">filter branches and tags</label>
43				<input
44					id="refs-filter"
45					type="search"
46					placeholder="Switch branch or tag…"
47					autocomplete="off"
48					data-pick="#panel-refs li"
49					hx-on:input="ermite.filter(this)"
50				/>
51				<button type="button" class="panel-x" aria-label="Close" hx-on:click="closest('dialog').close()"><kbd>esc</kbd></button>
52			</div>
53			<div class="panel-cols" data-picklist>
54				<section aria-label="Branches">
55					<h2>Branches <span class="count">{ itoa(len(l.Heads)) }</span></h2>
56					<ul>
57						for _, r := range l.Heads {
58							@refItem(r)
59						}
60					</ul>
61				</section>
62				<section aria-label="Tags">
63					<h2>Tags <span class="count">{ itoa(len(l.Tags)) }</span></h2>
64					<ul>
65						for _, r := range l.Tags {
66							@refItem(r)
67						}
68					</ul>
69				</section>
70			</div>
71		</dialog>
72	}
73}
74
75templ refItem(r RefItem) {
76	<li>
77		<a
78			href={ templ.SafeURL(r.Href) }
79			if r.Current {
80				aria-current="true"
81			}
82		>
83			<span class="mark" aria-hidden="true">
84				if r.Current {
85					●
86				} else {
87					&nbsp;
88				}
89			</span>{ r.Name }
90		</a>
91	</li>
92}
93
94// OverlayCmd is the ":" command line: one filterable list mixing sections,
95// refs and repos.
96templ OverlayCmd(items []CmdItem) {
97	<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()">
98		<div class="panel-head">
99			<label for="cmd-q" class="sr">go to</label>
100			<input
101				id="cmd-q"
102				type="search"
103				placeholder="Go to a section, branch, tag, file or repository…"
104				autocomplete="off"
105				spellcheck="false"
106				aria-controls="cmd-list"
107				hx-on:input="ermite.cmdFilter(this); ermiteFinder.palette(this)"
108				hx-on:keydown="ermite.cmdKey(event)"
109			/>
110			<button type="button" class="panel-x" aria-label="Close" hx-on:click="closest('dialog').close()"><kbd>esc</kbd></button>
111		</div>
112		<ul id="cmd-list" class="cmd-list" aria-label="Targets">
113			for i, c := range items {
114				<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>
115			}
116		</ul>
117		<p class="panel-foot"><span><kbd>↑</kbd><kbd>↓</kbd> move</span><span><kbd>enter</kbd> open</span><span><kbd>esc</kbd> close</span></p>
118	</dialog>
119}

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