@nyt87/ui 0.3.0 → 0.3.2
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/dist/styles.css +94 -4
- package/package.json +2 -5
package/dist/styles.css
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
/* ---------- Icons (the sprite and helper come from @nyt87/icons) ---------- */
|
|
23
23
|
.ds-icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.25em; }
|
|
24
|
+
/* The browser hides [hidden] HTML elements only, not SVG ones, so a button that swaps two icons needs this. */
|
|
25
|
+
.ds-icon[hidden] { display: none; }
|
|
24
26
|
.ds-icon--sm { width: 1rem; height: 1rem; }
|
|
25
27
|
.ds-icon--lg { width: 1.5rem; height: 1.5rem; }
|
|
26
28
|
.ds-icon--xl { width: 2rem; height: 2rem; }
|
|
@@ -44,6 +46,8 @@
|
|
|
44
46
|
.ds-btn--icon-only.ds-btn--sm { width: 2rem; padding: 0; }
|
|
45
47
|
.ds-btn--icon-only.ds-btn--md { width: 2.5rem; padding: 0; }
|
|
46
48
|
.ds-btn--icon-only.ds-btn--lg { width: var(--tap-min); padding: 0; }
|
|
49
|
+
/* Block: the full width of its container, for the one main action at the foot of a phone screen or a sheet */
|
|
50
|
+
.ds-btn--block { display: flex; width: 100%; }
|
|
47
51
|
|
|
48
52
|
.ds-btn--primary { background: var(--accent); color: var(--on-accent); }
|
|
49
53
|
.ds-btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
|
|
@@ -55,7 +59,17 @@
|
|
|
55
59
|
.ds-btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, var(--fg)); }
|
|
56
60
|
.ds-btn--danger-outline { background: transparent; color: var(--danger); border-color: currentColor; }
|
|
57
61
|
.ds-btn--danger-outline:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 10%, transparent); }
|
|
58
|
-
|
|
62
|
+
/* Link: a text action in a sentence or a table row ("Edit", "Copy"), in the link colour. Quiet danger is a destructive
|
|
63
|
+
row action that reads as text until pointed at or focused ("Remove"); its confirmation dialog carries the red.
|
|
64
|
+
Inline drops the button's height and padding, to sit inside a line of text. */
|
|
65
|
+
.ds-btn--link, .ds-btn--quiet-danger { background: none; padding-inline: var(--space-1); font-weight: 500; }
|
|
66
|
+
.ds-btn--link { color: var(--link); }
|
|
67
|
+
.ds-btn--link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 0.2em; }
|
|
68
|
+
.ds-btn--quiet-danger { color: var(--fg-muted); }
|
|
69
|
+
.ds-btn--quiet-danger:hover:not(:disabled), .ds-btn--quiet-danger:focus-visible { color: var(--danger); }
|
|
70
|
+
.ds-btn--inline { min-height: 0; padding: 0; font-size: inherit; vertical-align: baseline; }
|
|
71
|
+
/* aria-disabled: looks disabled but still takes the click, so it can say why it can't act */
|
|
72
|
+
.ds-btn:disabled, .ds-btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
|
|
59
73
|
.ds-btn[aria-busy='true'] { cursor: progress; opacity: 0.8; }
|
|
60
74
|
|
|
61
75
|
/* ---------- Field + controls ---------- */
|
|
@@ -101,6 +115,17 @@
|
|
|
101
115
|
.ds-seg--sm .ds-seg__item span { min-height: 1.6rem; padding: 0 var(--space-2); font-size: var(--text-xs); }
|
|
102
116
|
.ds-seg__item:hover span { color: var(--fg); }
|
|
103
117
|
.ds-seg__item input:checked + span { background: var(--bg-raised); color: var(--fg); box-shadow: var(--shadow-sm); }
|
|
118
|
+
/* Or <button aria-pressed> items, when a choice acts at once (a filter): the button is the item, its text the label. */
|
|
119
|
+
button.ds-seg__item { align-items: center; justify-content: center; min-height: 2rem; padding: 0 var(--space-3); font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--fg-muted); background: none; border: 0; }
|
|
120
|
+
button.ds-seg__item:hover { color: var(--fg); }
|
|
121
|
+
button.ds-seg__item[aria-pressed='true'] { background: var(--bg-raised); color: var(--fg); box-shadow: var(--shadow-sm); }
|
|
122
|
+
button.ds-seg__item:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
|
|
123
|
+
/* Block: the full width, the items sharing it. Grid: rows of --ds-seg-cols (3) items, for longer sets. */
|
|
124
|
+
.ds-seg--block { display: flex; width: 100%; }
|
|
125
|
+
.ds-seg--block .ds-seg__item { flex: 1; }
|
|
126
|
+
.ds-seg--block .ds-seg__item span { flex: 1; justify-content: center; }
|
|
127
|
+
.ds-seg--grid { display: grid; grid-template-columns: repeat(var(--ds-seg-cols, 3), minmax(0, 1fr)); width: 100%; }
|
|
128
|
+
.ds-seg--grid .ds-seg__item span { flex: 1; justify-content: center; }
|
|
104
129
|
|
|
105
130
|
/* ---------- Card ---------- */
|
|
106
131
|
.ds-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); }
|
|
@@ -149,7 +174,9 @@
|
|
|
149
174
|
.ds-tabs__list { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
|
|
150
175
|
.ds-tabs__tab { font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--fg-muted); background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: var(--space-3) var(--space-4); min-height: 2.5rem; cursor: pointer; white-space: nowrap; }
|
|
151
176
|
.ds-tabs__tab:hover { color: var(--fg); }
|
|
152
|
-
.ds-tabs__tab[aria-selected='true'] { color: var(--accent-ink); border-bottom-color: var(--accent); }
|
|
177
|
+
.ds-tabs__tab[aria-selected='true'], .ds-tabs__tab[aria-current='page'] { color: var(--accent-ink); border-bottom-color: var(--accent); }
|
|
178
|
+
/* Tabs that go to pages: links with aria-current="page", in a <nav> (no tabs.js) */
|
|
179
|
+
a.ds-tabs__tab { display: inline-flex; align-items: center; text-decoration: none; }
|
|
153
180
|
.ds-tabs__panel { padding: var(--space-4) 0; }
|
|
154
181
|
|
|
155
182
|
/* ---------- Table ---------- */
|
|
@@ -160,6 +187,20 @@
|
|
|
160
187
|
.ds-table tbody tr:last-child > * { border-bottom: 0; }
|
|
161
188
|
.ds-table tbody tr:hover { background: var(--bg-sunken); }
|
|
162
189
|
.ds-table .ds-num { text-align: right; font-variant-numeric: tabular-nums; }
|
|
190
|
+
/* Wrap: cells wrap and sit at the top, for tables of sentences rather than figures */
|
|
191
|
+
.ds-table--wrap th, .ds-table--wrap td { white-space: normal; vertical-align: top; }
|
|
192
|
+
/* Stack: on a phone each row becomes a block of "label: value" lines, so no column is squeezed or scrolled sideways.
|
|
193
|
+
Give each cell data-label (its column's name); the header row stays for screen readers only. */
|
|
194
|
+
@media (max-width: 40rem) {
|
|
195
|
+
.ds-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
196
|
+
.ds-table--stack, .ds-table--stack tbody, .ds-table--stack tr, .ds-table--stack :is(td, th) { display: block; width: 100%; }
|
|
197
|
+
.ds-table--stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
|
|
198
|
+
.ds-table--stack tbody tr:last-child { border-bottom: 0; }
|
|
199
|
+
.ds-table.ds-table--stack :is(td, th) { border: 0; padding: var(--space-1) 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
|
|
200
|
+
.ds-table--stack [data-label] { position: relative; }
|
|
201
|
+
.ds-table.ds-table--stack [data-label] { padding-left: 8rem; }
|
|
202
|
+
.ds-table--stack [data-label]::before { content: attr(data-label); position: absolute; left: 0; top: var(--space-1); width: 7.5rem; font-size: var(--text-xs); font-weight: 600; color: var(--fg-muted); }
|
|
203
|
+
}
|
|
163
204
|
.ds-table__caption { text-align: left; padding: var(--space-3) var(--space-4); font-weight: 700; }
|
|
164
205
|
|
|
165
206
|
/* ---------- Stat ---------- */
|
|
@@ -194,7 +235,7 @@
|
|
|
194
235
|
|
|
195
236
|
/* ---------- Layout helpers ---------- */
|
|
196
237
|
/* --max-width is the width of the content itself; the page gutter sits outside it, so content lines up with page sections. */
|
|
197
|
-
.ds-container { width: 100%; max-width: calc(var(--max-width) + var(--page-gutter) * 2); margin-inline: auto; padding-
|
|
238
|
+
.ds-container { width: 100%; max-width: calc(var(--max-width) + var(--page-gutter) * 2); margin-inline: auto; padding-left: max(var(--page-gutter), env(safe-area-inset-left, 0px)); padding-right: max(var(--page-gutter), env(safe-area-inset-right, 0px)); box-sizing: border-box; }
|
|
198
239
|
.ds-skip { position: absolute; left: var(--space-3); top: -5rem; z-index: 100; padding: var(--space-2) var(--space-4); background: var(--bg-raised); color: var(--fg); border: 2px solid var(--ring); border-radius: var(--radius-md); font-weight: 600; text-decoration: none; }
|
|
199
240
|
.ds-skip:focus { top: var(--space-3); }
|
|
200
241
|
|
|
@@ -312,6 +353,11 @@
|
|
|
312
353
|
.ds-sheet.ds-sheet--bottom { margin: auto 0 0; width: 100vw; height: fit-content; max-height: 85dvh; }
|
|
313
354
|
.ds-sheet.ds-sheet--bottom .ds-modal__panel { height: auto; max-height: 85dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-width: 1px 0 0; padding-bottom: env(safe-area-inset-bottom); }
|
|
314
355
|
.ds-sheet--bottom[open] .ds-modal__panel { animation: ds-sheet-up var(--duration-base) var(--ease); }
|
|
356
|
+
/* Adaptive: a bottom sheet on a phone, a centred dialog of at most 45rem where the screen is wide */
|
|
357
|
+
@media (min-width: 64rem) {
|
|
358
|
+
.ds-sheet--adaptive.ds-sheet--bottom { margin: auto; width: min(45rem, 100vw - 2rem); }
|
|
359
|
+
.ds-sheet--adaptive.ds-sheet--bottom .ds-modal__panel { border-radius: var(--radius-lg); border-width: 1px; padding-bottom: 0; }
|
|
360
|
+
}
|
|
315
361
|
@keyframes ds-sheet-up { from { transform: translateY(100%); } }
|
|
316
362
|
@media (prefers-reduced-motion: reduce) { .ds-sheet--bottom[open] .ds-modal__panel { animation: none; } }
|
|
317
363
|
|
|
@@ -336,6 +382,11 @@
|
|
|
336
382
|
.ds-chip__action:hover { background: var(--bg-sunken); color: var(--fg); }
|
|
337
383
|
.ds-chip--pending { border-style: dashed; }
|
|
338
384
|
.ds-chip--pending .ds-chip__label { color: var(--fg-muted); }
|
|
385
|
+
/* A chip that is itself a button: one that acts (a suggested time), or a toggle with aria-pressed (a pick of several). */
|
|
386
|
+
button.ds-chip { font: inherit; font-size: var(--text-sm); cursor: pointer; padding-right: var(--space-3); }
|
|
387
|
+
button.ds-chip:hover { background: var(--bg-sunken); }
|
|
388
|
+
button.ds-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
|
|
389
|
+
button.ds-chip[aria-pressed='true'] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-raised)); font-weight: 600; }
|
|
339
390
|
|
|
340
391
|
/* List rows: a lead (dot or icon), a title with a meta line, and a trailing action or chevron. */
|
|
341
392
|
.ds-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
|
|
@@ -350,12 +401,30 @@
|
|
|
350
401
|
.ds-list__title { font-weight: 600; overflow-wrap: anywhere; }
|
|
351
402
|
.ds-list__meta { color: var(--fg-muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
|
|
352
403
|
.ds-list__trail { flex: none; display: inline-flex; align-items: center; gap: var(--space-1); color: var(--fg-muted); font-size: var(--text-sm); }
|
|
404
|
+
/* Cards: each row its own bordered card, for lists of things that each carry a state. A tone colours the border
|
|
405
|
+
(1.5px), so the state reads without a badge: ok, warn or danger. */
|
|
406
|
+
.ds-list--cards { display: grid; gap: var(--space-2); border-top: 0; }
|
|
407
|
+
.ds-list--cards .ds-list__item { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md); padding-inline: var(--space-3); }
|
|
408
|
+
.ds-list--cards .ds-list__item:has(> .ds-list__link) { padding: 0; }
|
|
409
|
+
.ds-list--cards .ds-list__link { padding: var(--space-2) var(--space-3); }
|
|
410
|
+
.ds-list__item--ok, .ds-list__item--warn, .ds-list__item--danger { border-width: 1.5px; }
|
|
411
|
+
.ds-list--cards .ds-list__item--ok { border-color: var(--ok); }
|
|
412
|
+
.ds-list--cards .ds-list__item--warn { border-color: var(--warn); }
|
|
413
|
+
.ds-list--cards .ds-list__item--danger { border-color: var(--danger); }
|
|
353
414
|
|
|
354
415
|
/* Tab bar: the bottom navigation of a phone app. The app decides where it sits (usually fixed to the bottom). */
|
|
355
416
|
.ds-tabbar { display: flex; background: var(--bg-raised); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
|
|
356
417
|
.ds-tabbar__item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; min-height: 3.5rem; padding: var(--space-1); color: var(--fg-muted); font-size: var(--text-xs); font-weight: 600; text-decoration: none; }
|
|
357
418
|
.ds-tabbar__item .ds-icon { width: 1.5rem; height: 1.5rem; }
|
|
358
419
|
.ds-tabbar__item[aria-current='page'] { color: var(--accent-ink); }
|
|
420
|
+
/* An item's icon with a count on its corner (wrap the icon and a .ds-count in .ds-tabbar__icon) */
|
|
421
|
+
.ds-tabbar__icon { position: relative; display: inline-flex; }
|
|
422
|
+
|
|
423
|
+
/* Count: a small number on an icon (waiting items, unread comments). Put the number in the item's label too: the
|
|
424
|
+
bubble is aria-hidden. Inside a positioned parent (.ds-tabbar__icon, a ds-btn) it sits on the top-right corner. */
|
|
425
|
+
.ds-count { display: inline-block; min-width: 1.125rem; height: 1.125rem; padding: 0 0.3rem; border-radius: var(--radius-full); background: var(--warn); color: var(--on-status); font-size: 0.75rem; font-weight: 700; line-height: 1.125rem; text-align: center; font-variant-numeric: tabular-nums; box-sizing: border-box; }
|
|
426
|
+
.ds-tabbar__icon .ds-count, .ds-btn .ds-count { position: absolute; top: -0.35rem; right: -0.6rem; }
|
|
427
|
+
.ds-btn:has(> .ds-count) { position: relative; }
|
|
359
428
|
|
|
360
429
|
/* Search field: a text input with a search icon, and a clear button once it has text. */
|
|
361
430
|
.ds-search { position: relative; display: flex; align-items: center; }
|
|
@@ -386,6 +455,20 @@
|
|
|
386
455
|
/* A <dd>: the only valid child of a row besides <dt>. Two classes, to beat ".ds-details dd". */
|
|
387
456
|
.ds-details .ds-details__action { grid-column: 2; grid-row: 1 / span 2; }
|
|
388
457
|
|
|
458
|
+
/* Disclosure: a <details> that opens in place (recent activity, an item's technical key); the summary is the label. */
|
|
459
|
+
.ds-disclosure { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-md); }
|
|
460
|
+
.ds-disclosure > summary { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap-min); padding: 0 var(--space-3); font-weight: 600; cursor: pointer; list-style: none; border-radius: inherit; }
|
|
461
|
+
.ds-disclosure > summary::-webkit-details-marker { display: none; }
|
|
462
|
+
.ds-disclosure > summary::before { content: ''; flex: none; width: 0.45rem; height: 0.45rem; border: solid var(--fg-muted); border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform var(--duration-fast) var(--ease); }
|
|
463
|
+
.ds-disclosure[open] > summary::before { transform: rotate(45deg); }
|
|
464
|
+
.ds-disclosure > summary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
|
|
465
|
+
.ds-disclosure__body { padding: 0 var(--space-3) var(--space-3); }
|
|
466
|
+
@media (prefers-reduced-motion: reduce) { .ds-disclosure > summary::before { transition: none; } }
|
|
467
|
+
|
|
468
|
+
/* Action bar: the screen's main action, fixed to the bottom of a phone screen above the safe area. Leave room under
|
|
469
|
+
the content for it (padding-bottom on the page). */
|
|
470
|
+
.ds-actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; gap: var(--space-2); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); background: var(--bg-raised); border-top: 1px solid var(--border); }
|
|
471
|
+
|
|
389
472
|
/* Colour swatches: a choice of colours as radio buttons. Each swatch sets --ds-swatch. */
|
|
390
473
|
.ds-swatches { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; padding: 0; border: 0; }
|
|
391
474
|
.ds-swatch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: var(--tap-min); height: var(--tap-min); cursor: pointer; }
|
|
@@ -403,7 +486,7 @@ button.ds-swatch:focus-visible .ds-swatch__dot { outline: 2px solid var(--ring);
|
|
|
403
486
|
|
|
404
487
|
/* App shell: sidebar + top bar + main. Below 860px the sidebar becomes a drawer opened by .ds-app__toggle (needs @nyt87/ui/menu). */
|
|
405
488
|
.ds-app { --app-sidebar: 15rem; display: grid; grid-template-columns: var(--app-sidebar) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: 'side bar' 'side main'; min-height: var(--app-height, 100dvh); background: var(--bg); color: var(--fg); }
|
|
406
|
-
.ds-app__sidebar { grid-area: side; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-3); background: var(--bg-raised); border-right: 1px solid var(--border); position: sticky; top: 0; height: var(--app-height, 100dvh); overflow-y: auto; }
|
|
489
|
+
.ds-app__sidebar { grid-area: side; display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-3); background: var(--bg-raised); border-right: 1px solid var(--border); position: sticky; top: 0; height: var(--app-height, 100dvh); overflow-y: auto; box-sizing: border-box; }
|
|
407
490
|
.ds-app__bar { grid-area: bar; display: flex; align-items: center; gap: var(--space-3); min-height: var(--nav-height); padding: 0 var(--space-5); border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 20; }
|
|
408
491
|
.ds-app__title { margin: 0; font-size: var(--text-lg); font-weight: 700; }
|
|
409
492
|
.ds-app__bar-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
|
|
@@ -471,3 +554,10 @@ button.ds-swatch:focus-visible .ds-swatch__dot { outline: 2px solid var(--ring);
|
|
|
471
554
|
.ds-tip:hover .ds-tip__text, .ds-tip:focus-within .ds-tip__text { visibility: visible; opacity: 1; }
|
|
472
555
|
.ds-tip--below .ds-tip__text { bottom: auto; top: calc(100% + 6px); }
|
|
473
556
|
@media (prefers-reduced-motion: reduce) { .ds-tip__text { transition: none; } }
|
|
557
|
+
|
|
558
|
+
/* Touch: where the pointer is a finger, controls are at least 44px (--tap-min) tall; ds-btn--lg already is */
|
|
559
|
+
@media (pointer: coarse) {
|
|
560
|
+
.ds-btn--sm, .ds-btn--md, .ds-control, .ds-tabs__tab, .ds-seg__item span, button.ds-seg__item { min-height: var(--tap-min); }
|
|
561
|
+
.ds-btn--icon-only.ds-btn--sm, .ds-btn--icon-only.ds-btn--md { width: var(--tap-min); }
|
|
562
|
+
.ds-btn--inline { min-height: 0; }
|
|
563
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nyt87/ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Framework-free UI components for nyt87 products: HTML + CSS, with small vanilla behaviours for the interactive parts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,9 +9,6 @@
|
|
|
9
9
|
"url": "git+https://github.com/NYT87/design-system.git",
|
|
10
10
|
"directory": "packages/ui"
|
|
11
11
|
},
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"registry": "https://npm.pkg.github.com"
|
|
14
|
-
},
|
|
15
12
|
"main": "./dist/index.js",
|
|
16
13
|
"types": "./dist/index.d.ts",
|
|
17
14
|
"exports": {
|
|
@@ -49,7 +46,7 @@
|
|
|
49
46
|
"dist"
|
|
50
47
|
],
|
|
51
48
|
"dependencies": {
|
|
52
|
-
"@nyt87/tokens": ">=0.1.
|
|
49
|
+
"@nyt87/tokens": ">=0.1.5"
|
|
53
50
|
},
|
|
54
51
|
"scripts": {
|
|
55
52
|
"build": "tsup && cp src/styles.css dist/styles.css",
|