Skip to content

Commit e1a96f6

Browse files
committed
feat(web): widen the About text so the sponsor line stays on one line
Package names no longer wrap, and a credits table that does not fit a narrow window scrolls in its own box.
1 parent 9796df7 commit e1a96f6

9 files changed

Lines changed: 85 additions & 23 deletions

File tree

‎cli/src/coding_study/entrypoints/web/static/app.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cli/src/coding_study/entrypoints/web/static/chunks/about-3KPC3UIU.js‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎cli/src/coding_study/entrypoints/web/static/chunks/about-GCBJPIU7.css‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cli/src/coding_study/entrypoints/web/static/chunks/about-RLVNWVVS.js‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cli/src/coding_study/entrypoints/web/static/chunks/about-SWJJR6KJ.css‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎cli/src/coding_study/entrypoints/web/static/manifest.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"files": {
44
"THIRD_PARTY_LICENSES.txt": "16e05881b179ed03f4f9a37e41349e8fedc144c6568aa12e4fccc9190e0907b9",
55
"app.css": "3540242ce140a50f17d54c335082320161d5ca0dd1c65d9cee81f3e24f5eedab",
6-
"app.js": "fbd38890b10b66d78ca66c710e195980bd0e4290868cfe86fbef91ded4054b2f",
7-
"chunks/about-3KPC3UIU.js": "e7e859616073a529b484138549af0dd2693ebd0371caea311bec588313fbb4fa",
8-
"chunks/about-SWJJR6KJ.css": "75b67c44aa4740dc65323a36dc37500604a682587a85dfe3ed79d7a151eeb1af",
6+
"app.js": "87d95b7700f33c49d48a4a4f9b666c7bb54e6a15ee252d02ba8fbd7de88a11d4",
7+
"chunks/about-GCBJPIU7.css": "730fcd0f6835995f6c2d2bf50c07177892346ec5f07fd20fee803c11a592dc22",
8+
"chunks/about-RLVNWVVS.js": "415f949218d7c3076c21cbbcf42f0f88bdd7cc414e1d5636fdd9eda18c1e6aeb",
99
"chunks/chunk-4H53P3R3.js": "d5d049301c51a4280b42d38736639040dd25fd389d568351462365783c72cd0d",
1010
"chunks/chunk-4SAJJHEE.js": "509f2753ec699cbfa697968ea8f5af71079761505c931ed6b2ecc16e89fe0e80",
1111
"chunks/chunk-5JJK2J4Y.js": "065fc4b1b2e58dde2295dea0f15e2f3fa63a65d28a488886b766ead757ac8c4f",

‎cli/tests/entrypoints/web/test_browser_about.py‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
sync_api = pytest.importorskip("playwright.sync_api", reason="Playwright is not installed")
2828

2929
WAIT_MS = 60_000
30+
WIDE = {"width": 1440, "height": 900}
31+
NARROW = {"width": 390, "height": 844}
3032
READY = "table.problems tbody tr"
3133
VERSION_LINK = ".statusbar a.segment.version"
3234
TOP_BAR_LINKS = "header.topbar nav a"
@@ -72,6 +74,8 @@ class Seen:
7274
license_requests_before_open: int = -1
7375
license_requests_after_open: int = -1
7476
license_text: str = ""
77+
wide: dict[str, Any] = field(default_factory=dict[str, Any])
78+
narrow: dict[str, Any] = field(default_factory=dict[str, Any])
7579
uppercase: list[str] = field(default_factory=list[str])
7680
all_caps: list[str] = field(default_factory=list[str])
7781
brand_hash: str = ""
@@ -108,6 +112,7 @@ def seen(engine: str, server: RunningServer) -> Seen:
108112
page.wait_for_selector(FACTS)
109113
_read_the_view(page, found, server)
110114
found.requests_before_open = list(requests)
115+
_read_the_widths(page, found)
111116
_read_the_licenses(page, found, requests)
112117
found.requests_to_other_sites = [
113118
url for url in requests if not url.startswith(server.address)
@@ -174,6 +179,38 @@ def _licenses_requested(requests: list[str]) -> int:
174179
return sum(url.endswith(LICENSES_PATH) for url in requests)
175180

176181

182+
WIDTHS_PROBE = """() => {
183+
const lines = (element) => {
184+
const style = getComputedStyle(element);
185+
return Math.round(element.getBoundingClientRect().height / parseFloat(style.lineHeight));
186+
};
187+
const wraps = (element) => {
188+
const range = document.createRange();
189+
range.selectNodeContents(element);
190+
return new Set([...range.getClientRects()].map((box) => Math.round(box.top))).size > 1;
191+
};
192+
const names = [...document.querySelectorAll(".credit-name")];
193+
return {
194+
author: lines(document.querySelector(".about-author")),
195+
sponsor: lines(document.querySelector(".about-sponsor")),
196+
intro: lines(document.querySelector(".about-credits > p")),
197+
wrapped_names: names.filter(wraps).map((name) => name.textContent),
198+
page_overflows: document.documentElement.scrollWidth > window.innerWidth,
199+
table_overflows: [...document.querySelectorAll(".credits-scroll")].some(
200+
(box) => box.getBoundingClientRect().right > window.innerWidth
201+
),
202+
};
203+
}"""
204+
205+
206+
def _read_the_widths(page: Any, found: Seen) -> None:
207+
page.set_viewport_size(WIDE)
208+
found.wide = page.evaluate(WIDTHS_PROBE)
209+
page.set_viewport_size(NARROW)
210+
found.narrow = page.evaluate(WIDTHS_PROBE)
211+
page.set_viewport_size(WIDE)
212+
213+
177214
def _read_the_licenses(page: Any, found: Seen, requests: list[str]) -> None:
178215
found.license_requests_before_open = _licenses_requested(requests)
179216
page.click(LICENSES_SUMMARY)
@@ -311,6 +348,30 @@ def test_the_author_link_has_the_static_utm_tags_and_opens_safely(seen):
311348
}
312349

313350

351+
def test_the_sponsor_sentence_and_the_credits_introduction_stay_on_one_line_on_a_wide_window(seen):
352+
assert (seen.wide["author"], seen.wide["sponsor"], seen.wide["intro"]) == (1, 1, 1)
353+
354+
355+
def test_no_package_name_wraps_on_a_wide_window(seen):
356+
assert seen.wide["wrapped_names"] == []
357+
358+
359+
def test_no_package_name_wraps_on_a_narrow_window(seen):
360+
assert seen.narrow["wrapped_names"] == []
361+
362+
363+
def test_the_page_never_scrolls_sideways_on_a_narrow_window(seen):
364+
assert seen.narrow["page_overflows"] is False
365+
366+
367+
def test_a_credits_table_stays_inside_a_narrow_window(seen):
368+
assert seen.narrow["table_overflows"] is False
369+
370+
371+
def test_the_text_wraps_on_a_narrow_window(seen):
372+
assert seen.narrow["sponsor"] > 1
373+
374+
314375
def test_nothing_is_requested_from_another_site(seen):
315376
assert seen.requests_to_other_sites == []
316377

‎tools/web-ui/src/page/views/about.css‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* The About view (about.ts): the facts as name and value lines, the credits, the full texts and a
2-
quiet line at the foot. A line of text stays readable. */
2+
quiet line below the author. A line of text stays readable, but wide enough that the sponsor
3+
sentence and the credits' introduction stay on one line on an ordinary window. */
34

45
.about-body {
5-
max-width: 880px;
6+
max-width: 1040px;
67
}
78

89
.about h2 {
@@ -17,7 +18,7 @@
1718
}
1819

1920
.about p {
20-
max-width: 72ch;
21+
max-width: 120ch;
2122
}
2223

2324
.about-facts {
@@ -37,19 +38,15 @@
3738
overflow-wrap: anywhere;
3839
}
3940

40-
.credits {
41-
max-width: 640px;
42-
table-layout: fixed;
41+
/* Focusable, so the keyboard scrolls a table wider than a narrow window. */
42+
.credits-scroll {
43+
max-width: 760px;
44+
overflow-x: auto;
4345
}
4446

4547
.credits th:nth-child(2),
4648
.credits td:nth-child(2) {
47-
width: 9em;
48-
}
49-
50-
.credits th:nth-child(3),
51-
.credits td:nth-child(3) {
52-
width: 11em;
49+
white-space: nowrap;
5350
}
5451

5552
.credits thead th {
@@ -69,7 +66,7 @@
6966
.credits .credit-name {
7067
font-family: var(--font-mono);
7168
font-weight: 600;
72-
overflow-wrap: anywhere;
69+
white-space: nowrap;
7370
}
7471

7572
.about-licenses {

‎tools/web-ui/src/page/views/about.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ function credits(about: About): HTMLElement {
4949
{ class: "credit-section" },
5050
h("h3", { id: `credits-${index}` }, section.title),
5151
h(
52-
"table",
53-
{ class: "credits", "aria-labelledby": `credits-${index}` },
54-
h("thead", { class: "sr-only" }, h("tr", {}, ...["name", "version", "license"].map((name) => h("th", { scope: "col" }, name)))),
55-
h("tbody", {}, ...section.credits.map(creditRow)),
52+
"div",
53+
{ class: "credits-scroll", role: "region", tabindex: "0", "aria-labelledby": `credits-${index}` },
54+
h(
55+
"table",
56+
{ class: "credits", "aria-labelledby": `credits-${index}` },
57+
h("thead", { class: "sr-only" }, h("tr", {}, ...["name", "version", "license"].map((name) => h("th", { scope: "col" }, name)))),
58+
h("tbody", {}, ...section.credits.map(creditRow)),
59+
),
5660
),
5761
),
5862
),

0 commit comments

Comments
 (0)