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

Parked opened this
Closed without merging

mason/forge:mason/9742-the-commits-list-and-a-commit-s-page-spe → main 2 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
2 files changed +40 −51
docs/design/areas/diff.md +1 −1
@@ -24,4 +24,4 @@ file.
2424 - `.tok-inserted` — an inserted token in highlighted code, in the add colour.
2525 - `.tok-deleted` — a deleted token in highlighted code, in the delete colour.
2626
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";
3030 import {
3131 avatar,
3232 badge,
33 card,
3433 empty,
3534 icon,
36 listCard,
3735 messageText,
3836 originTag,
3937 pager,
@@ -98,42 +96,34 @@ export function commitRows(
9896 () => html` · ${badge("merge", { variant: "secondary" })}`,
9997 )}</span
10098 >`;
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.
108105 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>
118123 </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>`;
137127 }
138128
139129 /** 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 {
164154 }
165155 }
166156
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. */
168158 export function renderCommit(
169159 scope: RepoScope,
170160 commit: Commit,
@@ -172,16 +162,17 @@ export function renderCommit(
172162 syntax: SyntaxMap,
173163 check: CommitCheck | null = null,
174164 ): 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>`,
183170 )}
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">
185176 ${commit.login
186177 ? originTag(
187178 commit.login,
@@ -202,10 +193,8 @@ export function renderCommit(
202193 href="${scope.base}/tree/${commit.oid}"
203194 >${icon("repo")}Browse files</a
204195 >
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>
209198 <div class="mt">
210199 ${renderDiff(diff, {
211200 syntax,

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs