Public: anyone can read this; the crew can change it.

Design: a repository's audience mark uses §5's badge, and repo-audience leaves §5d #4423

Parked opened this
Closed without merging

mason/forge:mason/3852-design-a-repository-s-audience-mark-uses → main 17 commits fork

  • Closed without merging. Nothing was applied to main.

Review

Sign in to review this change.
7 files changed +63 −30
docs/DESIGN.md +2 −2
@@ -144,7 +144,7 @@ specification.
144144 | **input / textarea / select** `field()` | `.input` | `size=sm`, `[aria-invalid]` | focus, `:user-invalid`, `[readonly]` | a line editor with an inline error row |
145145 | **form field** `field()` | `.field` (`label`, `.hint`, `.error`) | `data-invalid` | — | label line, value line, hint line |
146146 | **checkbox** | `.check` | — | native, `accent-color` themed | `[x]` / `[ ]` |
147 | **badge** `badge()` / `stateBadge()` | `.badge` | `variant=secondary\|outline\|success\|danger\|merged\|attn`; `data-state=open\|closed`, `data-pr=merged` | — | a bracketed word in the state color |
147 | **badge** `badge()` / `stateBadge()` | `.badge` | `variant=secondary\|outline\|success\|danger\|merged\|attn`; `data-state=open\|closed`, `data-pr=merged` | `href` makes the badge the link (`<a class="badge">`), hover lifts it; a sentence inside `.truncate` is one line with `title` holding all of it, and on a phone wraps whole, a 44px target when a link (the repo head's audience sentence) | a bracketed word in the state color |
148148 | **stat** `stat()` | `.stat` (`.stat-label`, `.stat-value`, `.stat-note`, `.stat-spark`; grid: `.stats`) | `data-tone=attn` | hover (`--border-strong`, only when `href` makes it a link, named by `aria` when given); fixed heights, so a changing value shifts no neighbour; value is `.num` with its full form in `title`; note clamps to two lines, its whole text in `noteTitle`; the sparkline carries its own `role=img` and `aria-label`, or is decorative; `.stats` auto-fits columns of at least 160px | a number under its label, a note under that, an optional sparkline top right |
149149 | **label chip** `labelChip()` | `.label` | color via `--label` (see §7) | — | a colored `‹name›` |
150150 | **author** `userLink()` / `userTag()` | `.byline` (`.byline-name`) | — | `userTag` inside anything already a link — see below | `@name` in the avatar hue |
@@ -395,7 +395,7 @@ gone, so this list only shrinks.
395395 A `.field` directly inside a `.bar` drops its bottom margin and the bar aligns to the end, so a labelled input and its button share a baseline
396396 - **`style/components.ts`** — parts of the §5 components that the table does not spell out — the palette's list, the menu's items, a dialog's head and foot, comments, the theme picker — and a few small helpers beside them: `.cat` `.clone` `.clone-text` `.comment` `.comment-body` `.comment-form` `.dash` `.dialog-body` `.dialog-foot` `.dialog-head` `.empty-title` `.error-note` `.field-row` `.form-actions` `.hex` `.ico` `.ico-loader` `.list` `.live-status` `.menu-item` `.menu-panel` `.menu-sep` `.menu-title` `.palette-empty` `.palette-foot` `.palette-group` `.palette-heading` `.palette-input` `.palette-item` `.palette-list` `.passkey` `.passkey-lead` `.passkey-note` `.passkey-off` `.passkey-on` `.preview` `.sep` `.split` `.sprite` `.swatch` `.table-scroll` `.tell-here` `.theme-apply` `.theme-option` `.tick` `.timeline` `.tl-dot` `.toast-body` `.topbar-search`
397397 - **`style/components.ts`, settings rows** — a list whose rows are settings (limits, capacity): the `<ul class="list setting-list">` lets title and meta wrap instead of ellipsizing, and a row's controls take their own line under 640px. `.row-fields` is the form in that row's trail (input, Save, Default): always visible, never hover-gated, wrapping under the text before it would clip. Use both for any page whose rows show a name, a current value, and a control to change it; use `.row-actions` only for secondary actions (delete, wake, pin, revoke). Flags, telemetry, cloud, people, crew roles and subscription headroom/budget use `.row-fields`. Classes: `.row-fields` `.setting-list`
398 - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.app-shelf` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.commit-body` `.commit-head` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-audience` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep`
398 - **`style/content.ts`, page furniture** — what frames a page's content: page and repo heads, the merge box, the front page and its tiles, explore, backups, boards, the fleet chart's series colours, lineage: `.app-shelf` `.backups-drill` `.backups-error` `.backups-now` `.backups-restore` `.bform` `.bgrid` `.bmanage` `.boards-result` `.bp-h2` `.bp-h3` `.bp-w2` `.bp-w3` `.break` `.bt-bar` `.bt-grid` `.bt-group` `.bt-hist` `.bt-name` `.bt-procs` `.bt-row` `.bt-val` `.commit-body` `.commit-head` `.domain-records` `.explore-filters` `.explore-line` `.explore-main` `.explore-name` `.explore-row` `.fg-s0` `.fg-s1` `.fg-s2` `.fg-s3` `.fg-s4` `.fg-s5` `.fg-s6` `.fg-s7` `.filters` `.flag-form` `.front-admin` `.front-controls` `.front-crew` `.front-featured` `.front-featured-body` `.front-featured-look` `.front-issues` `.front-live` `.front-more` `.front-pick` `.front-pin-any` `.front-weights` `.frozen` `.frozen-form` `.frozen-sentence` `.headroom` `.issue-head` `.issue-meta` `.merge-box` `.merge-form` `.merge-headline` `.merge-sub` `.mirror-form` `.number` `.origin-link` `.origin-mark` `.origin-name` `.origin-row` `.owner` `.page-head` `.path-head` `.policy-line` `.qf` `.repo-actions` `.repo-desc` `.repo-layout` `.repo-lineage` `.repo-title` `.search` `.slash` `.stage-detail` `.stage-dot` `.steps` `.sub` `.sys-pair` `.table-wrap` `.terminal-line` `.tok` `.tree-row` `.tree-total` `.wall-cells` `.where-sep`
399399 - **`style/content.ts`, code view** — the source view and the syntax-highlight token classes `highlight-html.ts` builds as `tok-${kind}`: `.blob-view` `.ln` `.tok-attribute` `.tok-comment` `.tok-constant` `.tok-decorator` `.tok-deleted` `.tok-emphasis` `.tok-function` `.tok-heading` `.tok-inserted` `.tok-keyword` `.tok-link` `.tok-meta` `.tok-number` `.tok-operator` `.tok-plain` `.tok-property` `.tok-punctuation` `.tok-regex` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable`
400400 - **`style/content.ts`, prose (markdown)** — table cell alignment, built by `markdown.ts` as `ta-${align}`: `.ta-c` `.ta-r`
401401 - **`style/content.ts`, diff viewer** — the diff table: its gutters, line kinds, file head and inline review comments: `.add` `.del` `.dh` `.diff` `.diff-body` `.diff-head` `.diff-note` `.diff-path` `.diff-stat` `.diff-stub` `.diff-summary` `.diff-table` `.dl` `.dl-review` `.dn` `.dn-comment` `.nonl` `.rc-hidden` `.rc-resolve` `.rc-resolved` `.wd`
src/web/chrome.ts +9 −8
@@ -387,17 +387,18 @@ export function lineageLine(
387387 }
388388
389389 /**
390 * Who can see this repository, in the one sentence `audienceOf` gives, beside
391 * the badge. A link to the settings for whoever can open them, plain text for
392 * everyone else. One line: CSS truncates it, `title` keeps all of it.
390 * Who can see this repository, in the one sentence `audienceOf` gives, as an
391 * outline badge beside the Private/Public one. A link to the settings for
392 * whoever can open them, plain text for everyone else. The badge truncates
393 * it on a wide screen and wraps it on a phone; `title` keeps all of it.
393394 */
394395 function audienceLine(ctx: Ctx, repo: Repo, admin: boolean, base: string): Html {
395396 const { sentence } = audienceOf(audienceFacts(ctx.app.db, repo, ctx.auth.user));
396 return admin
397 ? html`<a class="repo-audience" href="${base}/settings" title="${sentence}"
398 >${sentence}</a
399 >`
400 : html`<span class="repo-audience" title="${sentence}">${sentence}</span>`;
397 return badge(html`<span class="truncate">${sentence}</span>`, {
398 variant: "outline",
399 title: sentence,
400 ...(admin ? { href: `${base}/settings` } : {}),
401 });
401402 }
402403
403404 export { hostOf };
src/web/style/components.ts +12
@@ -207,6 +207,18 @@ a.stat:hover { border-color: var(--border-strong); }
207207 background: color-mix(in srgb, var(--attn) 12%, transparent);
208208 }
209209 .badge .ico { width: 12px; height: 12px; }
210 /* A badge that is a link (\`badge(…, { href })\`): the pill is the target. */
211 a.badge { text-decoration: none; }
212 a.badge:hover { color: var(--fg); border-color: var(--muted-fg); }
213 /* A badge holding a sentence wraps it in \`.truncate\`: one line on a wide
214 screen, \`title\` keeps all of it. A phone has no hover for the title: the
215 whole sentence, on its own line, and a link tall enough to tap. */
216 .badge:has(> .truncate) { min-width: 0; max-width: 100%; }
217 @media (max-width: 640px) {
218 .badge:has(> .truncate) { flex-basis: 100%; border-radius: var(--radius); }
219 .badge > .truncate { white-space: normal; text-overflow: clip; }
220 a.badge:has(> .truncate) { min-height: 44px; padding: 4px 10px; box-sizing: border-box; }
221 }
210222 /* A loader that turns: the one icon that means "still going". */
211223 .ico-loader { animation: spin 1.1s linear infinite; }
212224 /* A button never spins at rest: only its own busy state turns the loader. */
src/web/style/content.ts −10
@@ -25,16 +25,6 @@ export const content = /* css */ `
2525 }
2626 .repo-title .owner { font-weight: 400; color: var(--muted-fg); }
2727 .repo-title .slash { color: var(--faint); font-weight: 400; }
28 .repo-audience {
29 flex: 1 1 16ch; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
30 font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--muted-fg);
31 }
32 a.repo-audience:hover { color: var(--fg); }
33 /* A phone has no hover for the title: the whole sentence, on its own line. */
34 @media (max-width: 640px) {
35 .repo-audience { flex-basis: 100%; white-space: normal; text-overflow: clip; }
36 a.repo-audience { display: block; padding: 12px 0; min-height: 44px; box-sizing: border-box; }
37 }
3828 .repo-desc { margin-top: 4px; color: var(--muted-fg); font-size: 13px; text-wrap: pretty; }
3929 .repo-lineage { margin-top: 3px; font-size: 12.5px; color: var(--faint); }
4030 .repo-head .tabs { margin-top: 12px; }
src/web/ui.ts +19 −2
@@ -225,15 +225,32 @@ export function iconBtn(
225225
226226 // ---- badges, labels, pills, dots ----
227227
228 /** A badge. With `href` it is the link itself (`<a class="badge">`), so the
229 * pill is the target; `title` carries the whole of a long text, which the
230 * badge truncates on a wide screen and wraps on a phone. */
228231 export function badge(
229232 text: Html | string,
230 o: { tone?: Tone; icon?: IconName; variant?: "secondary" | "outline" } = {},
233 o: {
234 tone?: Tone;
235 icon?: IconName;
236 variant?: "secondary" | "outline";
237 href?: string;
238 title?: string;
239 } = {},
231240 ): Html {
232241 const variant =
233242 o.tone && o.tone !== "default" ? o.tone : (o.variant ?? undefined);
243 const title = o.title !== undefined ? html`title="${o.title}" ` : null;
244 if (o.href !== undefined)
245 return html`<a
246 class="badge"
247 href="${o.href}"
248 ${title}${variant ? html`data-variant="${variant}"` : null}
249 >${o.icon ? icon(o.icon) : null}${text}</a
250 >`;
234251 return html`<span
235252 class="badge"
236 ${variant ? html`data-variant="${variant}"` : null}
253 ${title}${variant ? html`data-variant="${variant}"` : null}
237254 >${o.icon ? icon(o.icon) : null}${text}</span
238255 >`;
239256 }
test/audience-surfaces.test.ts +5 −2
@@ -18,9 +18,12 @@ import { serve, type Servers } from "../src/http/server.ts";
1818 const esc = (s: string): string =>
1919 s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
2020
21 /** The audience element of a page: its tag, link and text. */
21 /** The audience badge of a page: its tag, link, title and text. */
2222 function audienceOn(page: string) {
23 const m = /<(a|span) class="repo-audience"(?: href="([^"]*)")? title="([^"]*)"\s*>([^<]*)<\/\1\s*>/.exec(page);
23 const m =
24 /<(a|span)\s+class="badge"(?:\s+href="([^"]*)")?\s+title="([^"]*)" data-variant="outline"\s*><span class="truncate">([^<]*)<\/span><\/\1\s*>/.exec(
25 page,
26 );
2427 if (m === null) throw new Error("no audience element on the page");
2528 return { tag: m[1], href: m[2], title: m[3], text: m[4] };
2629 }
test/repo-audience.test.ts +16 −6
@@ -1,7 +1,8 @@
11 /**
2 * The repository head says who can see the repository, beside the badge: a
3 * link to the settings for who can open them, plain text for everyone else,
4 * and the public sentence for somebody not signed in.
2 * The repository head says who can see the repository, as §5's badge beside
3 * the Private/Public one (#3852): a link to the settings for who can open
4 * them, plain text for everyone else, and the public sentence for somebody
5 * not signed in.
56 */
67 import { afterAll, beforeAll, expect, test } from "bun:test";
78 import { mkdtemp, rm } from "node:fs/promises";
@@ -59,6 +60,8 @@ beforeAll(async () => {
5960 if (!promoted.ok) throw new Error(promoted.error);
6061 const r = await createRepo(app, users[1]!, { name: "yard", visibility: "public" });
6162 if (!r.ok) throw new Error(String(r.error));
63 const shed = await createRepo(app, users[1]!, { name: "shed", visibility: "private" });
64 if (!shed.ok) throw new Error(String(shed.error));
6265 });
6366
6467 afterAll(async () => {
@@ -69,18 +72,25 @@ afterAll(async () => {
6972 test("a writer sees the sentence as a link to the settings", async () => {
7073 const h = await head("/olive/yard", await signIn("olive"));
7174 expect(h).toMatch(
72 /<a class="repo-audience" href="\/olive\/yard\/settings" title="Public: anyone can read this; 1 person can change it\."\s*>Public: anyone can read this; 1 person can change it\.<\/a\s*>/,
75 /<a\s+class="badge"\s+href="\/olive\/yard\/settings"\s+title="Public: anyone can read this; 1 person can change it\." data-variant="outline"\s*><span class="truncate">Public: anyone can read this; 1 person can change it\.<\/span><\/a\s*>/,
7376 );
7477 });
7578
7679 test("a reader sees the same sentence as plain text", async () => {
7780 const h = await head("/olive/yard", await signIn("ravi"));
78 expect(h).toContain('<span class="repo-audience" title="Public: anyone');
81 expect(h).toMatch(/<span\s+class="badge"\s+title="Public: anyone/);
7982 expect(h).not.toContain('href="/olive/yard/settings"');
8083 });
8184
8285 test("somebody not signed in sees the public sentence", async () => {
8386 const h = await head("/olive/yard");
8487 expect(h).toContain("Public: anyone can read this; 1 person can change it.");
85 expect(h).toContain('<span class="repo-audience"');
88 expect(h).toMatch(/<span\s+class="badge"\s+title="Public: anyone/);
89 });
90
91 test("a private repository's head wears §5's badge, not the old page-local mark", async () => {
92 const h = await head("/olive/shed", await signIn("olive"));
93 expect(h).not.toContain("repo-audience");
94 expect(h).toMatch(/<span\s+class="badge"\s+data-variant="secondary"\s*>[\s\S]*?Private<\/span/);
95 expect(h).toMatch(/<a\s+class="badge"\s+href="\/olive\/shed\/settings"\s+title="Private: /);
8696 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs