Public: anyone can read this; the crew can change it.
Asks on a phone: full-width rows, one-thumb actions, and the pull says what it removed #1002
scout/forge:scout/691-asks-on-a-phone-full-width-rows-one-thum → main 1 commit fork
4 files
changed +153
−55
src/web/studio/asks.ts +49 −43
| @@ -873,7 +873,10 @@ export function decisionForm(d: Decision): Html | null { | ||
| 873 | 873 | * word. Saying something to the crew happens on the change's own page, |
| 874 | 874 | * where the conversation is — not in a box in a list. |
| 875 | 875 | */ |
| 876 | export function decisionActions(ctx: Ctx, d: Decision): Html { | |
| 876 | export function decisionSplit( | |
| 877 | ctx: Ctx, | |
| 878 | d: Decision, | |
| 879 | ): { primary: Html; rest: Html | null } { | |
| 877 | 880 | const base = repoBase(d.repo); |
| 878 | 881 | const pull = d.pull; |
| 879 | 882 | const preview = |
| @@ -883,53 +886,56 @@ export function decisionActions(ctx: Ctx, d: Decision): Html { | ||
| 883 | 886 | ? undefined |
| 884 | 887 | : `${base}/app/pull-${pull.number}/open`; |
| 885 | 888 | if (d.kind === "stopped" && pull) |
| 886 | return html`${btn("Tell them", { | |
| 887 | href: `${changeHref(base, pull.number)}-body`, | |
| 888 | size: "sm", | |
| 889 | variant: "primary", | |
| 890 | })} | |
| 891 | ${btn("Close", { | |
| 892 | size: "sm", | |
| 893 | form: askFormId(d), | |
| 894 | })} | |
| 895 | ${btn("See", { | |
| 896 | href: changeHref(base, pull.number), | |
| 897 | size: "sm", | |
| 898 | })}`; | |
| 889 | return { | |
| 890 | primary: btn("Tell them", { | |
| 891 | href: `${changeHref(base, pull.number)}#comment-body`, | |
| 892 | size: "sm", | |
| 893 | variant: "primary", | |
| 894 | }), | |
| 895 | rest: html`${btn("Close", { size: "sm", form: askFormId(d) })} | |
| 896 | ${btn("See", { href: changeHref(base, pull.number), size: "sm" })}`, | |
| 897 | }; | |
| 899 | 898 | if ((d.kind === "look" || d.kind === "review") && pull) |
| 900 | return html`${btn("Ship", { | |
| 901 | size: "sm", | |
| 902 | form: askFormId(d), | |
| 903 | variant: "primary", | |
| 904 | })} | |
| 905 | ${when( | |
| 906 | preview, | |
| 907 | (href) => | |
| 908 | html`${btn("Preview", { | |
| 909 | href, | |
| 899 | return { | |
| 900 | primary: btn("Ship", { | |
| 901 | size: "sm", | |
| 902 | form: askFormId(d), | |
| 903 | variant: "primary", | |
| 904 | }), | |
| 905 | rest: html`${when(preview, (href) => html`${btn("Preview", { href, size: "sm" })}`)} | |
| 906 | ${btn("Not like this", { | |
| 907 | href: `${changeHref(base, pull.number)}-body`, | |
| 910 | 908 | size: "sm", |
| 911 | 909 | })}`, |
| 912 | )} | |
| 913 | ${btn("Not like this", { | |
| 914 | href: `${changeHref(base, pull.number)}-body`, | |
| 915 | size: "sm", | |
| 916 | })}`; | |
| 910 | }; | |
| 917 | 911 | if (d.kind === "declined" && d.issue) |
| 918 | return html`${btn("Answer", { | |
| 919 | href: `${base}/issues/${d.issue.number}-body`, | |
| 920 | size: "sm", | |
| 921 | variant: "primary", | |
| 922 | })}`; | |
| 912 | return { | |
| 913 | primary: btn("Answer", { | |
| 914 | href: `${base}/issues/${d.issue.number}#comment-body`, | |
| 915 | size: "sm", | |
| 916 | variant: "primary", | |
| 917 | }), | |
| 918 | rest: null, | |
| 919 | }; | |
| 923 | 920 | if (d.kind === "parked" && d.issue) |
| 924 | return html`${btn("Tell them", { | |
| 925 | href: `${base}/issues/${d.issue.number}-body`, | |
| 926 | size: "sm", | |
| 927 | variant: "primary", | |
| 928 | })}`; | |
| 929 | return html`${btn("Settings", { | |
| 930 | href: `${base}/settings/autonomy`, | |
| 931 | size: "sm", | |
| 932 | })}`; | |
| 921 | return { | |
| 922 | primary: btn("Tell them", { | |
| 923 | href: `${base}/issues/${d.issue.number}#comment-body`, | |
| 924 | size: "sm", | |
| 925 | variant: "primary", | |
| 926 | }), | |
| 927 | rest: null, | |
| 928 | }; | |
| 929 | return { | |
| 930 | primary: btn("Settings", { href: `${base}/settings/autonomy`, size: "sm" }), | |
| 931 | rest: null, | |
| 932 | }; | |
| 933 | } | |
| 934 | ||
| 935 | /** Every action on one line (the change page's bar): the primary, then the rest. */ | |
| 936 | export function decisionActions(ctx: Ctx, d: Decision): Html { | |
| 937 | const { primary, rest } = decisionSplit(ctx, d); | |
| 938 | return html`${primary} ${rest}`; | |
| 933 | 939 | } |
| 934 | 940 | |
| 935 | 941 | /** |
src/web/studio/asks_page.ts +47 −11
| @@ -30,8 +30,8 @@ import { | ||
| 30 | 30 | askSentence, |
| 31 | 31 | ASK_WORDS, |
| 32 | 32 | ROW_PLURAL, |
| 33 | decisionActions, | |
| 34 | 33 | decisionForm, |
| 34 | decisionSplit, | |
| 35 | 35 | decisionsFor, |
| 36 | 36 | forgeNeedsFor, |
| 37 | 37 | type AskRow, |
| @@ -80,6 +80,40 @@ const weight = (c: Consequence, which?: string): Html | null => | ||
| 80 | 80 | ? html`<b>${c.why}</b>${which === undefined ? null : html`: \u201c${which}\u201d`} · ` |
| 81 | 81 | : null; |
| 82 | 82 | |
| 83 | /** The kind, in the word the head's meta line opens with. */ | |
| 84 | const KIND_WORD: Readonly<Record<Decision["kind"], string>> = { | |
| 85 | look: "Look", | |
| 86 | review: "Review", | |
| 87 | stopped: "Stopped", | |
| 88 | parked: "Parked", | |
| 89 | declined: "Declined", | |
| 90 | paused: "Paused", | |
| 91 | }; | |
| 92 | ||
| 93 | /** The head's meta line: the kind, then the repository, on one line. */ | |
| 94 | const meta = (kind: Decision["kind"], r: { ownerName: string; name: string }): Html => | |
| 95 | html`<span class="ask-meta muted small">${KIND_WORD[kind]} · ${r.ownerName}/${r.name}</span>`; | |
| 96 | ||
| 97 | /** A row's icon: a column a phone does without (the kind is in the meta line). */ | |
| 98 | const kindIcon = (kind: Decision["kind"]): Html => | |
| 99 | html`<span class="ask-ico">${icon(kind === "look" ? "eye" : "pull")}</span>`; | |
| 100 | ||
| 101 | /** | |
| 102 | * A row's actions: the primary at the trailing edge, 44px tall on a phone; | |
| 103 | * the rest behind one "More" there, flat beside it on a wider screen. | |
| 104 | */ | |
| 105 | function acts(ctx: Ctx, d: Decision): Html { | |
| 106 | const { primary, rest } = decisionSplit(ctx, d); | |
| 107 | return html`<span class="ask-acts" | |
| 108 | ><span class="ask-primary">${primary}</span>${rest === null | |
| 109 | ? null | |
| 110 | : html`<details class="ask-rest"> | |
| 111 | <summary class="btn" data-size="sm">More</summary> | |
| 112 | ${rest} | |
| 113 | </details>`}</span | |
| 114 | >`; | |
| 115 | } | |
| 116 | ||
| 83 | 117 | /** One clause, and what happens if nobody acts — never the same sentence twice. */ |
| 84 | 118 | const clause = ( |
| 85 | 119 | d: Decision | undefined, |
| @@ -87,10 +121,12 @@ const clause = ( | ||
| 87 | 121 | c: Consequence, |
| 88 | 122 | which?: string, |
| 89 | 123 | ): Html => |
| 90 | html`<p> | |
| 91 | ${weight(c, which)}${d === undefined ? null : html`${d.short.charAt(0).toUpperCase()}${d.short.slice(1)}. `}<span class="muted" | |
| 92 | >If nobody acts, ${ASK_WORDS[kind].ifNothing}.</span | |
| 93 | > | |
| 124 | html`<p class="ask-clause${kind === "look" || kind === "review" ? " ask-lookish" : ""}"> | |
| 125 | ${weight(c, which)}${d === undefined | |
| 126 | ? null | |
| 127 | : html`<span class="${kind === "look" || kind === "review" ? "ask-short" : ""}" | |
| 128 | >${d.short.charAt(0).toUpperCase()}${d.short.slice(1)}. </span | |
| 129 | >`}<span class="muted ask-ifnot">If nobody acts, ${ASK_WORDS[kind].ifNothing}.</span> | |
| 94 | 130 | </p>`; |
| 95 | 131 | |
| 96 | 132 | function decisionCard(ctx: Ctx, d: Decision, picked: ReadonlySet<string>): Html { |
| @@ -102,12 +138,12 @@ function decisionCard(ctx: Ctx, d: Decision, picked: ReadonlySet<string>): Html | ||
| 102 | 138 | : html`<a href="${base}/settings/autonomy">Paused</a>`; |
| 103 | 139 | return card( |
| 104 | 140 | html`${clause(d, d.kind, d.consequence)} |
| 105 | <div class="bar mt">${decisionActions(ctx, d)}</div>`, | |
| 141 | <div class="mt">${acts(ctx, d)}</div>`, | |
| 106 | 142 | { |
| 107 | 143 | id: askAnchor(d.id), |
| 108 | head: html`${pick(d, picked) ?? icon(d.kind === "look" ? "eye" : "pull")} | |
| 144 | head: html`${pick(d, picked) ?? kindIcon(d.kind)} | |
| 109 | 145 | <h2>${title}</h2> |
| 110 | <span class="muted small">${d.repo.ownerName}/${d.repo.name}</span>`, | |
| 146 | ${meta(d.kind, d.repo)}`, | |
| 111 | 147 | }, |
| 112 | 148 | ); |
| 113 | 149 | } |
| @@ -132,7 +168,7 @@ function rowCard(ctx: Ctx, r: AskRow<Decision>, picked: ReadonlySet<string>): Ht | ||
| 132 | 168 | return row({ |
| 133 | 169 | ...(box === null ? {} : { lead: box }), |
| 134 | 170 | title: html`<a href="${href}">${d.pull?.title ?? d.issue?.title ?? ""}</a>`, |
| 135 | meta: html`<span class="bar">${decisionActions(ctx, d)}</span>`, | |
| 171 | meta: acts(ctx, d), | |
| 136 | 172 | }); |
| 137 | 173 | }); |
| 138 | 174 | // On a phone a group is its head line, its asks one tap away, so two |
| @@ -155,9 +191,9 @@ function rowCard(ctx: Ctx, r: AskRow<Decision>, picked: ReadonlySet<string>): Ht | ||
| 155 | 191 | data-select-all |
| 156 | 192 | aria-label="Select all ${r.items.length}" |
| 157 | 193 | />` |
| 158 | : icon(r.kind === "look" ? "eye" : "pull")} | |
| 194 | : kindIcon(r.kind)} | |
| 159 | 195 | <h2>${rowHead(r.kind, r.items.length)}</h2> |
| 160 | <span class="muted small">${r.repo.ownerName}/${r.repo.name}</span>`, | |
| 196 | ${meta(r.kind, r.repo)}`, | |
| 161 | 197 | // The row ranks by its weightiest ask (first, `askRows`): name it. |
| 162 | 198 | foot: clause( |
| 163 | 199 | undefined, |
src/web/style/content.ts +38
| @@ -1197,4 +1197,42 @@ textarea.editor:focus { outline: none; } | ||
| 1197 | 1197 | } |
| 1198 | 1198 | } |
| 1199 | 1199 | .needs-you .ask-group > summary { padding: 10px 14px; cursor: pointer; } |
| 1200 | /* Asks: the primary action at a row's trailing edge, the rest flat beside | |
| 1201 | it where a details element can be held open (elsewhere: behind "More"). */ | |
| 1202 | .needs-you .ask-acts { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; } | |
| 1203 | .needs-you .ask-rest { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; } | |
| 1204 | .needs-you .ask-rest > summary { list-style: none; cursor: pointer; } | |
| 1205 | .needs-you .ask-rest > summary::-webkit-details-marker { display: none; } | |
| 1206 | @supports selector(::details-content) { | |
| 1207 | @media (min-width: 481px) { | |
| 1208 | .needs-you .ask-rest > summary { display: none; } | |
| 1209 | .needs-you .ask-rest::details-content { content-visibility: visible; display: contents; } | |
| 1210 | } | |
| 1211 | } | |
| 1212 | /* A phone: rows use the full width (the page's 16px gutter is the only | |
| 1213 | margin), no card box, no icon column, a title that wraps, the kind and | |
| 1214 | the repository on one line, a thumb-sized action at the trailing edge. */ | |
| 1215 | @media (max-width: 600px) { | |
| 1216 | .needs-you .card { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: none; box-shadow: none; } | |
| 1217 | .needs-you .card-head { background: none; border: 0; padding: 12px 0 0; gap: 4px 8px; } | |
| 1218 | .needs-you .card-body { padding: 2px 0 12px; } | |
| 1219 | .needs-you .card-foot { background: none; border: 0; padding: 0 0 12px; } | |
| 1220 | .needs-you .card-head h2 { order: 2; flex: 1 1 100%; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; } | |
| 1221 | .needs-you .ask-meta { order: 1; flex: 1 1 0; min-width: 0; } | |
| 1222 | .needs-you .ask-pick { order: 0; } | |
| 1223 | .needs-you .ask-ico, .needs-you .ask-ifnot, .needs-you .ask-short { display: none; } | |
| 1224 | .needs-you .ask-clause { margin: 0; } | |
| 1225 | .needs-you .ask-lookish:not(:has(b)) { display: none; } | |
| 1226 | .needs-you .ask-group > summary { padding: 10px 0; min-height: 44px; display: flex; align-items: center; } | |
| 1227 | .needs-you .row { padding: 8px 0; flex-wrap: wrap; } | |
| 1228 | .needs-you .row-title { white-space: normal; overflow: visible; overflow-wrap: anywhere; } | |
| 1229 | .needs-you .row-meta { white-space: normal; overflow: visible; } | |
| 1230 | .needs-you .ask-acts { display: flex; width: 100%; justify-content: flex-end; margin-top: 6px; } | |
| 1231 | .needs-you .ask-primary { order: 2; flex: 1 1 0; display: flex; } | |
| 1232 | .needs-you .ask-primary .btn { flex: 1; min-height: 44px; } | |
| 1233 | .needs-you .ask-rest { order: 1; } | |
| 1234 | .needs-you .ask-rest > summary { min-height: 44px; display: inline-flex; align-items: center; } | |
| 1235 | .needs-you .ask-rest .btn { min-height: 44px; } | |
| 1236 | .needs-you .ask-rest:not([open]) > :not(summary) { display: none; } | |
| 1237 | } | |
| 1200 | 1238 | `; |
test/asks-rank.test.ts +19 −1
| @@ -248,7 +248,7 @@ describe("asks that earn their place", () => { | ||
| 248 | 248 | expect(asks).toContain("<summary>1 more</summary>"); |
| 249 | 249 | // The phone's "more" opens in place to every ask: the wide screen's |
| 250 | 250 | // "more" sits inside it, and the stylesheet hides each where it is not. |
| 251 | expect(wide!.indexOf('id="asks-more"')).toBeLessThan(wide!.indexOf("</details>")); | |
| 251 | expect(wide!.indexOf('id="asks-more"')).toBeLessThan(wide!.lastIndexOf("</details>")); | |
| 252 | 252 | const css = await (await fetch(`${servers.url}${home.match(/href="(\/[^"]*\.css[^"]*)"/)![1]}`)).text(); |
| 253 | 253 | // Only where the browser can hold a details element open: an older one |
| 254 | 254 | // keeps both summaries, so no ask is out of reach. |
| @@ -355,4 +355,22 @@ describe("asks that earn their place", () => { | ||
| 355 | 355 | ".needs-you .ask-group > summary { display: none; }", |
| 356 | 356 | ); |
| 357 | 357 | }); |
| 358 | test("a phone's ask is a full-width row: kind with repo, primary at the trailing edge, the rest behind More (#691)", async () => { | |
| 359 | const home = await page("/"); | |
| 360 | const asks = home.slice(home.indexOf('<section id="needs-you"')); | |
| 361 | // The kind and the repository share one line. | |
| 362 | expect(asks).toMatch(/<span class="ask-meta muted small">(Look|Review|Stopped|Parked|Paused|Declined) · [^<]+\/[^<]+<\/span>/); | |
| 363 | // The primary action stands alone; the others sit in one "More". | |
| 364 | expect(asks).toContain('<span class="ask-primary">'); | |
| 365 | expect(asks).toContain('<details class="ask-rest">'); | |
| 366 | expect(asks).toContain("<summary class=\"btn\" data-size=\"sm\">More</summary>"); | |
| 367 | // The repeated sentence is tagged so a phone can drop them. | |
| 368 | expect(asks).toContain("ask-ifnot"); | |
| 369 | const css = await (await fetch(`${servers.url}${home.match(/href="(\/[^"]*\.css[^"]*)"/)![1]}`)).text(); | |
| 370 | const phone = css.slice(css.indexOf("A phone: rows use the full width")); | |
| 371 | expect(phone).toContain(".needs-you .card { border: 0;"); | |
| 372 | expect(phone).toContain(".needs-you .ask-primary .btn { flex: 1; min-height: 44px; }"); | |
| 373 | expect(phone).toContain(".needs-you .ask-ico, .needs-you .ask-ifnot, .needs-you .ask-short { display: none; }"); | |
| 374 | expect(phone).toContain(".needs-you .row-title { white-space: normal;"); | |
| 375 | }); | |
| 358 | 376 | }); |
new above
offline