@nyt87/ui 0.3.1 → 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.
Files changed (2) hide show
  1. package/dist/styles.css +57 -2
  2. package/package.json +1 -1
package/dist/styles.css CHANGED
@@ -46,6 +46,8 @@
46
46
  .ds-btn--icon-only.ds-btn--sm { width: 2rem; padding: 0; }
47
47
  .ds-btn--icon-only.ds-btn--md { width: 2.5rem; padding: 0; }
48
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%; }
49
51
 
50
52
  .ds-btn--primary { background: var(--accent); color: var(--on-accent); }
51
53
  .ds-btn--primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
@@ -113,6 +115,17 @@
113
115
  .ds-seg--sm .ds-seg__item span { min-height: 1.6rem; padding: 0 var(--space-2); font-size: var(--text-xs); }
114
116
  .ds-seg__item:hover span { color: var(--fg); }
115
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; }
116
129
 
117
130
  /* ---------- Card ---------- */
118
131
  .ds-card { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius-lg); }
@@ -340,6 +353,11 @@ a.ds-tabs__tab { display: inline-flex; align-items: center; text-decoration: non
340
353
  .ds-sheet.ds-sheet--bottom { margin: auto 0 0; width: 100vw; height: fit-content; max-height: 85dvh; }
341
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); }
342
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
+ }
343
361
  @keyframes ds-sheet-up { from { transform: translateY(100%); } }
344
362
  @media (prefers-reduced-motion: reduce) { .ds-sheet--bottom[open] .ds-modal__panel { animation: none; } }
345
363
 
@@ -364,6 +382,11 @@ a.ds-tabs__tab { display: inline-flex; align-items: center; text-decoration: non
364
382
  .ds-chip__action:hover { background: var(--bg-sunken); color: var(--fg); }
365
383
  .ds-chip--pending { border-style: dashed; }
366
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; }
367
390
 
368
391
  /* List rows: a lead (dot or icon), a title with a meta line, and a trailing action or chevron. */
369
392
  .ds-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--border); }
@@ -378,12 +401,30 @@ a.ds-tabs__tab { display: inline-flex; align-items: center; text-decoration: non
378
401
  .ds-list__title { font-weight: 600; overflow-wrap: anywhere; }
379
402
  .ds-list__meta { color: var(--fg-muted); font-size: var(--text-sm); overflow-wrap: anywhere; }
380
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); }
381
414
 
382
415
  /* Tab bar: the bottom navigation of a phone app. The app decides where it sits (usually fixed to the bottom). */
383
416
  .ds-tabbar { display: flex; background: var(--bg-raised); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
384
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; }
385
418
  .ds-tabbar__item .ds-icon { width: 1.5rem; height: 1.5rem; }
386
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; }
387
428
 
388
429
  /* Search field: a text input with a search icon, and a clear button once it has text. */
389
430
  .ds-search { position: relative; display: flex; align-items: center; }
@@ -414,6 +455,20 @@ a.ds-tabs__tab { display: inline-flex; align-items: center; text-decoration: non
414
455
  /* A <dd>: the only valid child of a row besides <dt>. Two classes, to beat ".ds-details dd". */
415
456
  .ds-details .ds-details__action { grid-column: 2; grid-row: 1 / span 2; }
416
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
+
417
472
  /* Colour swatches: a choice of colours as radio buttons. Each swatch sets --ds-swatch. */
418
473
  .ds-swatches { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; padding: 0; border: 0; }
419
474
  .ds-swatch { position: relative; display: inline-flex; align-items: center; justify-content: center; width: var(--tap-min); height: var(--tap-min); cursor: pointer; }
@@ -431,7 +486,7 @@ button.ds-swatch:focus-visible .ds-swatch__dot { outline: 2px solid var(--ring);
431
486
 
432
487
  /* App shell: sidebar + top bar + main. Below 860px the sidebar becomes a drawer opened by .ds-app__toggle (needs @nyt87/ui/menu). */
433
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); }
434
- .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; }
435
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; }
436
491
  .ds-app__title { margin: 0; font-size: var(--text-lg); font-weight: 700; }
437
492
  .ds-app__bar-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
@@ -502,7 +557,7 @@ button.ds-swatch:focus-visible .ds-swatch__dot { outline: 2px solid var(--ring);
502
557
 
503
558
  /* Touch: where the pointer is a finger, controls are at least 44px (--tap-min) tall; ds-btn--lg already is */
504
559
  @media (pointer: coarse) {
505
- .ds-btn--sm, .ds-btn--md, .ds-control, .ds-tabs__tab { min-height: var(--tap-min); }
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); }
506
561
  .ds-btn--icon-only.ds-btn--sm, .ds-btn--icon-only.ds-btn--md { width: var(--tap-min); }
507
562
  .ds-btn--inline { min-height: 0; }
508
563
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nyt87/ui",
3
- "version": "0.3.1",
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",