@terpjs/react-core 0.16.0 → 0.18.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 +4 -3
- package/package.json +2 -2
- package/src/Disclosure.test.tsx +106 -0
- package/src/Disclosure.tsx +104 -0
- package/src/bootstrap.test.tsx +49 -0
- package/src/bootstrap.tsx +23 -0
- package/src/clipboard.test.ts +158 -0
- package/src/clipboard.ts +165 -0
- package/src/dataview/DataView.test.tsx +49 -0
- package/src/dataview/DataView.tsx +16 -0
- package/src/dataview/DataViewCardList.tsx +4 -2
- package/src/dataview/DataViewTable.tsx +19 -6
- package/src/index.ts +7 -2
- package/src/layout.test.tsx +80 -1
- package/src/layout.tsx +143 -6
- package/src/layoutContract.test.tsx +1 -0
- package/src/layoutContract.ts +1 -0
- package/src/markers.test.ts +4 -0
- package/src/styles.test.ts +204 -6
- package/src/styles.ts +306 -49
- package/src/theme.test.tsx +30 -0
- package/src/theme.tsx +17 -0
- package/src/tokens.guard.test.ts +1 -1
- package/src/useResource.test.tsx +56 -0
- package/src/useResource.ts +49 -4
package/src/styles.ts
CHANGED
|
@@ -397,6 +397,37 @@ html {
|
|
|
397
397
|
and the icon inherits — so a tone is one declaration pair rather than three
|
|
398
398
|
places to keep in step. The body restates the reading colour, because the
|
|
399
399
|
copy must stay neutral-900 while the frame and glyph carry the tone. */
|
|
400
|
+
/* Disclosure. The toggle is a text button that happens to carry a chevron, so it
|
|
401
|
+
inherits the reading colour rather than the accent -- a row of accent-coloured
|
|
402
|
+
"Technical details" links reads as navigation, and this navigates nowhere. The
|
|
403
|
+
chevron rotates by swapping the glyph rather than by transform, which keeps the
|
|
404
|
+
two states legible with animation disabled.
|
|
405
|
+
|
|
406
|
+
The panel is indented to the width of the chevron plus its gap, so the revealed
|
|
407
|
+
content lines up with the label above it instead of with the glyph. */
|
|
408
|
+
[data-terp="disclosure"] {
|
|
409
|
+
display: flex;
|
|
410
|
+
flex-direction: column;
|
|
411
|
+
gap: var(--space-2);
|
|
412
|
+
}
|
|
413
|
+
[data-terp="disclosure-toggle"] {
|
|
414
|
+
display: inline-flex;
|
|
415
|
+
align-items: center;
|
|
416
|
+
gap: var(--space-2);
|
|
417
|
+
align-self: flex-start;
|
|
418
|
+
padding: var(--space-1) var(--space-2);
|
|
419
|
+
margin-inline-start: calc(var(--space-2) * -1);
|
|
420
|
+
border: none;
|
|
421
|
+
border-radius: var(--radius-sm);
|
|
422
|
+
background: none;
|
|
423
|
+
color: var(--color-neutral-700);
|
|
424
|
+
font: inherit;
|
|
425
|
+
font-weight: 500;
|
|
426
|
+
cursor: pointer;
|
|
427
|
+
}
|
|
428
|
+
[data-terp="disclosure-panel"] {
|
|
429
|
+
padding-inline-start: calc(var(--space-4) + var(--space-2));
|
|
430
|
+
}
|
|
400
431
|
[data-terp="alert"] {
|
|
401
432
|
display: grid;
|
|
402
433
|
grid-template-columns: auto 1fr;
|
|
@@ -609,10 +640,42 @@ textarea[data-terp="input"] {
|
|
|
609
640
|
/* display: contents is what makes the dt and dd grid items of the dl itself, so labels align
|
|
610
641
|
ACROSS rows without a DOM change — and it belongs in here rather than in the base rules
|
|
611
642
|
because it is the mechanism of the shared column, which exists only above the cutover.
|
|
612
|
-
Narrow, the row wrapper stays a block and each pair reads as two lines.
|
|
613
|
-
|
|
643
|
+
Narrow, the row wrapper stays a block and each pair reads as two lines.
|
|
644
|
+
|
|
645
|
+
EVERY ROW BUT THE FULL ONE, and the exclusion is the whole of how full works rather than
|
|
646
|
+
a special case bolted onto it. A box that generates no box has no grid area, so the
|
|
647
|
+
grid-column the full row asks for is DROPPED and its span silently does not happen. Said
|
|
648
|
+
as :not() here, the full row is simply never a contents box — in this rule, in the auto
|
|
649
|
+
rule below, and in any third one someone adds — instead of being un-contents-ed again
|
|
650
|
+
afterwards by a rule that has to out-specify each of them in turn. The first version did
|
|
651
|
+
it that way and the auto list was the case it lost: same weight, declared earlier, so
|
|
652
|
+
full did nothing there at any width. */
|
|
653
|
+
[data-terp="detail-list"][data-layout="aligned"]
|
|
654
|
+
[data-terp="detail-list-row"]:not([data-full="true"]) {
|
|
614
655
|
display: contents;
|
|
615
656
|
}
|
|
657
|
+
/* The shared measure across several lists (ADR 0113). The GROUP owns the track list -- see
|
|
658
|
+
its base rule below -- and each aligned list inside becomes a subgrid of it, so every
|
|
659
|
+
label in every list is measured against one track instead of each list measuring its own.
|
|
660
|
+
Four lists on a card had four different gutters before this, none of them wrong by that
|
|
661
|
+
list's own rules, which is why it read as sloppy rather than broken.
|
|
662
|
+
|
|
663
|
+
Keyed on :not([data-columns]) rather than on the marker alone, and that exclusion is the
|
|
664
|
+
honest half: a two-pair list needs FOUR tracks and the group publishes two, so folding it
|
|
665
|
+
in would reflow its pairs to one per row -- a layout change wearing an alignment fix's
|
|
666
|
+
clothes. It keeps its own tracks and its own measure, which is what it renders today.
|
|
667
|
+
|
|
668
|
+
Inside the wide block because that is where the shared column exists at all: below the
|
|
669
|
+
cutover every list is one column with the label above its value, so there is nothing to
|
|
670
|
+
share and the group is a plain stack of lists.
|
|
671
|
+
|
|
672
|
+
No feature query, and that is a property of subgrid rather than an omission: where it is
|
|
673
|
+
unsupported the declaration is dropped and each list keeps its own tracks, which is
|
|
674
|
+
exactly today's output. Baseline-wide since Chrome 117, Safari 16, Firefox 71. */
|
|
675
|
+
[data-terp="detail-list-group"]
|
|
676
|
+
> [data-terp="detail-list"][data-layout="aligned"]:not([data-columns]) {
|
|
677
|
+
grid-template-columns: subgrid;
|
|
678
|
+
}
|
|
616
679
|
}
|
|
617
680
|
|
|
618
681
|
/* Grids -------------------------------------------------------------------- */
|
|
@@ -689,6 +752,19 @@ textarea[data-terp="input"] {
|
|
|
689
752
|
[data-terp="detail-list-row"] {
|
|
690
753
|
min-width: 0;
|
|
691
754
|
}
|
|
755
|
+
/* One pair across every track, for the value that cannot live in a column: a paragraph, a
|
|
756
|
+
payload, a code block. Declared at every width, which costs nothing where there is one track
|
|
757
|
+
to span and is the point where there are four -- and it is what stopped a wide value from
|
|
758
|
+
needing a SECOND list, whose independently measured label column put its values on a
|
|
759
|
+
different vertical line from the first list's.
|
|
760
|
+
|
|
761
|
+
1 / -1 rather than a span count, so it does not have to know whether the list is one pair
|
|
762
|
+
wide, two, or an auto-fit count nobody wrote down. It is a grid item in every layout,
|
|
763
|
+
because the two rules that make a row a display: contents box both exclude it by
|
|
764
|
+
selector — a contents box has no grid area and would drop this declaration silently. */
|
|
765
|
+
[data-terp="detail-list-row"][data-full="true"] {
|
|
766
|
+
grid-column: 1 / -1;
|
|
767
|
+
}
|
|
692
768
|
[data-terp="detail-list-term"] {
|
|
693
769
|
display: inline;
|
|
694
770
|
font-weight: var(--font-weight-medium);
|
|
@@ -729,6 +805,50 @@ textarea[data-terp="input"] {
|
|
|
729
805
|
[data-terp="detail-list"][data-layout="stacked"] {
|
|
730
806
|
row-gap: var(--space-3);
|
|
731
807
|
}
|
|
808
|
+
/* columns="auto", and its tracks live HERE rather than in the wide-viewport block above --
|
|
809
|
+
which is the whole of what it is for. The closed counts need a cutover because a number
|
|
810
|
+
cannot fit a phone; an auto-fit floor needs none, so this list follows its CONTAINER instead
|
|
811
|
+
of the window. That is the difference that matters for a list inside a card inside a split
|
|
812
|
+
pane, where the window says nothing about the width the list actually got.
|
|
813
|
+
|
|
814
|
+
Two published floors, and they are the behaviour rather than a detail: a pair is at least
|
|
815
|
+
9rem of label and 13rem of value. Measured across seven container widths -- three pairs at
|
|
816
|
+
1200px, two at 900px, one from 700px down.
|
|
817
|
+
|
|
818
|
+
The percentage cap is the part that is not obvious, and it is a real failure rather than
|
|
819
|
+
defensive. Grid's floor is min(16rem, 100%) because ONE track wider than its container
|
|
820
|
+
overflows it; a PAIR has two floors and 100% each lets their sum reach 200%, so a detail
|
|
821
|
+
list in a narrow panel scrolled sideways -- measured overflowing at 120px with both floors
|
|
822
|
+
capped at 100%. 30% and 60% leave the gap its share, so one pair always fits: no sideways
|
|
823
|
+
scroll at 240px.
|
|
824
|
+
|
|
825
|
+
A zero floor is not an option here even though every other track in this component takes
|
|
826
|
+
one. minmax(0, max-content) inside an auto-fit repeat makes the repetition count unbounded:
|
|
827
|
+
measured, Chromium generated 35 pair repetitions and collapsed 31 of them to 0px, putting
|
|
828
|
+
every pair on one row. Floors are what make auto-fit mean anything.
|
|
829
|
+
|
|
830
|
+
16rem for the layouts with no label column, which is Grid's own floor -- so a stacked auto
|
|
831
|
+
list and a Grid of cards break at the same width by construction rather than by coincidence,
|
|
832
|
+
the same argument the hub grid's floor already makes. */
|
|
833
|
+
[data-terp="detail-list"][data-columns="auto"] {
|
|
834
|
+
grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
|
|
835
|
+
column-gap: var(--space-4);
|
|
836
|
+
}
|
|
837
|
+
[data-terp="detail-list"][data-layout="aligned"][data-columns="auto"] {
|
|
838
|
+
grid-template-columns: repeat(
|
|
839
|
+
auto-fit,
|
|
840
|
+
minmax(min(9rem, 30%), max-content) minmax(min(13rem, 60%), 1fr)
|
|
841
|
+
);
|
|
842
|
+
column-gap: var(--space-3);
|
|
843
|
+
}
|
|
844
|
+
/* The shared column for an auto list, at EVERY width, which the aligned rule in the wide block
|
|
845
|
+
only gives above the cutover. Without it an auto list below the cutover would place each pair
|
|
846
|
+
BLOCK into one auto track, so the label would sit above its value in a list that had asked to
|
|
847
|
+
be measured -- the reflow this prop exists to replace, arriving through the back door. */
|
|
848
|
+
[data-terp="detail-list"][data-layout="aligned"][data-columns="auto"]
|
|
849
|
+
[data-terp="detail-list-row"]:not([data-full="true"]) {
|
|
850
|
+
display: contents;
|
|
851
|
+
}
|
|
732
852
|
[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-term"],
|
|
733
853
|
[data-terp="detail-list"][data-layout="aligned"] [data-terp="detail-list-value"],
|
|
734
854
|
[data-terp="detail-list"][data-layout="stacked"] [data-terp="detail-list-term"],
|
|
@@ -767,6 +887,48 @@ textarea[data-terp="input"] {
|
|
|
767
887
|
[data-terp="detail-list"][data-gap="6"] { row-gap: var(--space-6); }
|
|
768
888
|
[data-terp="detail-list"][data-gap="8"] { row-gap: var(--space-8); }
|
|
769
889
|
|
|
890
|
+
/* The detail-list group (ADR 0113): several lists, one measured label column.
|
|
891
|
+
The subgrid half is in the wide-viewport block above, where the shared column exists; this
|
|
892
|
+
is the container that owns the tracks it shares.
|
|
893
|
+
|
|
894
|
+
THE TRACK LIST IS DECLARED ONCE, HERE, AND AT EVERY WIDTH -- not split into a narrow shape
|
|
895
|
+
and a wide override, and that is a placement decision rather than a shortcut. The wide block
|
|
896
|
+
sits ~100 lines above this section, so an override there would have to out-specify a rule
|
|
897
|
+
that comes later in source; the group root has no second attribute to spend on that. It does
|
|
898
|
+
not need one: with every child spanning 1 / -1, a group whose children are NOT subgrids
|
|
899
|
+
renders exactly as a stack of full-width lists, because the label track is then sized by
|
|
900
|
+
nothing and collapses to zero. So the narrow shape needs no rule at all and the two shapes
|
|
901
|
+
cannot drift apart.
|
|
902
|
+
|
|
903
|
+
It must be the aligned track list, verbatim, and column-gap with it: a subgrid takes the
|
|
904
|
+
PARENT's gutters along the axis it subgrids, so the group's column-gap becomes the
|
|
905
|
+
label-to-value distance inside every list in it. styles.test.ts pins the two against each
|
|
906
|
+
other, because a group whose tracks disagreed with aligned's would align the lists to each
|
|
907
|
+
other and to nothing else on the card. */
|
|
908
|
+
[data-terp="detail-list-group"] {
|
|
909
|
+
display: grid;
|
|
910
|
+
grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
|
|
911
|
+
column-gap: var(--space-3);
|
|
912
|
+
row-gap: var(--space-4);
|
|
913
|
+
min-width: 0;
|
|
914
|
+
}
|
|
915
|
+
/* Every child spans the group, lists and everything between them alike -- a heading, a
|
|
916
|
+
divider, a paragraph. A list that becomes a subgrid needs the span to reach both tracks;
|
|
917
|
+
a child that does not is simply full width, which is what it would have been on its own. */
|
|
918
|
+
[data-terp="detail-list-group"] > * {
|
|
919
|
+
grid-column: 1 / -1;
|
|
920
|
+
min-width: 0;
|
|
921
|
+
}
|
|
922
|
+
/* The distance between the lists. row-gap only, for the reason the list's own gap prop gives:
|
|
923
|
+
the column gap is the shared measure and belongs to the group's rule above, not to a caller. */
|
|
924
|
+
[data-terp="detail-list-group"][data-gap="0"] { row-gap: var(--space-0); }
|
|
925
|
+
[data-terp="detail-list-group"][data-gap="1"] { row-gap: var(--space-1); }
|
|
926
|
+
[data-terp="detail-list-group"][data-gap="2"] { row-gap: var(--space-2); }
|
|
927
|
+
[data-terp="detail-list-group"][data-gap="3"] { row-gap: var(--space-3); }
|
|
928
|
+
[data-terp="detail-list-group"][data-gap="4"] { row-gap: var(--space-4); }
|
|
929
|
+
[data-terp="detail-list-group"][data-gap="6"] { row-gap: var(--space-6); }
|
|
930
|
+
[data-terp="detail-list-group"][data-gap="8"] { row-gap: var(--space-8); }
|
|
931
|
+
|
|
770
932
|
/* Checkboxes / radios / switches ------------------------------------------- */
|
|
771
933
|
/* One label shape for all three, so the marker is shared: the control differs,
|
|
772
934
|
the "box or dot, gap, then its text" arrangement does not. accent-color is
|
|
@@ -1130,9 +1292,32 @@ textarea[data-terp="input"] {
|
|
|
1130
1292
|
/* Breadcrumbs -------------------------------------------------------------- */
|
|
1131
1293
|
/* The trail owns its whole subtree, so the list and its items are addressed
|
|
1132
1294
|
structurally and the current crumb by the aria-current it already carries —
|
|
1133
|
-
no marker for something the accessibility tree already states.
|
|
1295
|
+
no marker for something the accessibility tree already states.
|
|
1296
|
+
|
|
1297
|
+
ONE line-height for every crumb, declared here rather than left to inherit, and it is a
|
|
1298
|
+
repair rather than a tidy-up. The leaf declared 1.3 of its own (see page-title) while its
|
|
1299
|
+
ancestors inherited line-height: normal, so a row that centres its items was centring two
|
|
1300
|
+
different line boxes and the two could not share a baseline. Measured in the workbench at
|
|
1301
|
+
font-size-sm: the ancestors' line box resolved to 19.00px against the leaf's 18.19px, which
|
|
1302
|
+
left the leaf's glyphs 0.59px above the crumb it hangs off, with the chevron between them
|
|
1303
|
+
centred on a third line. Sub-pixel, and it reads as a trail whose end sits high.
|
|
1304
|
+
|
|
1305
|
+
DECLARED rather than inherited for the second half of the same defect: normal is the FONT's
|
|
1306
|
+
own metric, so the size of the mismatch was whatever the app's typeface happened to say, and
|
|
1307
|
+
an app on a webfont with taller natural leading got a worse one than the system stack this
|
|
1308
|
+
was measured in. A published step is the one value the ancestor links and the h1 can agree
|
|
1309
|
+
on without either of them asking the font.
|
|
1310
|
+
|
|
1311
|
+
What this does NOT fix is the chevron's optical centring, and that is a decision rather than
|
|
1312
|
+
an oversight. Its box centres on the line box at 95.48px while the crumb's ink centres at
|
|
1313
|
+
96.00px, because the font's ascent carries 5px of empty space above the caps against 4px of
|
|
1314
|
+
descent below the baseline — so a box-centred glyph sits half a pixel high. Correcting it
|
|
1315
|
+
means a nudge in em against ONE font's metrics, and this package renders system-ui: Segoe UI
|
|
1316
|
+
here, SF on macOS, Roboto on Android. A correction that is right on one is wrong on the other
|
|
1317
|
+
two, so the half pixel stays. */
|
|
1134
1318
|
[data-terp="breadcrumbs"] {
|
|
1135
1319
|
font-size: var(--font-size-sm);
|
|
1320
|
+
line-height: var(--font-line-height-snug);
|
|
1136
1321
|
color: var(--color-neutral-600);
|
|
1137
1322
|
}
|
|
1138
1323
|
[data-terp="breadcrumbs"] ol,
|
|
@@ -1472,8 +1657,41 @@ textarea[data-terp="input"] {
|
|
|
1472
1657
|
above. That is a published contract token rather than a private property because
|
|
1473
1658
|
tokens.guard.test.ts refuses a fallback-less var() against anything tokens.css does not
|
|
1474
1659
|
declare — and a shell measure an app may want to move is what ADR 0097 §1 says a contract
|
|
1475
|
-
token is for.
|
|
1476
|
-
|
|
1660
|
+
token is for.
|
|
1661
|
+
|
|
1662
|
+
The BLOCK padding is ZERO, and that is what makes --shell-header-height mean anything. It
|
|
1663
|
+
was var(--space-2) under the min-height floor and the floor never once applied: this header
|
|
1664
|
+
ALWAYS carries a control — the sidebar toggle, the theme and language triggers — and a
|
|
1665
|
+
control is --density-control-min-height, 2.25rem. 36px of control plus 8px of padding plus
|
|
1666
|
+
the 1px border is 53px against a floor of 48, so the token an app reads to line its own
|
|
1667
|
+
chrome up with this header was 5px short of the header itself, and the page band below
|
|
1668
|
+
(which reads the same token, and carries a control only on a page that has actions) was 48px
|
|
1669
|
+
on some pages and 53px on others. Measured, both of them, in the workbench.
|
|
1670
|
+
|
|
1671
|
+
Zero rather than a step, and the step is what the first attempt used: var(--space-1) leaves
|
|
1672
|
+
a 39px content box, which clears the 2.25rem control and NOT the 2.75rem one the package
|
|
1673
|
+
also ships (Button size="lg" is --density-control-min-height plus --space-2). Measured: a
|
|
1674
|
+
band whose action button was large came out at 53px again — the same defect, on a legal
|
|
1675
|
+
composition, four pixels of padding away. At zero the content box is the floor less its
|
|
1676
|
+
border, 47px, which clears every control this package has; the row centres its content, so
|
|
1677
|
+
a 36px control sits with 5.5px above and below it either way and nothing about the ordinary
|
|
1678
|
+
band moves.
|
|
1679
|
+
|
|
1680
|
+
What zero costs is the WRAPPED row's breathing room, and the row gap is what pays for it:
|
|
1681
|
+
a band that wraps grows past the floor and its two lines stay var(--space-2) apart, but the
|
|
1682
|
+
first line now starts at the border. That is the trade — a rare row a little tight against
|
|
1683
|
+
its edge, against a common row whose height depended on which control the page happened to
|
|
1684
|
+
put in it.
|
|
1685
|
+
|
|
1686
|
+
A headroom argument rather than a proof, so it is pinned where a resolved height can be read
|
|
1687
|
+
instead of inferred: the workbench's computed lane asserts both chrome rows come out at
|
|
1688
|
+
--shell-header-height with no control, with the default one, and with the largest one the
|
|
1689
|
+
package ships.
|
|
1690
|
+
|
|
1691
|
+
Not solved by raising the token instead, which was the other candidate. 3rem is published
|
|
1692
|
+
geometry an app can already move from its own theme.css, and a consumer reading it to
|
|
1693
|
+
offset something against this header is entitled to the number being true — so the fix is
|
|
1694
|
+
to make the header the height it claims, not to redefine the claim around the padding.
|
|
1477
1695
|
|
|
1478
1696
|
No backticks anywhere above, and that is not a style preference: one here terminates
|
|
1479
1697
|
TERP_STYLES_CSS and the parse then fails somewhere else entirely with "try inserting a
|
|
@@ -1487,7 +1705,7 @@ textarea[data-terp="input"] {
|
|
|
1487
1705
|
align-items: center;
|
|
1488
1706
|
justify-content: space-between;
|
|
1489
1707
|
gap: var(--space-3);
|
|
1490
|
-
padding: var(--space-
|
|
1708
|
+
padding: var(--space-0) var(--shell-gutter);
|
|
1491
1709
|
min-height: var(--shell-header-height);
|
|
1492
1710
|
box-sizing: border-box;
|
|
1493
1711
|
background: var(--color-neutral-0);
|
|
@@ -1689,8 +1907,10 @@ textarea[data-terp="input"] {
|
|
|
1689
1907
|
list. In a band the title is CHROME — it names where you are, above content that starts
|
|
1690
1908
|
immediately under a border — and a 24px leaf on a trail of 14px ancestors reads as
|
|
1691
1909
|
small-small-BIG rather than as one trail. It also does not fit: the band is
|
|
1692
|
-
shell-header-height
|
|
1693
|
-
|
|
1910
|
+
shell-header-height less its 1px border, which leaves 47px, and xl at the trail's line
|
|
1911
|
+
height is 2.03rem of it before a badge or a lead line asks for room —
|
|
1912
|
+
and the row would then be set by the title rather than by the floor, which is the defect
|
|
1913
|
+
the padding above was cut to end.
|
|
1694
1914
|
--font-size-xl keeps two readers (heading[data-size="xl"], login-title), so the top of the
|
|
1695
1915
|
scale is still wired; an app that wants the masthead back redefines the marker from its own
|
|
1696
1916
|
unlayered theme.css, exactly as the retired comment here said.
|
|
@@ -1727,14 +1947,18 @@ textarea[data-terp="input"] {
|
|
|
1727
1947
|
specific the ancestor rule is: without this the leaf renders at twice the trail.
|
|
1728
1948
|
|
|
1729
1949
|
Semibold at the trail's own size, which is the whole "the trail is the title" idea in one
|
|
1730
|
-
declaration — heavier than its ancestors, not larger.
|
|
1950
|
+
declaration — heavier than its ancestors, not larger.
|
|
1951
|
+
|
|
1952
|
+
And no line-height of its own, which is the other half of that idea: it takes the trail's
|
|
1953
|
+
(see breadcrumbs, where the value and the defect are recorded). A second value here — 1.3
|
|
1954
|
+
against the ancestors' inherited normal — is what left the leaf's glyphs sitting 0.59px
|
|
1955
|
+
above the crumb they hang off, in the same font at the same size. */
|
|
1731
1956
|
[data-terp="page-title"] {
|
|
1732
1957
|
margin: 0;
|
|
1733
1958
|
font-size: var(--font-size-sm);
|
|
1734
1959
|
font-weight: var(--font-weight-semibold);
|
|
1735
1960
|
letter-spacing: 0;
|
|
1736
1961
|
color: var(--color-neutral-900);
|
|
1737
|
-
line-height: 1.3;
|
|
1738
1962
|
}
|
|
1739
1963
|
/* Status pills next to the title. A row of its own so a page passing several keeps them
|
|
1740
1964
|
together when the band wraps, rather than letting one pill orphan onto the second line. */
|
|
@@ -1771,6 +1995,16 @@ textarea[data-terp="input"] {
|
|
|
1771
1995
|
height this is reading. Without it the two are a padding apart and the "same height as the
|
|
1772
1996
|
header above it" claim is off by 1rem.
|
|
1773
1997
|
|
|
1998
|
+
padding-block is ZERO for the reason the app header's rule states in full, and this row is
|
|
1999
|
+
where the symptom showed: with var(--space-2) a single action button beat the floor, so the
|
|
2000
|
+
band was 53px on a page with actions and 48px on a page without — the one piece of chrome
|
|
2001
|
+
whose entire promise is that it is the same height as the header above it, changing height
|
|
2002
|
+
per page. var(--space-1) fixed that for the default control and not for the large one, which
|
|
2003
|
+
is why this is zero rather than a step. It still grows past the floor when the row WRAPS, which is the
|
|
2004
|
+
one case that should move it: a long title meeting a wide action cluster takes a second
|
|
2005
|
+
line rather than overflowing, and a band that clipped its own title to keep a height would
|
|
2006
|
+
be the worse trade.
|
|
2007
|
+
|
|
1774
2008
|
:not([data-measure="narrow"]) because a form is capped WITH its header (ADR 0098 §3) — a
|
|
1775
2009
|
Save button a screen-width from its field is worse than one over it — so a form gets the
|
|
1776
2010
|
one-row band with no chrome at all: a title row, which is what it wants.
|
|
@@ -1779,7 +2013,7 @@ textarea[data-terp="input"] {
|
|
|
1779
2013
|
is nothing to bleed into and an inline pad with no negative margin would inset the band's
|
|
1780
2014
|
content from the body beneath it for no reason. */
|
|
1781
2015
|
[data-terp="page"]:not([data-measure="narrow"]) > [data-terp="page-header"] {
|
|
1782
|
-
padding-block: var(--space-
|
|
2016
|
+
padding-block: var(--space-0);
|
|
1783
2017
|
min-height: var(--shell-header-height);
|
|
1784
2018
|
box-sizing: border-box;
|
|
1785
2019
|
border-block-end: 1px solid var(--color-neutral-200);
|
|
@@ -2120,17 +2354,16 @@ textarea[data-terp="input"] {
|
|
|
2120
2354
|
through an ancestor. hub-card-bare is what catches this one, and only because its full
|
|
2121
2355
|
card is deliberately long enough to set the row height.
|
|
2122
2356
|
|
|
2123
|
-
The transition
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2357
|
+
The transition is ONE property on ONE element, and it used to be three across three.
|
|
2358
|
+
box-shadow and transform animated on the card and colour on the title, because the hover
|
|
2359
|
+
state lifted the card a pixel, gave it a shadow and took the title to accent alongside the
|
|
2360
|
+
edge. The movement is gone (see the state rules for why), and with it both of the card's
|
|
2361
|
+
transitions and the title's — a transition whose property nothing changes is dead weight
|
|
2362
|
+
that reads as a live intention. What remains is the body's border-color, declared on the
|
|
2363
|
+
element that owns the border. */
|
|
2128
2364
|
[data-terp="hubcard"] {
|
|
2129
2365
|
height: 100%;
|
|
2130
2366
|
min-height: 0;
|
|
2131
|
-
transition:
|
|
2132
|
-
box-shadow var(--motion-duration-fast) var(--motion-easing-standard),
|
|
2133
|
-
transform var(--motion-duration-fast) var(--motion-easing-standard);
|
|
2134
2367
|
}
|
|
2135
2368
|
[data-terp="hubcard-body"] {
|
|
2136
2369
|
display: grid;
|
|
@@ -2173,7 +2406,6 @@ textarea[data-terp="input"] {
|
|
|
2173
2406
|
color: var(--color-neutral-900);
|
|
2174
2407
|
font-size: var(--font-size-base);
|
|
2175
2408
|
font-weight: var(--font-weight-semibold);
|
|
2176
|
-
transition: color var(--motion-duration-fast) var(--motion-easing-standard);
|
|
2177
2409
|
}
|
|
2178
2410
|
/* neutral-600 rather than fg-muted, and it is not the tinted-surface case: this text
|
|
2179
2411
|
sits on the card's own neutral-0 and measures 7.58 / 7.94 / 7.50 / 7.60 / 18.42. */
|
|
@@ -3865,6 +4097,15 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
3865
4097
|
}
|
|
3866
4098
|
|
|
3867
4099
|
@layer terp.state {
|
|
4100
|
+
/* Disclosure's toggle is a text button, so its hover is a quiet wash rather than a
|
|
4101
|
+
fill -- the control sits inside reading content and a solid hover would read as a
|
|
4102
|
+
row selection. No focus rule: the [data-terp]:focus-visible rule below already covers every
|
|
4103
|
+
marked element, and restating it here would be a copy that can drift out of step. */
|
|
4104
|
+
[data-terp="disclosure-toggle"]:hover {
|
|
4105
|
+
background: var(--color-neutral-100);
|
|
4106
|
+
color: var(--color-neutral-900);
|
|
4107
|
+
}
|
|
4108
|
+
|
|
3868
4109
|
/* Shared focus-visible ring: every interactive element that opts in via
|
|
3869
4110
|
[data-terp] shows a soft outline ring. It must stay in terp.state. It ties
|
|
3870
4111
|
with [data-terp="button"][data-variant="primary"] on specificity — both
|
|
@@ -4251,30 +4492,42 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
4251
4492
|
}
|
|
4252
4493
|
|
|
4253
4494
|
/* Hub cards --------------------------------------------------------------- */
|
|
4254
|
-
/* The hover
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4495
|
+
/* The hover state is the accent edge, and nothing else.
|
|
4496
|
+
|
|
4497
|
+
It was four declarations over three elements: the card lifted a pixel and took a shadow,
|
|
4498
|
+
the body's border went accent, the title's colour went with it. The lift is what people
|
|
4499
|
+
actually noticed, and not kindly. A hub is a grid of large targets, so a pointer on its way
|
|
4500
|
+
to one card sweeps across every card between here and there, and each one twitched as it
|
|
4501
|
+
passed — motion reporting the cursor's position, which the cursor already reports. Movement
|
|
4502
|
+
in an interface should say something the still frame cannot; this said nothing, on a surface
|
|
4503
|
+
that shows several of itself at once. The shadow went with it rather than separately: a
|
|
4504
|
+
1px rise and a 1px shadow are one effect, elevation, and half of an elevation reads as a
|
|
4505
|
+
rendering fault rather than as restraint.
|
|
4506
|
+
|
|
4507
|
+
That leaves the edge to carry the whole state, and it is enough to: accent against
|
|
4508
|
+
neutral-200 is the same signal the rest of the sheet uses for is-this-one, it lands on the
|
|
4509
|
+
element the pointer is actually over, and it moves no layout. The title's accent came off
|
|
4510
|
+
with it — not because it was objectionable, but because two properties saying one thing is
|
|
4511
|
+
how a hover state grows back into four.
|
|
4512
|
+
|
|
4513
|
+
The edge recolours hubcard-BODY, not the card, and that distinction is the reason this rule
|
|
4514
|
+
was dead for as long as it was. It used to set border-color on [data-terp="hubcard"], the
|
|
4515
|
+
outer <li>, which has no border at all: HubPage puts the visible edge on the inner
|
|
4516
|
+
hubcard-body span. Measured in a browser rather than reasoned about, because no baseline
|
|
4517
|
+
captures a hover — the li computed border 0px none at rest and 0px none in the accent colour
|
|
4518
|
+
on hover, while the shadow and the transform, being on the element that could take them, did
|
|
4519
|
+
apply. So through that whole period the hover was a lift with no edge, the exact inverse of
|
|
4520
|
+
what it is now.
|
|
4521
|
+
|
|
4522
|
+
THE ESCALATION IS GONE, and this file was the condition for it. hubcard-body's border was
|
|
4523
|
+
declared inline in HubPage, on the very element this selector matches, so no layered rule
|
|
4524
|
+
could reach it at any specificity. That surface takes its base from terp.base now, so layer
|
|
4525
|
+
order alone is enough. The title's colour was the same story and retired the same way; its
|
|
4526
|
+
hover half is gone with the rest of the state, so one of the seven is now moot rather than
|
|
4527
|
+
merely retired. */
|
|
4272
4528
|
[data-terp="hubcard"]:hover [data-terp="hubcard-body"] {
|
|
4273
4529
|
border-color: var(--color-fg-accent);
|
|
4274
4530
|
}
|
|
4275
|
-
[data-terp="hubcard"]:hover [data-terp="hubcard-title"] {
|
|
4276
|
-
color: var(--color-fg-accent);
|
|
4277
|
-
}
|
|
4278
4531
|
|
|
4279
4532
|
/* Which layout is active, expressed as more than a wash. terp.state, and keyed on the
|
|
4280
4533
|
real ARIA attribute — the [data-terp="tab"][aria-selected="true"] precedent — and the
|
|
@@ -4538,14 +4791,18 @@ button[data-terp="input"][data-placeholder="true"] {
|
|
|
4538
4791
|
THE LAST ESCALATION IN THE SHEET IS GONE, and it was the widest. Its
|
|
4539
4792
|
consumers were the three inline transitions left in the package: the shell's
|
|
4540
4793
|
nav-link transition (NAV_LINK_STYLE), the hub card title's (titleTextStyle)
|
|
4541
|
-
and the sidebar's own transition: width. The first
|
|
4542
|
-
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4548
|
-
|
|
4794
|
+
and the sidebar's own transition: width. The first became a rule; the second
|
|
4795
|
+
became a rule and has since gone entirely, with the title's hover colour that
|
|
4796
|
+
was its only reason to exist; the third was the documented escape — the aside
|
|
4797
|
+
carried no marker, so nothing here matched it and a reduced-motion user
|
|
4798
|
+
watched the rail animate — and it is closed by the sidebar taking a marker and
|
|
4799
|
+
its width becoming a rule. With no style attribute left to out-shout, layer
|
|
4800
|
+
order alone wins: terp.motion sits above terp.base and terp.state, so
|
|
4801
|
+
transition: none needs nothing shouted. Measured, not assumed: under
|
|
4802
|
+
prefers-reduced-motion the sidebar, a nav link and a hub card BODY all compute
|
|
4803
|
+
transition-duration 0s. The body rather than the title, and the swap is the
|
|
4804
|
+
point rather than a tidy-up: the title has no transition to suppress any more,
|
|
4805
|
+
so asserting 0s on it would pass against a default and witness nothing. */
|
|
4549
4806
|
@media (prefers-reduced-motion: reduce) {
|
|
4550
4807
|
[data-terp],
|
|
4551
4808
|
[data-terp="appshell-nav"] a,
|
package/src/theme.test.tsx
CHANGED
|
@@ -8,6 +8,7 @@ afterEach(() => {
|
|
|
8
8
|
cleanup();
|
|
9
9
|
window.localStorage.clear();
|
|
10
10
|
document.documentElement.removeAttribute("data-theme");
|
|
11
|
+
document.documentElement.style.removeProperty("color-scheme");
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
describe("ThemeProvider + ThemeToggle", () => {
|
|
@@ -34,6 +35,35 @@ describe("ThemeProvider + ThemeToggle", () => {
|
|
|
34
35
|
expect(window.localStorage.getItem(THEME_STORAGE_KEY)).toBe("dark");
|
|
35
36
|
});
|
|
36
37
|
|
|
38
|
+
it("hands back the pre-paint bootstrap's inline color-scheme", () => {
|
|
39
|
+
// `public/theme-bootstrap.js` stamps the stored palette on <html> before the first paint
|
|
40
|
+
// and declares its appearance inline with it, because in a dev server the token sheet
|
|
41
|
+
// arrives with the bundle and the attribute alone has no palette to paint from. Inline
|
|
42
|
+
// is what makes that work and also what makes it a loan: a style attribute outranks
|
|
43
|
+
// every rule in every layer, so a viewer who loaded on a dark palette and then chose a
|
|
44
|
+
// light one would keep dark scrollbars, a dark caret and a dark select popup for the
|
|
45
|
+
// rest of the session, on a page that is no longer dark.
|
|
46
|
+
document.documentElement.setAttribute("data-theme", "dark");
|
|
47
|
+
document.documentElement.style.colorScheme = "dark";
|
|
48
|
+
window.localStorage.setItem(THEME_STORAGE_KEY, "dark");
|
|
49
|
+
|
|
50
|
+
render(
|
|
51
|
+
<ThemeProvider>
|
|
52
|
+
<ThemeToggle />
|
|
53
|
+
</ThemeProvider>,
|
|
54
|
+
);
|
|
55
|
+
// Taken back on mount, while the palette it described is still the live one — so the
|
|
56
|
+
// token sheet's own per-theme declaration is what governs from here.
|
|
57
|
+
expect(document.documentElement.style.getPropertyValue("color-scheme")).toBe("");
|
|
58
|
+
expect(document.documentElement.getAttribute("data-theme")).toBe("dark");
|
|
59
|
+
|
|
60
|
+
// And it does not come back when the choice changes, which is the case it exists for.
|
|
61
|
+
fireEvent.click(screen.getByRole("button", { name: "Theme" }));
|
|
62
|
+
fireEvent.click(screen.getByRole("menuitemradio", { name: "Light" }));
|
|
63
|
+
expect(document.documentElement.getAttribute("data-theme")).toBe("light");
|
|
64
|
+
expect(document.documentElement.style.getPropertyValue("color-scheme")).toBe("");
|
|
65
|
+
});
|
|
66
|
+
|
|
37
67
|
it("applies a named theme beyond light and dark", () => {
|
|
38
68
|
// The named themes are the reason the semantic token layer exists. They are compiled,
|
|
39
69
|
// contrast-gated and published, and none of that reaches a user unless the control can
|
package/src/theme.tsx
CHANGED
|
@@ -85,6 +85,23 @@ export function ThemeProvider({ defaultTheme = "system", children }: ThemeProvid
|
|
|
85
85
|
} else {
|
|
86
86
|
root.setAttribute("data-theme", theme);
|
|
87
87
|
}
|
|
88
|
+
// And the pre-paint bootstrap's bridge comes back here.
|
|
89
|
+
//
|
|
90
|
+
// A generated app serves `public/theme-bootstrap.js` blocking in the document head, so a
|
|
91
|
+
// stored choice reaches `<html>` before the first paint instead of arriving with this
|
|
92
|
+
// effect — the reason being that the body is empty until React commits, so the browser
|
|
93
|
+
// has already painted a light canvas by the time this runs. That script also declares
|
|
94
|
+
// `color-scheme` INLINE, because the token sheet is imported by the entry point and in a
|
|
95
|
+
// dev server therefore arrives with the bundle: without it the attribute is right and
|
|
96
|
+
// there is still no palette to paint from.
|
|
97
|
+
//
|
|
98
|
+
// Inline is exactly why it has to be given back. A style attribute outranks every rule
|
|
99
|
+
// in every layer, so the value the bootstrap wrote would go on governing the native
|
|
100
|
+
// chrome for the whole session: pick a light palette after loading on a dark one and the
|
|
101
|
+
// scrollbars, the caret and the select popup stay dark, against a page that is not.
|
|
102
|
+
// Removing it hands `color-scheme` back to the theme blocks in the token sheet, which is
|
|
103
|
+
// where it is declared per palette. A no-op on every load after the first.
|
|
104
|
+
root.style.removeProperty("color-scheme");
|
|
88
105
|
}, [theme]);
|
|
89
106
|
|
|
90
107
|
const setTheme = useCallback((next: Theme) => {
|
package/src/tokens.guard.test.ts
CHANGED
|
@@ -134,7 +134,7 @@ const UNREAD_TOKENS: Record<string, string[]> = {
|
|
|
134
134
|
* prose scale.
|
|
135
135
|
*/
|
|
136
136
|
const BARE_TYPE_LITERALS: Record<string, Record<string, number>> = {
|
|
137
|
-
"line-height": { "0": 2, "1": 5, "1.2": 4, "1.25": 7, "1.3":
|
|
137
|
+
"line-height": { "0": 2, "1": 5, "1.2": 4, "1.25": 7, "1.3": 1, "1.4": 3, "1.5": 4 },
|
|
138
138
|
// `inherit` is recorded rather than tokenised, and it is the one value here that is not
|
|
139
139
|
// debt: the sort button in a table header must render the tracking its own `th` sets, and
|
|
140
140
|
// naming a token would pin it to whatever that header uses TODAY. The UA stylesheet resets
|
package/src/useResource.test.tsx
CHANGED
|
@@ -17,6 +17,62 @@ describe("useResource", () => {
|
|
|
17
17
|
expect(result.current.error).toBeNull();
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
it("carries the total when the source hands over the page", async () => {
|
|
21
|
+
// The backend has always sent it -- the Page envelope is {items, total, skip, limit}.
|
|
22
|
+
// The documented recipe unwrapped .items and dropped the rest, so every "showing N of
|
|
23
|
+
// M" re-derived an answer the server had computed.
|
|
24
|
+
const { result } = renderHook(() =>
|
|
25
|
+
useResource<string, string>({ list: async () => ({ items: ["a", "b"], total: 57 }) }),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
29
|
+
|
|
30
|
+
expect(result.current.items).toEqual(["a", "b"]);
|
|
31
|
+
expect(result.current.total).toBe(57);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("leaves the total unknown when the source hands over rows", async () => {
|
|
35
|
+
// Not zero. A source that returns an array has said nothing about how many rows there
|
|
36
|
+
// are, and a screen reading undefined as 0 announces an empty result set over a full
|
|
37
|
+
// page of them.
|
|
38
|
+
const { result } = renderHook(() =>
|
|
39
|
+
useResource<string, string>({ list: async () => ["a", "b"] }),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
43
|
+
|
|
44
|
+
expect(result.current.total).toBeUndefined();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("leaves the total unknown when the page did not count", async () => {
|
|
48
|
+
// The cursor envelope computes the total only on include_total=true, so a page with no
|
|
49
|
+
// total is the ordinary case rather than a malformed one -- and it must not collapse
|
|
50
|
+
// into the same answer as a page of zero rows.
|
|
51
|
+
const { result } = renderHook(() =>
|
|
52
|
+
useResource<string, string>({ list: async () => ({ items: ["a"] }) }),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
await waitFor(() => expect(result.current.loading).toBe(false));
|
|
56
|
+
|
|
57
|
+
expect(result.current.items).toEqual(["a"]);
|
|
58
|
+
expect(result.current.total).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("updates the total on reload", async () => {
|
|
62
|
+
let total = 2;
|
|
63
|
+
const { result } = renderHook(() =>
|
|
64
|
+
useResource<string, string>({ list: async () => ({ items: ["a"], total }) }),
|
|
65
|
+
);
|
|
66
|
+
await waitFor(() => expect(result.current.total).toBe(2));
|
|
67
|
+
|
|
68
|
+
total = 9;
|
|
69
|
+
await act(async () => {
|
|
70
|
+
await result.current.reload();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
expect(result.current.total).toBe(9);
|
|
74
|
+
});
|
|
75
|
+
|
|
20
76
|
it("reloads when a declared dependency changes (in-place route-param navigation)", async () => {
|
|
21
77
|
// A detail view keyed by a route param must refetch when the param changes
|
|
22
78
|
// without a remount — otherwise the previous record's data lingers.
|