@nyt87/ui 0.2.7 → 0.3.1

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.
Files changed (2) hide show
  1. package/dist/styles.css +56 -4
  2. 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; }
@@ -55,7 +57,17 @@
55
57
  .ds-btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, var(--fg)); }
56
58
  .ds-btn--danger-outline { background: transparent; color: var(--danger); border-color: currentColor; }
57
59
  .ds-btn--danger-outline:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 10%, transparent); }
58
- .ds-btn:disabled { opacity: 0.5; cursor: not-allowed; }
60
+ /* Link: a text action in a sentence or a table row ("Edit", "Copy"), in the link colour. Quiet danger is a destructive
61
+ row action that reads as text until pointed at or focused ("Remove"); its confirmation dialog carries the red.
62
+ Inline drops the button's height and padding, to sit inside a line of text. */
63
+ .ds-btn--link, .ds-btn--quiet-danger { background: none; padding-inline: var(--space-1); font-weight: 500; }
64
+ .ds-btn--link { color: var(--link); }
65
+ .ds-btn--link:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 0.2em; }
66
+ .ds-btn--quiet-danger { color: var(--fg-muted); }
67
+ .ds-btn--quiet-danger:hover:not(:disabled), .ds-btn--quiet-danger:focus-visible { color: var(--danger); }
68
+ .ds-btn--inline { min-height: 0; padding: 0; font-size: inherit; vertical-align: baseline; }
69
+ /* aria-disabled: looks disabled but still takes the click, so it can say why it can't act */
70
+ .ds-btn:disabled, .ds-btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
59
71
  .ds-btn[aria-busy='true'] { cursor: progress; opacity: 0.8; }
60
72
 
61
73
  /* ---------- Field + controls ---------- */
@@ -149,7 +161,9 @@
149
161
  .ds-tabs__list { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--border); overflow-x: auto; }
150
162
  .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
163
  .ds-tabs__tab:hover { color: var(--fg); }
152
- .ds-tabs__tab[aria-selected='true'] { color: var(--accent-ink); border-bottom-color: var(--accent); }
164
+ .ds-tabs__tab[aria-selected='true'], .ds-tabs__tab[aria-current='page'] { color: var(--accent-ink); border-bottom-color: var(--accent); }
165
+ /* Tabs that go to pages: links with aria-current="page", in a <nav> (no tabs.js) */
166
+ a.ds-tabs__tab { display: inline-flex; align-items: center; text-decoration: none; }
153
167
  .ds-tabs__panel { padding: var(--space-4) 0; }
154
168
 
155
169
  /* ---------- Table ---------- */
@@ -160,6 +174,20 @@
160
174
  .ds-table tbody tr:last-child > * { border-bottom: 0; }
161
175
  .ds-table tbody tr:hover { background: var(--bg-sunken); }
162
176
  .ds-table .ds-num { text-align: right; font-variant-numeric: tabular-nums; }
177
+ /* Wrap: cells wrap and sit at the top, for tables of sentences rather than figures */
178
+ .ds-table--wrap th, .ds-table--wrap td { white-space: normal; vertical-align: top; }
179
+ /* Stack: on a phone each row becomes a block of "label: value" lines, so no column is squeezed or scrolled sideways.
180
+ Give each cell data-label (its column's name); the header row stays for screen readers only. */
181
+ @media (max-width: 40rem) {
182
+ .ds-table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
183
+ .ds-table--stack, .ds-table--stack tbody, .ds-table--stack tr, .ds-table--stack :is(td, th) { display: block; width: 100%; }
184
+ .ds-table--stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
185
+ .ds-table--stack tbody tr:last-child { border-bottom: 0; }
186
+ .ds-table.ds-table--stack :is(td, th) { border: 0; padding: var(--space-1) 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
187
+ .ds-table--stack [data-label] { position: relative; }
188
+ .ds-table.ds-table--stack [data-label] { padding-left: 8rem; }
189
+ .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); }
190
+ }
163
191
  .ds-table__caption { text-align: left; padding: var(--space-3) var(--space-4); font-weight: 700; }
164
192
 
165
193
  /* ---------- Stat ---------- */
@@ -194,7 +222,7 @@
194
222
 
195
223
  /* ---------- Layout helpers ---------- */
