Public: anyone can read this; the crew can change it.
The commits list and a commit's page speak the home page's language #9748
mason/forge:mason/9742-the-commits-list-and-a-commit-s-page-spe → main 2 commits fork
2 files
changed +40
−51
docs/design/areas/diff.md +1 −1
| @@ -24,4 +24,4 @@ file. | ||
| 24 | 24 | - `.tok-inserted` — an inserted token in highlighted code, in the add colour. |
| 25 | 25 | - `.tok-deleted` — a deleted token in highlighted code, in the delete colour. |
| 26 | 26 | |
| 27 | The commits list and a commit's page (#9348) add no class: inside `[data-commits]` (an attribute, `COMMITS_CSS` in `src/web/pages/commits.ts`) a row's subject and author wrap, a long word breaks anywhere, and the diff scrolls inside its own `.diff-body`. | |
| 27 | The commits list and a commit's page (#9348, #9742) add no class, and draw no card: rows and a heading with a muted line. Inside `[data-commits]` (an attribute, `COMMITS_CSS` in `src/web/pages/commits.ts`) a row's subject and author wrap, a long word breaks anywhere, and the diff scrolls inside its own `.diff-body`. |
src/web/pages/commits.ts +39 −50
| @@ -30,10 +30,8 @@ import { localScope, type RepoScope } from "../scope.ts"; | ||
| 30 | 30 | import { |
| 31 | 31 | avatar, |
| 32 | 32 | badge, |
| 33 | card, | |
| 34 | 33 | empty, |
| 35 | 34 | icon, |
| 36 | listCard, | |
| 37 | 35 | messageText, |
| 38 | 36 | originTag, |
| 39 | 37 | pager, |
| @@ -98,42 +96,34 @@ export function commitRows( | ||
| 98 | 96 | () => html` · ${badge("merge", { variant: "secondary" })}`, |
| 99 | 97 | )}</span |
| 100 | 98 | >`; |
| 101 | return html`<div data-commits>${listCard( | |
| 102 | commits.map((commit) => { | |
| 103 | const verdict = verdicts.get(commit.oid); | |
| 104 | const step = verdict?.summary.split("\n")[0]?.trim() ?? ""; | |
| 105 | // A link cannot sit inside a link: a row with a verdict is a row whose | |
| 106 | // title links to the commit and whose badge links to the check. | |
| 107 | if (verdict === undefined || verdict.runId === null) | |
| 99 | return html`<div data-commits> | |
| 100 | <ul class="list setting-list"> | |
| 101 | ${commits.map((commit) => { | |
| 102 | const verdict = verdicts.get(commit.oid); | |
| 103 | const step = verdict?.summary.split("\n")[0]?.trim() ?? ""; | |
| 104 | // The message is the row's one link; a check's badge links to its run. | |
| 108 | 105 | return html`<li> |
| 109 | <a | |
| 110 | class="row" | |
| 111 | data-nav | |
| 112 | tabindex="-1" | |
| 113 | href="${scope.base}/commit/${commit.oid}" | |
| 114 | > | |
| 115 | ${lead(commit)}<span class="row-main">${text(commit)}</span> | |
| 116 | <span class="row-trail">${sha(commit.oid)}</span> | |
| 117 | </a> | |
| 106 | <div class="row"> | |
| 107 | ${lead(commit)} | |
| 108 | <a class="row-main" href="${scope.base}/commit/${commit.oid}" | |
| 109 | >${text(commit)}</a | |
| 110 | > | |
| 111 | <span class="row-trail" | |
| 112 | >${when( | |
| 113 | verdict !== undefined && verdict.runId !== null, | |
| 114 | () => html`<a | |
| 115 | href="${scope.base}/runs/${verdict?.runId}" | |
| 116 | title="${step}" | |
| 117 | aria-label="Check ${verdict?.state === "ok" ? "passed" : "failed"} for ${commit.oid.slice(0, 7)}${step === "" ? "" : `: ${step}`}" | |
| 118 | >${runStateBadge(verdict?.state === "ok" ? "ok" : "failed", "check")}</a | |
| 119 | >`, | |
| 120 | )}${sha(commit.oid)}</span | |
| 121 | > | |
| 122 | </div> | |
| 118 | 123 | </li>`; |
| 119 | return html`<li> | |
| 120 | <div class="row" data-nav tabindex="-1"> | |
| 121 | ${lead(commit)} | |
| 122 | <a class="row-main" href="${scope.base}/commit/${commit.oid}" | |
| 123 | >${text(commit)}</a | |
| 124 | > | |
| 125 | <span class="row-trail" | |
| 126 | ><a | |
| 127 | href="${scope.base}/runs/${verdict.runId}" | |
| 128 | title="${step}" | |
| 129 | aria-label="Check ${verdict.state === "ok" ? "passed" : "failed"} for ${commit.oid.slice(0, 7)}${step === "" ? "" : `: ${step}`}" | |
| 130 | >${runStateBadge(verdict.state === "ok" ? "ok" : "failed", "check")}</a | |
| 131 | >${sha(commit.oid)}</span | |
| 132 | > | |
| 133 | </div> | |
| 134 | </li>`; | |
| 135 | }), | |
| 136 | )}</div>`; | |
| 124 | })} | |
| 125 | </ul> | |
| 126 | </div>`; | |
| 137 | 127 | } |
| 138 | 128 | |
| 139 | 129 | /** A commit's check in a sentence; on red, the first failing step as the check named it. */ |
| @@ -164,7 +154,7 @@ export function checkSentence(scope: RepoScope, check: CommitCheck): Html { | ||
| 164 | 154 | } |
| 165 | 155 | } |
| 166 | 156 | |
| 167 | /** One commit's header card and its diff. */ | |
| 157 | /** One commit: its message as the heading, who and when as a muted line, then its diff. */ | |
| 168 | 158 | export function renderCommit( |
| 169 | 159 | scope: RepoScope, |
| 170 | 160 | commit: Commit, |
| @@ -172,16 +162,17 @@ export function renderCommit( | ||
| 172 | 162 | syntax: SyntaxMap, |
| 173 | 163 | check: CommitCheck | null = null, |
| 174 | 164 | ): Html { |
| 175 | const verdict: Html = | |
| 176 | check !== null && check.state !== "none" | |
| 177 | ? html`<div class="card-body small">${checkSentence(scope, check)}</div>` | |
| 178 | : html``; | |
| 179 | const head: Html = card( | |
| 180 | html`${verdict}${when( | |
| 181 | commit.body.trim() !== "", | |
| 182 | () => html`<div class="card-body">${messageText(commit.body)}</div>`, | |
| 165 | return html`<div data-commits><section class="mt"> | |
| 166 | <h2>${commit.subject}</h2> | |
| 167 | ${when( | |
| 168 | check !== null && check.state !== "none", | |
| 169 | () => html`<p class="small">${check ? checkSentence(scope, check) : null}</p>`, | |
| 183 | 170 | )} |
| 184 | <div class="card-body bar small muted"> | |
| 171 | ${when( | |
| 172 | commit.body.trim() !== "", | |
| 173 | () => html`<div>${messageText(commit.body)}</div>`, | |
| 174 | )} | |
| 175 | <div class="bar small muted"> | |
| 185 | 176 | ${commit.login |
| 186 | 177 | ? originTag( |
| 187 | 178 | commit.login, |
| @@ -202,10 +193,8 @@ export function renderCommit( | ||
| 202 | 193 | href="${scope.base}/tree/${commit.oid}" |
| 203 | 194 | >${icon("repo")}Browse files</a |
| 204 | 195 | > |
| 205 | </div>`, | |
| 206 | { head: html`<h2>${commit.subject}</h2>`, pad: false }, | |
| 207 | ); | |
| 208 | return html`<div data-commits><div class="mt">${head}</div></div> | |
| 196 | </div> | |
| 197 | </section></div> | |
| 209 | 198 | <div class="mt"> |
| 210 | 199 | ${renderDiff(diff, { |
| 211 | 200 | syntax, |
new above
offline