Skip to content

Commit 449bc59

Browse files
committed
fix(ui): table links read as links
Tables sit on `--table-frame-background` (`--surface-tint`), which is darker than the page, and nothing here accounted for that. The link blue measures 4.96:1 on the page but 4.39:1 on the frame, and its dark counterpart 3.68:1 -- both under AA. They now take a ramp step either side: 5.66:1 light, 6.76:1 dark. Links also had no cue but hue. A link and a code span in a cell were both Menlo 400 with no decoration, so in the Type column `Attribute[]` and `string` differed only in colour -- WCAG 1.4.1. Table links carry an underline. `--table-name-color` is inherited rather than the label pink. The frame specifies that colour for the first-column names, but the selector reaches every code span in a cell, none of which are links; magenta, and on dark an outright #FF4C4C, read as dead links beside the live ones, at 3.00:1 and 3.71:1. Inheriting also handles `<code><a>` correctly, since the nested link keeps its own colour. Hover moves from the cell to the link. The cell rule washed 30% black over the whole `td`, dropping the link it advertised to 2.72:1 and putting a pointer over prose that wasn't clickable. The link's own hover steps one further in each theme's direction, so it is always the stronger state, and thickens the underline rather than adding one.
1 parent 1973148 commit 449bc59

2 files changed

Lines changed: 61 additions & 10 deletions

File tree

‎docs/ui/src/css/doc.css‎

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,37 @@ html {
437437
background: none;
438438
}
439439

440+
/* Table links carry an underline and their own blue.
441+
442+
Underline, because nothing else marked them: links and inline code in a
443+
cell are both Menlo at 400 with no decoration, so in the Type column
444+
`Attribute[]` (a link) and `string` (not one) differed by hue alone --
445+
WCAG 1.4.1. The mock draws no underline, but it also doesn't put the two
446+
side by side in a column.
447+
448+
Their own blue, because the cell ground is `--table-frame-background`
449+
(`--surface-tint`), darker than the page. `--link` measures 4.96:1 on the
450+
page but 4.39:1 here, and its dark counterpart 3.68:1 -- both under the
451+
4.5 AA wants. `--table-link-color` is the ramp step either side: 5.66:1
452+
light, 6.80:1 dark. */
453+
.doc table.tableblock a {
454+
color: var(--table-link-color);
455+
text-decoration: underline;
456+
text-underline-offset: 0.15em;
457+
}
458+
459+
/* Hover belongs to the link, not the cell. The cell-wide rule this replaces
460+
washed 30% black over the whole `td` -- which dropped the link it was
461+
advertising from 5.66:1 to 2.72:1, and put a pointer cursor over prose that
462+
wasn't clickable. Here the colour steps one further in each theme's own
463+
direction, so the hover state is always the stronger of the two, and the
464+
rule thickens rather than appears, since the underline is already on. */
465+
.doc table.tableblock a:hover,
466+
.doc table.tableblock a:focus-visible {
467+
color: var(--table-link-hover-color);
468+
text-decoration-thickness: 2px;
469+
}
470+
440471
.doc table.tableblock thead ~ tbody tr:first-child {
441472
background-color: transparent;
442473
}
@@ -449,8 +480,11 @@ html {
449480
font-size: calc(14 / var(--rem-base) * 1rem);
450481
}
451482

