@terpjs/react-core 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/package.json +5 -5
- package/src/Breadcrumbs.test.tsx +78 -0
- package/src/Breadcrumbs.tsx +38 -5
- package/src/ModuleNav.test.tsx +29 -1
- package/src/ModuleNav.tsx +5 -1
- package/src/Page.tsx +16 -3
- package/src/Stat.test.tsx +35 -0
- package/src/Stat.tsx +3 -1
- package/src/WorkspacePage.test.tsx +69 -0
- package/src/WorkspacePage.tsx +103 -0
- package/src/admin/AdminHub.tsx +233 -86
- package/src/admin/GroupDetail.tsx +1 -1
- package/src/admin/RecordHistory.tsx +5 -0
- package/src/admin/UserDetail.tsx +1 -1
- package/src/admin/admin.test.tsx +233 -14
- package/src/charts/TrendChart.tsx +24 -18
- package/src/charts/charts.test.tsx +11 -0
- package/src/currentInView.ts +28 -0
- package/src/dataview/DataView.test.tsx +48 -1
- package/src/dataview/DataView.tsx +18 -3
- package/src/dataview/DataViewToolbar.tsx +4 -1
- package/src/index.ts +2 -0
- package/src/layoutContract.test.tsx +62 -1
- package/src/layoutContract.ts +12 -0
- package/src/locale.tsx +8 -0
- package/src/markers.test.ts +4 -0
- package/src/router.test.tsx +1 -1
- package/src/router.tsx +19 -1
- package/src/styles.test.ts +241 -2
- package/src/styles.ts +234 -39
- package/src/trailMemory.ts +56 -0
- package/src/ui/Tabs.test.tsx +44 -0
- package/src/ui/Tabs.tsx +5 -2
- package/src/uiText.tsx +30 -1
- package/src/viewerTimeZone.ts +15 -0
package/src/styles.ts
CHANGED
|
@@ -302,7 +302,6 @@ html {
|
|
|
302
302
|
[data-terp="button"][data-variant="primary"] {
|
|
303
303
|
background: var(--color-brand-primary);
|
|
304
304
|
color: var(--color-brand-primary-contrast);
|
|
305
|
-
box-shadow: var(--shadow-sm);
|
|
306
305
|
}
|
|
307
306
|
[data-terp="button"][data-variant="secondary"] {
|
|
308
307
|
background: var(--color-neutral-0);
|
|
@@ -357,17 +356,29 @@ html {
|
|
|
357
356
|
/* Badges ------------------------------------------------------------------- */
|
|
358
357
|
/* The border matches the soft fill exactly, so it reads as one flat pill while
|
|
359
358
|
still occupying a border box — which is what keeps a Badge the same height
|
|
360
|
-
next to a bordered control.
|
|
359
|
+
next to a bordered control.
|
|
360
|
+
|
|
361
|
+
A label longer than its container wraps inside it. It did not: nowrap with no width cap let a
|
|
362
|
+
phrase in a narrow column run out of it, cover the next one and widen a phone's page. The
|
|
363
|
+
radius is what keeps one line a pill. 0.75rem is more than half a one-line badge's height,
|
|
364
|
+
so the corners clamp to a full round, exactly as 9999px did, and less than half of two lines',
|
|
365
|
+
so a wrapped badge is a rounded box rather than a lozenge.
|
|
366
|
+
|
|
367
|
+
It wraps between words, and inside a word only once a word alone is wider than the
|
|
368
|
+
container. break-word on an inline block, not anywhere on an inline flex: anywhere also
|
|
369
|
+
shrinks the badge's narrowest width to one glyph, so an auto-layout table squeezed the
|
|
370
|
+
badge column first and split "Cancelled" mid-word over three lines. A badge holds text
|
|
371
|
+
only, so the inline block draws one line exactly as the inline flex did. */
|
|
361
372
|
[data-terp="badge"] {
|
|
362
|
-
display: inline-
|
|
363
|
-
|
|
373
|
+
display: inline-block;
|
|
374
|
+
max-inline-size: 100%;
|
|
364
375
|
border: 1px solid;
|
|
365
|
-
border-radius: var(--radius-
|
|
376
|
+
border-radius: var(--radius-lg);
|
|
366
377
|
padding: 2px var(--space-2);
|
|
367
378
|
font-size: var(--font-size-xs);
|
|
368
379
|
font-weight: var(--font-weight-semibold);
|
|
369
380
|
line-height: 1.4;
|
|
370
|
-
|
|
381
|
+
overflow-wrap: break-word;
|
|
371
382
|
}
|
|
372
383
|
[data-terp="badge"][data-tone="neutral"] {
|
|
373
384
|
color: var(--color-fg-muted);
|
|
@@ -1272,7 +1283,16 @@ textarea[data-terp="input"] {
|
|
|
1272
1283
|
step down from the page, in light; the dark themes invert both, which is the direction a
|
|
1273
1284
|
recess wants in each. --color-bg-inset cannot do that job — in three themes it is
|
|
1274
1285
|
declared AS the canvas value, so an inset named from it would be the one thing that
|
|
1275
|
-
disappears.
|
|
1286
|
+
disappears.
|
|
1287
|
+
|
|
1288
|
+
Flat at rest (ADR 0172). The blocks are told apart by their fill and their hairline, never
|
|
1289
|
+
by a shadow: a card, a hub card, a figure, a chart and the table frame all sit on the page
|
|
1290
|
+
at one height. A shadow means a LAYER — something over the page that the page goes on
|
|
1291
|
+
under: a tooltip, a toast, a popover, a dropdown list, a dialog, the phone's nav drawer.
|
|
1292
|
+
It used to mean importance as well — the table frame raised to --shadow-md, the headline
|
|
1293
|
+
figure too, everything else at --shadow-sm and the chrome at none — and three meanings on
|
|
1294
|
+
one scale read as no system at all. Importance is the fill's job (the headline's brand
|
|
1295
|
+
fill, the table's surface), and the chrome's edges were hairlines already. */
|
|
1276
1296
|
[data-terp="card"] {
|
|
1277
1297
|
display: flex;
|
|
1278
1298
|
flex-direction: column;
|
|
@@ -1280,7 +1300,6 @@ textarea[data-terp="input"] {
|
|
|
1280
1300
|
background: var(--color-bg-subtle);
|
|
1281
1301
|
border: 1px solid var(--color-neutral-200);
|
|
1282
1302
|
border-radius: var(--radius-lg);
|
|
1283
|
-
box-shadow: var(--shadow-sm);
|
|
1284
1303
|
padding: var(--space-4);
|
|
1285
1304
|
min-width: 0;
|
|
1286
1305
|
}
|
|
@@ -1335,7 +1354,6 @@ textarea[data-terp="input"] {
|
|
|
1335
1354
|
[data-terp="card"][data-variant="plain"] {
|
|
1336
1355
|
background: none;
|
|
1337
1356
|
border-color: transparent;
|
|
1338
|
-
box-shadow: none;
|
|
1339
1357
|
padding: 0;
|
|
1340
1358
|
}
|
|
1341
1359
|
|
|
@@ -1520,17 +1538,33 @@ textarea[data-terp="input"] {
|
|
|
1520
1538
|
}
|
|
1521
1539
|
|
|
1522
1540
|
/* Tabs --------------------------------------------------------------------- */
|
|
1523
|
-
/* The
|
|
1524
|
-
|
|
1541
|
+
/* The strip is one line that scrolls sideways where it does not fit. It wrapped, and a wrapped
|
|
1542
|
+
strip put the second line's tabs under the first line's selected edge and the rule under the
|
|
1543
|
+
second line, so on a phone it read as two strips with one tab marked between them. The
|
|
1544
|
+
current tab is scrolled into the strip's view as it changes (useCurrentInView).
|
|
1545
|
+
|
|
1546
|
+
The rule is a 1px background on the content box's last row rather than a bottom border. A
|
|
1547
|
+
scroll container clips at its padding edge, and the selected tab's 2px edge reached a pixel
|
|
1548
|
+
into the border to cover it; drawn inside, the rule sits under that edge and nothing is cut.
|
|
1549
|
+
The padding is room for the focus ring, which the container would clip as well, and the
|
|
1550
|
+
negative margin gives the layout that room back, so the strip sits where it did. */
|
|
1525
1551
|
[data-terp="tabs"] {
|
|
1526
1552
|
display: grid;
|
|
1527
1553
|
gap: var(--space-3);
|
|
1528
1554
|
}
|
|
1529
1555
|
[data-terp="tab-list"] {
|
|
1530
1556
|
display: flex;
|
|
1531
|
-
flex-wrap:
|
|
1557
|
+
flex-wrap: nowrap;
|
|
1532
1558
|
gap: var(--space-1);
|
|
1533
|
-
|
|
1559
|
+
margin: calc(-1 * var(--space-1));
|
|
1560
|
+
padding: var(--space-1);
|
|
1561
|
+
overflow-x: auto;
|
|
1562
|
+
scrollbar-width: none;
|
|
1563
|
+
background: linear-gradient(var(--color-neutral-200), var(--color-neutral-200)) no-repeat
|
|
1564
|
+
var(--space-1) calc(100% - var(--space-1)) / calc(100% - 2 * var(--space-1)) 1px;
|
|
1565
|
+
}
|
|
1566
|
+
[data-terp="tab-list"]::-webkit-scrollbar {
|
|
1567
|
+
display: none;
|
|
1534
1568
|
}
|
|
1535
1569
|
[data-terp="tab"] {
|
|
1536
1570
|
font-family: var(--font-family-sans);
|
|
@@ -1543,7 +1577,8 @@ textarea[data-terp="input"] {
|
|
|
1543
1577
|
color: var(--color-fg-muted);
|
|
1544
1578
|
background: transparent;
|
|
1545
1579
|
cursor: pointer;
|
|
1546
|
-
|
|
1580
|
+
flex: none;
|
|
1581
|
+
white-space: nowrap;
|
|
1547
1582
|
border-top-left-radius: var(--radius-sm);
|
|
1548
1583
|
border-top-right-radius: var(--radius-sm);
|
|
1549
1584
|
transition:
|
|
@@ -1563,17 +1598,28 @@ textarea[data-terp="input"] {
|
|
|
1563
1598
|
|
|
1564
1599
|
The edges are logical (border-block-end) to match tab and appshell-footer rather
|
|
1565
1600
|
than the physical borderBottom the component declared. Identical in every writing
|
|
1566
|
-
mode this framework ships, and the sheet already had one convention.
|
|
1601
|
+
mode this framework ships, and the sheet already had one convention.
|
|
1602
|
+
|
|
1603
|
+
One line that scrolls sideways where it does not fit, as the tab strip is and for its
|
|
1604
|
+
reason: wrapped, the strip's rule sat under the second line and the first line's active
|
|
1605
|
+
edge floated above it. The rule stays the nav's own border, outside the scrolling list, so
|
|
1606
|
+
nothing clips it; the list's padding is the focus ring's room and its negative margin gives
|
|
1607
|
+
the layout that room back. */
|
|
1567
1608
|
[data-terp="module-nav"] {
|
|
1568
1609
|
border-block-end: 1px solid var(--color-neutral-200);
|
|
1569
1610
|
}
|
|
1570
1611
|
[data-terp="module-nav-list"] {
|
|
1571
1612
|
list-style: none;
|
|
1572
|
-
margin:
|
|
1573
|
-
padding:
|
|
1613
|
+
margin: calc(-1 * var(--space-1));
|
|
1614
|
+
padding: var(--space-1);
|
|
1574
1615
|
display: flex;
|
|
1575
|
-
flex-wrap:
|
|
1616
|
+
flex-wrap: nowrap;
|
|
1576
1617
|
gap: var(--space-3);
|
|
1618
|
+
overflow-x: auto;
|
|
1619
|
+
scrollbar-width: none;
|
|
1620
|
+
}
|
|
1621
|
+
[data-terp="module-nav-list"]::-webkit-scrollbar {
|
|
1622
|
+
display: none;
|
|
1577
1623
|
}
|
|
1578
1624
|
[data-terp="module-nav-link"] {
|
|
1579
1625
|
display: inline-flex;
|
|
@@ -1581,6 +1627,7 @@ textarea[data-terp="input"] {
|
|
|
1581
1627
|
padding: var(--space-2) 0;
|
|
1582
1628
|
color: var(--color-fg-muted);
|
|
1583
1629
|
text-decoration: none;
|
|
1630
|
+
white-space: nowrap;
|
|
1584
1631
|
border-block-end: 2px solid transparent;
|
|
1585
1632
|
}
|
|
1586
1633
|
|
|
@@ -1649,6 +1696,19 @@ textarea[data-terp="input"] {
|
|
|
1649
1696
|
[data-terp="breadcrumbs"] li > [data-terp="breadcrumbs-separator"] {
|
|
1650
1697
|
flex: 0 0 auto;
|
|
1651
1698
|
}
|
|
1699
|
+
/* A crumb whose label is not known yet and never was at this path (ADR 0173): a quiet bar of
|
|
1700
|
+
one width where its words will be, in em so it scales with the crumb or the heading it sits
|
|
1701
|
+
in. Not a stand-in word: the parent's name in the leaf was a wrong title for as long as the
|
|
1702
|
+
record loaded. The words are its visually hidden "Loading", read where the bar is shown. */
|
|
1703
|
+
[data-terp="breadcrumbs-pending"] {
|
|
1704
|
+
display: inline-block;
|
|
1705
|
+
inline-size: 8em;
|
|
1706
|
+
max-inline-size: 100%;
|
|
1707
|
+
block-size: 0.9em;
|
|
1708
|
+
vertical-align: middle;
|
|
1709
|
+
border-radius: var(--radius-sm);
|
|
1710
|
+
background: var(--color-neutral-100);
|
|
1711
|
+
}
|
|
1652
1712
|
/* Keyed on our own marker, not on [aria-current="page"]. The trail's ancestor
|
|
1653
1713
|
crumbs are the app router's links, and TanStack stamps aria-current="page" on
|
|
1654
1714
|
every link whose path is a PREFIX of the current one — which every ancestor
|
|
@@ -1936,7 +1996,13 @@ textarea[data-terp="input"] {
|
|
|
1936
1996
|
and the nav labels in the icon rail, which were a style-object TERNARY before this —
|
|
1937
1997
|
the component picked between two objects per render, and the collapsed branch was
|
|
1938
1998
|
painted by nothing, because the rail state was internal and no specimen could reach it.
|
|
1939
|
-
That is what defaultCollapsed is for.
|
|
1999
|
+
That is what defaultCollapsed is for.
|
|
2000
|
+
|
|
2001
|
+
Every element named here is a block or an inline box, never a table: a table's width and
|
|
2002
|
+
height are minimums, so this rule cannot shrink one. A chart's data table is hidden through
|
|
2003
|
+
its wrapper for that reason. Marked on the table itself, it kept its full size, hung below the
|
|
2004
|
+
chart, stretched the document, and a page whose content fitted could scroll, carrying the
|
|
2005
|
+
shell's sticky sidebar away with it. */
|
|
1940
2006
|
[data-terp="appshell-skip-link"],
|
|
1941
2007
|
[data-terp="drawer-focus-start"],
|
|
1942
2008
|
[data-terp="drawer-focus-end"],
|
|
@@ -1944,6 +2010,7 @@ textarea[data-terp="input"] {
|
|
|
1944
2010
|
[data-terp="stat-trend-data"],
|
|
1945
2011
|
[data-terp="chart-table"],
|
|
1946
2012
|
[data-terp="status-history-data"],
|
|
2013
|
+
[data-terp="breadcrumbs-pending-text"],
|
|
1947
2014
|
[data-terp="appshell-sidebar"][data-collapsed="true"] [data-terp="appshell-brand-title"],
|
|
1948
2015
|
[data-terp="appshell-sidebar"][data-collapsed="true"] [data-terp="appshell-nav-label"],
|
|
1949
2016
|
[data-terp="appshell-sidebar"][data-collapsed="true"] [data-terp="appshell-nav-group-label"] {
|
|
@@ -2191,11 +2258,18 @@ textarea[data-terp="input"] {
|
|
|
2191
2258
|
content — the loading and error frames, where the body is one small block. With
|
|
2192
2259
|
the default the two rows would spread to fill the height. It needs something to
|
|
2193
2260
|
stretch the article before it is observable at all, which is why page-loading and
|
|
2194
|
-
page-error render inside a grid box rather than a plain tall div.
|
|
2261
|
+
page-error render inside a grid box rather than a plain tall div.
|
|
2262
|
+
|
|
2263
|
+
The gap is the room between SECTIONS (ADR 0174), and it is a step wider than the gap inside
|
|
2264
|
+
one: --space-6 against the --space-4 a grid and a hub's cards keep between the blocks of a
|
|
2265
|
+
section. At one shared --space-4, a row of cards was as far from
|
|
2266
|
+
the table under it as the cards were from each other, so nothing said where a section
|
|
2267
|
+
ended. Two rules below cancel or repeat this value and name the same token: the summary
|
|
2268
|
+
band's flush margin and the sequence bar's room above it. */
|
|
2195
2269
|
[data-terp="page"] {
|
|
2196
2270
|
display: grid;
|
|
2197
2271
|
grid-template-columns: minmax(0, 1fr);
|
|
2198
|
-
gap: var(--space-
|
|
2272
|
+
gap: var(--space-6);
|
|
2199
2273
|
align-content: start;
|
|
2200
2274
|
min-width: 0;
|
|
2201
2275
|
}
|
|
@@ -2540,7 +2614,7 @@ textarea[data-terp="input"] {
|
|
|
2540
2614
|
[data-terp="appshell-main"]
|
|
2541
2615
|
> [data-terp="page"]:not([data-measure="narrow"])
|
|
2542
2616
|
> [data-terp="page-summary"] {
|
|
2543
|
-
margin: calc(-1 * var(--space-
|
|
2617
|
+
margin: calc(-1 * var(--space-6)) calc(-1 * var(--shell-gutter)) 0;
|
|
2544
2618
|
padding-inline: var(--shell-gutter);
|
|
2545
2619
|
border-radius: 0;
|
|
2546
2620
|
border-block-end: 1px solid var(--color-neutral-200);
|
|
@@ -2597,9 +2671,14 @@ textarea[data-terp="input"] {
|
|
|
2597
2671
|
As a width it composes instead of competing, because CSS resolves max-width AFTER width:
|
|
2598
2672
|
min(100%, measure) caps a child that has no measure of its own, and a child that has one
|
|
2599
2673
|
still wins with it. min() rather than a bare token so a track narrower than the measure is
|
|
2600
|
-
untouched rather than overflowing.
|
|
2674
|
+
untouched rather than overflowing.
|
|
2675
|
+
|
|
2676
|
+
A workspace's canvas host is exempt as the bands are (ADR 0179): the measure exists for
|
|
2677
|
+
reading, and a canvas is not read along a line. Capped, it stopped at the measure and sat
|
|
2678
|
+
against the start of a wider track, with the band above running past it. Adding it to the
|
|
2679
|
+
one :not() leaves the weight where it was, for the reason the summary band's entry does. */
|
|
2601
2680
|
[data-terp="appshell"][data-content-width="measured"]
|
|
2602
|
-
[data-terp="page"] > *:not([data-terp="page-header"], [data-terp="page-summary"]) {
|
|
2681
|
+
[data-terp="page"] > *:not([data-terp="page-header"], [data-terp="page-summary"], [data-terp="canvas-host"]) {
|
|
2603
2682
|
width: min(100%, var(--shell-content-max-width));
|
|
2604
2683
|
}
|
|
2605
2684
|
/* The reach-through, for the one body child that generates no box of its own. Markdown is
|
|
@@ -2646,7 +2725,9 @@ textarea[data-terp="input"] {
|
|
|
2646
2725
|
grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
|
|
2647
2726
|
align-items: center;
|
|
2648
2727
|
gap: var(--space-3);
|
|
2649
|
-
|
|
2728
|
+
/* The page's own section gap, so the body ends as far above the bar as it starts below the
|
|
2729
|
+
band. */
|
|
2730
|
+
margin-block-start: var(--space-6);
|
|
2650
2731
|
padding-block: var(--space-2) max(var(--space-2), env(safe-area-inset-bottom));
|
|
2651
2732
|
border-block-start: 1px solid var(--color-neutral-200);
|
|
2652
2733
|
background: var(--color-bg-subtle);
|
|
@@ -2760,6 +2841,81 @@ html:has([data-terp="page-sequence"]) {
|
|
|
2760
2841
|
min-width: 0;
|
|
2761
2842
|
}
|
|
2762
2843
|
|
|
2844
|
+
/* The workspace (ADR 0179) ------------------------------------------------ */
|
|
2845
|
+
/* One canvas that fills the screen. Every other page lays its body out as blocks that take
|
|
2846
|
+
the height of their content; a canvas has none of its own and takes the box it is given, so
|
|
2847
|
+
the box has to come from here or from an inline style app code may not write.
|
|
2848
|
+
|
|
2849
|
+
The same scoping the page-sequence bar uses: the shell's main area becomes a flex column
|
|
2850
|
+
only when it holds a workspace, the page grows into it, and inside the page the host grows
|
|
2851
|
+
into what the band and the summary leave. No other page changes. The page keeps its own gap,
|
|
2852
|
+
because a flex column honours gap exactly as the grid did. */
|
|
2853
|
+
[data-terp="appshell-main"]:has(> [data-terp="page"][data-fill="workspace"]) {
|
|
2854
|
+
display: flex;
|
|
2855
|
+
flex-direction: column;
|
|
2856
|
+
}
|
|
2857
|
+
[data-terp="appshell-main"] > [data-terp="page"][data-fill="workspace"] {
|
|
2858
|
+
flex-grow: 1;
|
|
2859
|
+
}
|
|
2860
|
+
[data-terp="page"][data-fill="workspace"] {
|
|
2861
|
+
display: flex;
|
|
2862
|
+
flex-direction: column;
|
|
2863
|
+
}
|
|
2864
|
+
[data-terp="page"][data-fill="workspace"] > [data-terp="canvas-host"] {
|
|
2865
|
+
flex: 1 1 auto;
|
|
2866
|
+
}
|
|
2867
|
+
/* A state in the canvas's place takes the canvas's box: it grows as the host does, keeps the
|
|
2868
|
+
host's floor, and centres its message in it. Otherwise the frame is a short block while the
|
|
2869
|
+
canvas loads and jumps to the full height when it arrives. Only these three: an alert above
|
|
2870
|
+
the canvas is a line of the page, and the canvas takes what it leaves. */
|
|
2871
|
+
[data-terp="page"][data-fill="workspace"] > [data-terp="loading-state"],
|
|
2872
|
+
[data-terp="page"][data-fill="workspace"] > [data-terp="error-state"],
|
|
2873
|
+
[data-terp="page"][data-fill="workspace"] > [data-terp="empty-state"] {
|
|
2874
|
+
flex: 1 1 auto;
|
|
2875
|
+
min-height: 24rem;
|
|
2876
|
+
align-content: center;
|
|
2877
|
+
}
|
|
2878
|
+
/* The host is a block of the page, painted as one: the surface fill, and the hairline and
|
|
2879
|
+
radius a card uses. It clips, so a canvas panned past its edge never paints over the band.
|
|
2880
|
+
clip rather than hidden: hidden makes the host a scroll container, so focusing something on
|
|
2881
|
+
the canvas near its edge could scroll the drawing inside its frame, and clip cannot. The
|
|
2882
|
+
floor keeps a canvas a canvas where nothing gives it height: standalone, and on a viewport
|
|
2883
|
+
shorter than the band plus the floor. */
|
|
2884
|
+
[data-terp="canvas-host"] {
|
|
2885
|
+
position: relative;
|
|
2886
|
+
min-height: 24rem;
|
|
2887
|
+
min-width: 0;
|
|
2888
|
+
overflow: clip;
|
|
2889
|
+
background: var(--color-bg-surface);
|
|
2890
|
+
border: 1px solid var(--color-neutral-200);
|
|
2891
|
+
border-radius: var(--radius-lg);
|
|
2892
|
+
}
|
|
2893
|
+
/* The layer the canvas is drawn in, laid over the whole host, and the framework's own element.
|
|
2894
|
+
The host's height comes from flex growth inside a column that is only min-height tall, so a
|
|
2895
|
+
percentage height resolved against the HOST is not definite. Positioning the canvas itself
|
|
2896
|
+
absolutely would sidestep that, but a canvas library's root is not ours to position: its
|
|
2897
|
+
own sheet sizes it (commonly position: relative and a 100% size), and an unlayered sheet beats
|
|
2898
|
+
every layered rule here. No library styles this layer, and an absolutely positioned box at
|
|
2899
|
+
inset 0 has a definite size, so its child takes 100% of it in both directions and that
|
|
2900
|
+
resolves: an svg fills it and scales its drawing by its viewBox, and a library root that
|
|
2901
|
+
sizes itself to its container gets all of it.
|
|
2902
|
+
|
|
2903
|
+
The explicit 100% is there because an svg is a replaced element: given only a box to sit in,
|
|
2904
|
+
it takes its width from the box and its height from its viewBox's ratio, so a wide diagram sat
|
|
2905
|
+
at the top of a tall canvas instead of in its middle. The first recording of the workspace
|
|
2906
|
+
baseline showed exactly that. Every child takes the whole layer, which is why the host takes
|
|
2907
|
+
one: a second lands below the first and is clipped. A dialog is the exception, at its own
|
|
2908
|
+
size, because an open modal one is in the top layer and a 100% height would stretch it over
|
|
2909
|
+
the whole viewport. */
|
|
2910
|
+
[data-terp="canvas-host-layer"] {
|
|
2911
|
+
position: absolute;
|
|
2912
|
+
inset: 0;
|
|
2913
|
+
}
|
|
2914
|
+
[data-terp="canvas-host-layer"] > :not([data-terp="dialog"]) {
|
|
2915
|
+
width: 100%;
|
|
2916
|
+
height: 100%;
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2763
2919
|
/* The sign-in screen ------------------------------------------------------- */
|
|
2764
2920
|
/* The one screen an unauthenticated user sees, and the only full-viewport page in
|
|
2765
2921
|
the package: a 100vh grid centring one card. The reset layer's box-sizing note
|
|
@@ -2807,7 +2963,6 @@ html:has([data-terp="page-sequence"]) {
|
|
|
2807
2963
|
background: var(--color-neutral-0);
|
|
2808
2964
|
border: 1px solid var(--color-neutral-200);
|
|
2809
2965
|
border-radius: var(--radius-lg);
|
|
2810
|
-
box-shadow: var(--shadow-md);
|
|
2811
2966
|
}
|
|
2812
2967
|
[data-terp="login-brand"] {
|
|
2813
2968
|
display: flex;
|
|
@@ -3017,7 +3172,6 @@ html:has([data-terp="page-sequence"]) {
|
|
|
3017
3172
|
background: var(--color-bg-subtle);
|
|
3018
3173
|
border: 1px solid var(--color-neutral-200);
|
|
3019
3174
|
border-radius: var(--radius-lg);
|
|
3020
|
-
box-shadow: var(--shadow-sm);
|
|
3021
3175
|
color: var(--color-neutral-900);
|
|
3022
3176
|
box-sizing: border-box;
|
|
3023
3177
|
transition: border-color var(--motion-duration-fast) var(--motion-easing-standard);
|
|
@@ -3080,6 +3234,23 @@ html:has([data-terp="page-sequence"]) {
|
|
|
3080
3234
|
[data-terp="hubcard-stat"][data-empty="true"] {
|
|
3081
3235
|
visibility: hidden;
|
|
3082
3236
|
}
|
|
3237
|
+
/* A list none of whose cards carries a figure keeps no figure row. The placeholder is there so
|
|
3238
|
+
a bare card stays flush with a full one beside it; with no full one there is nothing to stay
|
|
3239
|
+
flush with, and the row and the 10rem floor it helped pad out were blank space at the foot
|
|
3240
|
+
of every card — the admin hub's areas under its figures, an app's landing before its first
|
|
3241
|
+
figure. The cards in a row still share a height: the grid stretches them, and the
|
|
3242
|
+
description's track takes the slack. */
|
|
3243
|
+
:is(ul, ol):not(:has([data-terp="hubcard-stat"]:not([data-empty="true"])))
|
|
3244
|
+
> [data-terp="hubcard"]
|
|
3245
|
+
[data-terp="hubcard-body"] {
|
|
3246
|
+
grid-template-rows: auto 1fr;
|
|
3247
|
+
min-height: 0;
|
|
3248
|
+
}
|
|
3249
|
+
:is(ul, ol):not(:has([data-terp="hubcard-stat"]:not([data-empty="true"])))
|
|
3250
|
+
> [data-terp="hubcard"]
|
|
3251
|
+
[data-terp="hubcard-stat"] {
|
|
3252
|
+
display: none;
|
|
3253
|
+
}
|
|
3083
3254
|
|
|
3084
3255
|
/* DataView: the composition root ------------------------------------------- */
|
|
3085
3256
|
/* One display for both return paths, so it belongs on the bare marker rather than
|
|
@@ -3126,11 +3297,11 @@ html:has([data-terp="page-sequence"]) {
|
|
|
3126
3297
|
leaves the toolbar inside a surface, and leaves two nested frames whenever the view
|
|
3127
3298
|
is empty (the empty state's dashed frame inside the card's solid one).
|
|
3128
3299
|
|
|
3129
|
-
What the slot carries is the surface itself — a fill, a border and a radius
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3300
|
+
What the slot carries is the surface itself — a fill, a border and a radius. The
|
|
3301
|
+
collection is where data is read, so under ADR 0169's surface ladder it keeps
|
|
3302
|
+
--color-bg-surface while the containers around it step back to --color-bg-subtle: the
|
|
3303
|
+
table is the brightest object on the page by rule. It was raised by --shadow-md as well,
|
|
3304
|
+
and no longer is: a block at rest is flat (ADR 0172), and the fill already says it. None of that moves the ownership settled above: the frame is the
|
|
3134
3305
|
table's, not the view's.
|
|
3135
3306
|
|
|
3136
3307
|
Keyed on [data-variant="full"] rather than the bare marker for the reason the
|
|
@@ -3143,7 +3314,6 @@ html:has([data-terp="page-sequence"]) {
|
|
|
3143
3314
|
background: var(--color-bg-surface);
|
|
3144
3315
|
border: 1px solid var(--color-neutral-200);
|
|
3145
3316
|
border-radius: var(--radius-lg);
|
|
3146
|
-
box-shadow: var(--shadow-md);
|
|
3147
3317
|
}
|
|
3148
3318
|
/* The horizontal scroll container the reset's scrollbar comment already names. A
|
|
3149
3319
|
marker rather than [data-terp="dataview"] > div, which also matches the toolbar.
|
|
@@ -3646,7 +3816,6 @@ th[data-terp="dataview-actions-cell"] > span {
|
|
|
3646
3816
|
background: var(--color-bg-surface);
|
|
3647
3817
|
border: 1px solid var(--color-neutral-200);
|
|
3648
3818
|
border-radius: var(--radius-lg);
|
|
3649
|
-
box-shadow: var(--shadow-sm);
|
|
3650
3819
|
}
|
|
3651
3820
|
[data-terp="dataview-card"][data-clickable="true"] {
|
|
3652
3821
|
cursor: pointer;
|
|
@@ -4609,7 +4778,6 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
4609
4778
|
border: 1px solid var(--color-neutral-200);
|
|
4610
4779
|
border-radius: var(--radius-lg);
|
|
4611
4780
|
background: var(--color-bg-surface);
|
|
4612
|
-
box-shadow: var(--shadow-sm);
|
|
4613
4781
|
color: var(--color-fg-default);
|
|
4614
4782
|
}
|
|
4615
4783
|
[data-terp="chart-caption"] {
|
|
@@ -5012,7 +5180,6 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
5012
5180
|
border: 1px solid var(--color-neutral-200);
|
|
5013
5181
|
border-radius: var(--radius-lg);
|
|
5014
5182
|
background: var(--color-bg-surface);
|
|
5015
|
-
box-shadow: var(--shadow-sm);
|
|
5016
5183
|
color: var(--color-fg-default);
|
|
5017
5184
|
}
|
|
5018
5185
|
[data-terp="stat-label"] {
|
|
@@ -5032,6 +5199,13 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
5032
5199
|
font-variant-numeric: tabular-nums;
|
|
5033
5200
|
overflow-wrap: anywhere;
|
|
5034
5201
|
}
|
|
5202
|
+
/* A figure with nothing to show prints a dash, and the dash is an absence rather than a number:
|
|
5203
|
+
in the value's full ink and weight it read as a broken bar. A headline keeps its own ink, the
|
|
5204
|
+
one its fill was measured against. */
|
|
5205
|
+
[data-terp="stat"]:not([data-headline]) [data-terp="stat-value"][data-empty] {
|
|
5206
|
+
color: var(--color-fg-subtle);
|
|
5207
|
+
font-weight: var(--font-weight-normal);
|
|
5208
|
+
}
|
|
5035
5209
|
[data-terp="stat-delta"] {
|
|
5036
5210
|
display: flex;
|
|
5037
5211
|
flex-wrap: wrap;
|
|
@@ -5126,7 +5300,6 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
5126
5300
|
[data-terp="stat"][data-headline] {
|
|
5127
5301
|
border-color: var(--color-brand-primary);
|
|
5128
5302
|
background: var(--color-brand-primary);
|
|
5129
|
-
box-shadow: var(--shadow-md);
|
|
5130
5303
|
color: var(--color-brand-primary-contrast);
|
|
5131
5304
|
}
|
|
5132
5305
|
[data-terp="stat"][data-headline] [data-terp="stat-label"],
|
|
@@ -5186,6 +5359,19 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
5186
5359
|
[data-terp="stat-group"] > [data-terp="stat"][data-headline] + [data-terp="stat"] {
|
|
5187
5360
|
box-shadow: none;
|
|
5188
5361
|
}
|
|
5362
|
+
/* On a narrow screen the rows of figures, and the band they sit in, close up: a band of five
|
|
5363
|
+
figures is three rows deep there, and with a full gap between them and the band's full padding
|
|
5364
|
+
around them it put the page's own content half a phone's height down. The floor above stays,
|
|
5365
|
+
two to a line: three were tried, and a figure such as "4 m 12 s" then broke over two lines
|
|
5366
|
+
and its label over two more, which made the group taller rather than shorter. */
|
|
5367
|
+
@media ${NARROW_VIEWPORT} {
|
|
5368
|
+
[data-terp="stat-group"] {
|
|
5369
|
+
row-gap: var(--space-2);
|
|
5370
|
+
}
|
|
5371
|
+
[data-terp="page-summary"] {
|
|
5372
|
+
padding-block: var(--space-3);
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5189
5375
|
/* A lone figure in a boxed card: the card is its frame, so the figure takes no tile of its own
|
|
5190
5376
|
-- a tile inside a box is a frame inside a frame. A group's cells keep theirs, and the
|
|
5191
5377
|
headline keeps its fill wherever it is. A plain card has no frame to lend, so a figure in one
|
|
@@ -5195,7 +5381,6 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
5195
5381
|
border: 0;
|
|
5196
5382
|
border-radius: 0;
|
|
5197
5383
|
background: none;
|
|
5198
|
-
box-shadow: none;
|
|
5199
5384
|
}
|
|
5200
5385
|
/* In a hub card's stat row the card is the frame, so an ordinary figure has none of its own
|
|
5201
5386
|
there. The headline keeps its fill wherever it is. */
|
|
@@ -5204,7 +5389,6 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
5204
5389
|
border: 0;
|
|
5205
5390
|
border-radius: 0;
|
|
5206
5391
|
background: none;
|
|
5207
|
-
box-shadow: none;
|
|
5208
5392
|
}
|
|
5209
5393
|
|
|
5210
5394
|
/* Tooltips ----------------------------------------------------------------- */
|
|
@@ -6188,6 +6372,17 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
6188
6372
|
box-shadow: 0 0 0 3px var(--color-focus-ring);
|
|
6189
6373
|
}
|
|
6190
6374
|
|
|
6375
|
+
/* The canvas's ring, drawn on its host (ADR 0179). A canvas that answers keys takes focus, and
|
|
6376
|
+
it fills the host's layer edge to edge, so any ring drawn around it lies outside the host's
|
|
6377
|
+
padding box and the host's clip cuts all of it away: a keyboard user on the canvas saw no
|
|
6378
|
+
indicator at all. The host's own outline and shadow sit outside the box it clips, so the ring
|
|
6379
|
+
moves there, the shared ring's declarations unchanged, while the canvas has keyboard focus. */
|
|
6380
|
+
[data-terp="canvas-host"]:has(> [data-terp="canvas-host-layer"] > :focus-visible) {
|
|
6381
|
+
outline: 2px solid var(--color-fg-accent);
|
|
6382
|
+
outline-offset: 1px;
|
|
6383
|
+
box-shadow: 0 0 0 3px var(--color-focus-ring);
|
|
6384
|
+
}
|
|
6385
|
+
|
|
6191
6386
|
/* The pager's disabled ink, scoped rather than added to the shared iconbutton
|
|
6192
6387
|
rule above: of the seventeen sites wearing that marker only six can be disabled at
|
|
6193
6388
|
all — these four and the view-options panel's two reorder arrows, which carry
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the breadcrumb trail has already said about each place, for as long as the app runs
|
|
5
|
+
* (ADR 0173).
|
|
6
|
+
*
|
|
7
|
+
* Every routed view mounts its own page, so the trail is built again on every navigation, and
|
|
8
|
+
* a label that comes from data (a record's name) is not known again until that data is: the
|
|
9
|
+
* trail used to print a stand-in and then the name, on every visit, on every tab of a detail,
|
|
10
|
+
* and on the parent crumb one level down. The trail is the same place it was a moment ago, so
|
|
11
|
+
* it can say so. A crumb whose label is not known yet shows the last label it had at that
|
|
12
|
+
* path, and only a place never seen before shows a placeholder.
|
|
13
|
+
*
|
|
14
|
+
* The router's shell holds the labels, one map for the app's lifetime ({@link TrailLabelsContext}),
|
|
15
|
+
* and each routed view binds them to the path ITS OWN match is at. Not the router's current
|
|
16
|
+
* location: during a navigation the old page is still rendered while the location is already
|
|
17
|
+
* the new one, so a leaf keyed by the location remembered the page being left under the name of
|
|
18
|
+
* the page being opened, and the detail then recalled its parent's title. A trail outside a Terp
|
|
19
|
+
* router has no memory: a pending crumb is a placeholder there, and nothing else changes.
|
|
20
|
+
*/
|
|
21
|
+
export interface TrailMemory {
|
|
22
|
+
/** The path this routed view's own match is at: the key for its leaf, which has no `to`. */
|
|
23
|
+
readonly pathname: string;
|
|
24
|
+
/** The last label shown at *path*, if any. */
|
|
25
|
+
recall(path: string): string | undefined;
|
|
26
|
+
/** Remember *label* as what *path* is called. */
|
|
27
|
+
remember(path: string, label: string): void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** One spelling per place: no query, no fragment, no trailing slash past the root. */
|
|
31
|
+
export function trailPath(path: string): string {
|
|
32
|
+
const bare = path.split(/[?#]/, 1)[0]!;
|
|
33
|
+
return bare.length > 1 ? bare.replace(/\/+$/, "") : bare;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A memory over *labels*, at *pathname*. The map outlives the value, which a navigation replaces. */
|
|
37
|
+
export function trailMemory(labels: Map<string, string>, pathname: string): TrailMemory {
|
|
38
|
+
return {
|
|
39
|
+
pathname,
|
|
40
|
+
recall: (path) => labels.get(trailPath(path)),
|
|
41
|
+
remember: (path, label) => {
|
|
42
|
+
labels.set(trailPath(path), label);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The labels themselves, held by the router's shell across every navigation. */
|
|
48
|
+
export const TrailLabelsContext = createContext<Map<string, string> | null>(null);
|
|
49
|
+
|
|
50
|
+
/** The memory bound to the routed view's own path. */
|
|
51
|
+
export const TrailMemoryContext = createContext<TrailMemory | null>(null);
|
|
52
|
+
|
|
53
|
+
/** The surrounding router's trail memory, or `null` outside one. */
|
|
54
|
+
export function useTrailMemory(): TrailMemory | null {
|
|
55
|
+
return useContext(TrailMemoryContext);
|
|
56
|
+
}
|
package/src/ui/Tabs.test.tsx
CHANGED
|
@@ -55,3 +55,47 @@ describe("Tabs with a single tab", () => {
|
|
|
55
55
|
expect(screen.getByRole("tab", { name: "Only" })).toBeDisabled();
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
|
+
|
|
59
|
+
describe("Tabs on a strip too narrow for them", () => {
|
|
60
|
+
// jsdom lays nothing out, so the boxes are given: the strip is 100 to 300, and whichever tab
|
|
61
|
+
// is selected sits where each test puts it.
|
|
62
|
+
function boxes(selected: [number, number]) {
|
|
63
|
+
return vi
|
|
64
|
+
.spyOn(HTMLElement.prototype, "getBoundingClientRect")
|
|
65
|
+
.mockImplementation(function (this: HTMLElement) {
|
|
66
|
+
const at = (left: number, right: number) =>
|
|
67
|
+
({ left, right, top: 0, bottom: 20, width: right - left, height: 20, x: left, y: 0 }) as DOMRect;
|
|
68
|
+
if (this.dataset.terp === "tab-list") return at(100, 300);
|
|
69
|
+
if (this.getAttribute("aria-selected") === "true") return at(...selected);
|
|
70
|
+
return at(0, 0);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
it("scrolls the strip forward to a selected tab past its end, and follows the selection", () => {
|
|
75
|
+
const spy = boxes([320, 360]);
|
|
76
|
+
try {
|
|
77
|
+
render(<Tabs label="Sections" tabs={tabs} defaultValue="audit" />);
|
|
78
|
+
const list = screen.getByRole("tablist");
|
|
79
|
+
// Mutation: no scroll, which leaves the selected tab out of sight on a phone.
|
|
80
|
+
expect(list.scrollLeft).toBe(60);
|
|
81
|
+
fireEvent.click(screen.getByRole("tab", { name: "Overview" }));
|
|
82
|
+
// Mutation: scrolling on mount only, not as the selection moves.
|
|
83
|
+
expect(list.scrollLeft).toBe(120);
|
|
84
|
+
} finally {
|
|
85
|
+
spy.mockRestore();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("scrolls it back to a selected tab before its start", () => {
|
|
90
|
+
// jsdom keeps a negative scroll position where a browser clamps it, which is what makes the
|
|
91
|
+
// backward step visible here.
|
|
92
|
+
const spy = boxes([60, 90]);
|
|
93
|
+
try {
|
|
94
|
+
render(<Tabs label="Sections" tabs={tabs} defaultValue="audit" />);
|
|
95
|
+
// Mutation: scrolling only forwards, which leaves a tab before the strip's start hidden.
|
|
96
|
+
expect(screen.getByRole("tablist").scrollLeft).toBe(-40);
|
|
97
|
+
} finally {
|
|
98
|
+
spy.mockRestore();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
package/src/ui/Tabs.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useId, useMemo, useState } from "react";
|
|
1
|
+
import { useId, useMemo, useRef, useState } from "react";
|
|
2
2
|
import type { KeyboardEvent, ReactNode } from "react";
|
|
3
3
|
|
|
4
|
+
import { useCurrentInView } from "../currentInView";
|
|
4
5
|
import { injectTerpStyles } from "../styles";
|
|
5
6
|
import { useUiText } from "../uiText";
|
|
6
7
|
import type { UiText } from "../uiText";
|
|
@@ -37,6 +38,8 @@ export function Tabs({ tabs, value, defaultValue, onChange, label }: TabsProps)
|
|
|
37
38
|
// Nothing reports that — axe sees a well-formed reference to nothing. The same refusal to
|
|
38
39
|
// interpolate caller strings into ids is written out at AppShell's nav-group labels.
|
|
39
40
|
const selectedIndex = tabs.findIndex((tab) => tab.value === selectedTab?.value);
|
|
41
|
+
const list = useRef<HTMLDivElement>(null);
|
|
42
|
+
useCurrentInView(list, selectedTab?.value, '[aria-selected="true"]');
|
|
40
43
|
|
|
41
44
|
// One usable tab is not a choice, so it gets no chrome. A tablist over a single tab costs
|
|
42
45
|
// a row of the screen to offer nothing, and it is worse than decorative to a screen
|
|
@@ -92,7 +95,7 @@ export function Tabs({ tabs, value, defaultValue, onChange, label }: TabsProps)
|
|
|
92
95
|
|
|
93
96
|
return (
|
|
94
97
|
<div data-terp="tabs">
|
|
95
|
-
<div role="tablist" data-terp="tab-list" aria-label={label === undefined ? undefined : resolve(label)} onKeyDown={onKeyDown}>
|
|
98
|
+
<div ref={list} role="tablist" data-terp="tab-list" aria-label={label === undefined ? undefined : resolve(label)} onKeyDown={onKeyDown}>
|
|
96
99
|
{tabs.map((tab, index) => {
|
|
97
100
|
const selected = tab.value === selectedTab?.value;
|
|
98
101
|
return (
|