components.templ RawHistoryFolder
1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3package web
4
5// Facts is a key/value block on an 11ch key column.
6templ Facts(facts []Fact) {
7 <dl class="kv">
8 for _, f := range facts {
9 <dt>{ f.Key }</dt>
10 @FactValue(f)
11 }
12 </dl>
13}
14
15// CloneBlock is a block of copyable shell lines; each has its own [copy]
16// button, whose label says "copied" for 1.5 s.
17templ CloneBlock(c Clone) {
18 <div class="clone" id={ c.ID }>
19 for _, line := range c.Lines {
20 <div class="clone-line">
21 <span class="mute" aria-hidden="true">$ </span><code>{ line }</code>
22 <button
23 type="button"
24 class="btn copy"
25 data-js
26 data-label="Copy"
27 aria-label={ "copy: " + line }
28 hx-on:click="ermite.copy(this)"
29 >Copy</button>
30 </div>
31 }
32 </div>
33}
34
35// HomeRow is one row of the home list. Its id is the target of SSE swaps.
36templ HomeRowView(r HomeRow) {
37 <tr id={ r.ID } data-cursor?={ r.Cursor }>
38 <td class="cur" aria-hidden="true"></td>
39 <td class="c-name">
40 <a href={ templ.SafeURL(r.Href) }>{ r.Name }</a>
41 if r.Fresh {
42 <span class="pill new">new push</span>
43 }
44 </td>
45 <td class="c-desc dim">{ r.Desc }</td>
46 <td class="c-when nowrap">
47 <time
48 if r.PushedAt != "" {
49 datetime={ r.PushedAt }
50 }
51 >{ r.Pushed }</time>
52 </td>
53 <td class="c-ref">{ r.Branch }</td>
54 </tr>
55}
56
57// Outline is the README outline; levels indent by 2ch, the h1 is bold.
58templ Outline(headings []Heading) {
59 <nav class="outline" aria-label="Outline">
60 for _, h := range headings {
61 <a class={ "l" + itoa(h.Level) } href={ templ.SafeURL("#" + h.ID) }>{ h.Text }</a>
62 }
63 </nav>
64}
65
66// ReadmeCard is a README in a card whose header names the file.
67templ ReadmeCard(r Readme) {
68 <section class="card readme" aria-labelledby="readme-h">
69 <h2 class="card-h" id="readme-h">
70 <span class="ico i-file" aria-hidden="true"></span>
71 { r.Name }
72 </h2>
73 @ReadmeView(r)
74 </section>
75}
76
77// ReadmeView is a rendered README. Its HTML comes from the Markdown
78// renderer, which drops raw HTML and filters URLs.
79templ ReadmeView(r Readme) {
80 <article class="prose" aria-label={ r.Name } hx-ignore>
81 if r.Note != "" {
82 <p class="dim">{ r.Note }</p>
83 } else {
84 @templ.Raw(r.HTML)
85 }
86 </article>
87}
88
89// CommitRows is a cursor table of commits: sha, subject with inline refs,
90// author, relative date (absolute in the title).
91templ CommitRows(rows []CommitRow) {
92 <table class="list commits" aria-label="Commits">
93 <tbody data-rows>
94 for _, c := range rows {
95 <tr
96 if c.ID != "" {
97 id={ c.ID }
98 }
99 data-cursor?={ c.Cursor }
100 >
101 <td class="cur" aria-hidden="true"></td>
102 <td class="c-sha mute">{ c.Short }</td>
103 <td class="c-subject">
104 <a href={ templ.SafeURL(c.CHref) }>{ c.Subject }</a>
105 if c.Merge {
106 <span class="pill">merge</span>
107 }
108 for _, b := range c.Branches {
109 <span class="pill">{ b }</span>
110 }
111 for _, t := range c.Tags {
112 <span class="pill tag"><span class="sr">tag </span>{ t }</span>
113 }
114 </td>
115 <td class="c-ck">@CommitChecks(c.Checks)</td>
116 <td class="c-who dim">{ c.Author }</td>
117 <td class="c-when nowrap dim"><time datetime={ c.WhenAt } title={ c.WhenAt }>{ c.When }</time></td>
118 </tr>
119 }
120 </tbody>
121 </table>
122}