452-
/* Figma: names are Menlo 14 in the label pink -- .doc code's 0.95em would
453-
render them at 13.3. */
483+
/* Menlo 14 -- `.doc code`'s 0.95em would render these at 13.3. The colour is
484+
inherited rather than the frame's label pink: this selector catches every
485+
code span in a cell, none of which are links, and the pink read as a broken
486+
one next to the real links in the same column. A link nested inside a code
487+
span still takes `--table-link-color` from the rule above. */
454488
.doc table.tableblock td code {
455489
color: var(--table-name-color);
456490
background: none;
@@ -1360,11 +1394,6 @@ html {
13601394
height: 20px !important;
13611395
}
13621396

1363-
.doc table.tableblock td:has(a):hover {
1364-
background-color: rgba(0, 0, 0, 0.3);
1365-
cursor: pointer;
1366-
}
1367-
13681397
.doc table.tableblock td:has(a) p {
13691398
margin: 0;
13701399
padding: 0;

‎docs/ui/src/css/vars.css‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
--mr-blue-300: #93c5fd;
3535
--mr-blue-450: #1e78ff; /* Figma exact: theme-toggle fill, note blocks */
3636
--mr-blue-600: #2563eb;
37+
/* One step past 600, for links on the tinted table ground where 600
38+
measures 4.39:1. */
39+
--mr-blue-700: #1d4fd7;
40+
/* Hover steps for table links -- one further in each theme's direction, so
41+
the state is never dimmer than the rest state. */
42+
--mr-blue-800: #1e40af;
43+
--mr-blue-200: #bfdbfe;
3744
--mr-yellow: #facc15;
3845
--mr-yellow-300: #f1d874;
3946
--mr-amber-700: #b45309;
@@ -343,14 +350,24 @@
343350
1.00:1, i.e. no visible grid and no visible header at all.
344351
The framed variant's ground is the brand blue at 10% over the page
345352
(#E7EDF6 light / #263552 dark), which is exactly --surface-tint.
346-
Names in the first column are Menlo in the label colour (#EC4899 light /
347-
#FF4C4C dark) -- --ds-color-label already carries both. */
353+
The frame draws the first-column names in the label colour (#EC4899
354+
light / #FF4C4C dark), but that rule reaches every code span in a cell,
355+
not just the names -- and those spans are not links. Magenta and, on
356+
dark, outright red read as a visited or dead link sitting beside the
357+
live blue ones, and they measure 3.00:1 and 3.71:1 on the frame ground.
358+
They take the cell's own colour instead. */
348359
--table-border-color: var(--ds-color-code-body);
349360
--table-frame-color: var(--outline);
350361
--table-frame-background: var(--surface-tint);
362+
/* Links sit on that tinted frame, not the page. `--link` (#2563EB) is
363+
4.96:1 on the page but 4.39:1 here, and the dark blue 3.68:1 -- both
364+
under AA. One step darker clears it at 5.66:1; dark goes the other way,
365+
to the 300, at 6.80:1. */
366+
--table-link-color: var(--mr-blue-700);
367+
--table-link-hover-color: var(--mr-blue-800);
351368
--table-header-background: var(--ds-color-code-body);
352369
--table-header-color: var(--mr-white);
353-
--table-name-color: var(--ds-color-label);
370+
--table-name-color: inherit;
354371
--table-stripe-background: var(--surface-2);
355372
--table-footer-background:
356373
linear-gradient(
@@ -435,6 +452,9 @@
435452
--border-strong: rgba(148, 163, 184, 0.32);
436453
/* DERIVED -- see the note in the prefers-color-scheme block below. */
437454
--outline: #000;
455+
/* Dark inverts the direction: the 300 clears the tinted frame at 6.80:1. */
456+
--table-link-color: var(--mr-blue-300);
457+
--table-link-hover-color: var(--mr-blue-200);
438458
--navbar-surface: var(--mr-navy-750);
439459
--nav-title-background: var(--mr-red);
440460
--gold-surface: var(--mr-yellow);
@@ -514,6 +534,8 @@
514534
--border-strong: rgba(148, 163, 184, 0.32);
515535
/* DERIVED -- the frame is light only. Revisit with a dark frame. */
516536
--outline: #000;
537+
--table-link-color: var(--mr-blue-300);
538+
--table-link-hover-color: var(--mr-blue-200);
517539
--navbar-surface: var(--mr-navy-750);
518540
--nav-title-background: var(--mr-red);
519541
--gold-surface: var(--mr-yellow);

0 commit comments

Comments
 (0)