196
224
  /* --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-inline: var(--page-gutter); box-sizing: border-box; }
225
+ .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
226
  .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
227
  .ds-skip:focus { top: var(--space-3); }
200
228
 
@@ -267,6 +295,8 @@
267
295
  .ds-section__title { margin: 0 0 var(--space-4); font-size: clamp(var(--text-2xl), 3.5vw, var(--text-3xl)); line-height: var(--leading-tight); }
268
296
 
269
297
  .ds-features { display: grid; gap: var(--space-5) var(--space-6); grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr)); margin: 0; padding: 0; list-style: none; }
298
+ .ds-features__icon { display: inline-grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: var(--space-3); border-radius: var(--radius-md); background: var(--bg-sunken); color: var(--accent-ink); }
299
+ .ds-features__icon > :is(svg, img) { width: 1.75rem; height: 1.75rem; }
270
300
  .ds-features__title { margin: 0 0 var(--space-1); font-size: var(--text-md); line-height: var(--leading-tight); }
271
301
  .ds-features__text { margin: 0; color: var(--fg-muted); line-height: var(--leading-normal); }
272
302
 
@@ -285,6 +315,20 @@
285
315
  .ds-prose > h3 { font-size: var(--text-lg); }
286
316
  .ds-prose > :is(ul, ol):not([class]) { padding-left: 1.25em; }
287
317
  .ds-prose a:not([class]) { color: var(--link); }
318
+ .ds-prose > :is(h2, h3, h4) { scroll-margin-top: var(--space-4); }
319
+ .ds-prose > h4 { margin-top: var(--space-5); font-size: var(--text-md); }
320
+ .ds-prose li + li { margin-top: var(--space-1); }
321
+ /* Markdown output: code, tables, quotes, pictures and rules. Wide blocks scroll on their own, not the page. */
322
+ .ds-prose :not(pre) > code { padding: 0.1em 0.35em; font-family: var(--font-mono); font-size: 0.9em; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 5px; overflow-wrap: break-word; }
323
+ .ds-prose > pre:not([class]) { padding: var(--space-3) var(--space-4); overflow-x: auto; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-md); font-family: var(--font-mono); font-size: var(--text-sm); }
324
+ .ds-prose > table:not([class]) { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: var(--text-sm); }
325
+ .ds-prose > table:not([class]) :is(th, td) { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); text-align: left; vertical-align: top; }
326
+ .ds-prose > table:not([class]) th { background: var(--bg-sunken); }
327
+ .ds-prose > blockquote:not([class]) { padding: var(--space-2) var(--space-4); border-left: 3px solid var(--accent); background: var(--bg-sunken); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
328
+ .ds-prose > blockquote:not([class]) > * { margin: 0; }
329
+ .ds-prose > blockquote:not([class]) > * + * { margin-top: var(--space-2); }
330
+ .ds-prose img:not([class]) { max-width: 100%; height: auto; }
331
+ .ds-prose > hr:not([class]) { border: 0; border-top: 1px solid var(--border); margin-block: var(--space-6); }
288
332
 
289
333
  /* ---------- App kit: phone-first apps (bottom sheet, toast, chips, list rows, tab bar, search, progress, details, swatches) ---------- */
290
334
 
@@ -367,7 +411,8 @@
367
411
  .ds-details__row:last-child { border-bottom: 0; padding-bottom: 0; }
368
412
  .ds-details dt { grid-column: 1; color: var(--fg-muted); font-size: var(--text-sm); }
369
413
  .ds-details dd { grid-column: 1; margin: 0; overflow-wrap: anywhere; }
370
- .ds-details__action { grid-column: 2; grid-row: 1 / span 2; }
414
+ /* A <dd>: the only valid child of a row besides <dt>. Two classes, to beat ".ds-details dd". */
415
+ .ds-details .ds-details__action { grid-column: 2; grid-row: 1 / span 2; }
371
416
 
372
417
  /* Colour swatches: a choice of colours as radio buttons. Each swatch sets --ds-swatch. */
373
418
  .ds-swatches { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; padding: 0; border: 0; }
@@ -454,3 +499,10 @@ button.ds-swatch:focus-visible .ds-swatch__dot { outline: 2px solid var(--ring);
454
499
  .ds-tip:hover .ds-tip__text, .ds-tip:focus-within .ds-tip__text { visibility: visible; opacity: 1; }
455
500
  .ds-tip--below .ds-tip__text { bottom: auto; top: calc(100% + 6px); }
456
501
  @media (prefers-reduced-motion: reduce) { .ds-tip__text { transition: none; } }
502
+
503
+ /* Touch: where the pointer is a finger, controls are at least 44px (--tap-min) tall; ds-btn--lg already is */
504
+ @media (pointer: coarse) {
505
+ .ds-btn--sm, .ds-btn--md, .ds-control, .ds-tabs__tab { min-height: var(--tap-min); }
506
+ .ds-btn--icon-only.ds-btn--sm, .ds-btn--icon-only.ds-btn--md { width: var(--tap-min); }
507
+ .ds-btn--inline { min-height: 0; }
508
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyt87/ui",
3
- "version": "0.2.7",
3
+ "version": "0.3.1",
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.3"
49
+ "@nyt87/tokens": ">=0.1.5"
53
50
  },
54
51
  "scripts": {
55
52
  "build": "tsup && cp src/styles.css dist/styles.css",