@keystone-sites/marketing-design-system 1.0.2 → 1.0.4

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/AGENTS.md CHANGED
@@ -90,6 +90,12 @@ files from their own `AGENTS.md`; they never copy them.
90
90
  visible `:focus-visible`, 44px targets, WCAG AA contrast (measured on every
91
91
  theme), `<dialog>` semantics for overlays with focus returned to the opener.
92
92
  Overlays lock scroll only through `lib/scroll-lock.ts`.
93
+ - Loading is a state, never a placeholder value. A slot whose content has
94
+ not arrived renders `primitives/skeleton.tsx` sized to the value it waits
95
+ for (`measure="00"` under the slot's own type, or a drawn `shape`), inside
96
+ a region marked `aria-busy`; the value replaces the skeleton in place, so
97
+ nothing reflows when it lands. A surface never paints "Not run yet", "—",
98
+ `0`, or any interim string while the real value is still loading.
93
99
  - Inline `style` carries only per-instance values the CSS cannot know
94
100
  (a CSS custom property, a color role, a frame index). Anything constant
95
101
  is a class.
package/index.css CHANGED
@@ -52,6 +52,7 @@
52
52
  @import "./primitives/surface.css" layer(primitives);
53
53
  @import "./primitives/prose.css" layer(primitives);
54
54
  @import "./primitives/status.css" layer(primitives);
55
+ @import "./primitives/skeleton.css" layer(primitives);
55
56
  @import "./primitives/tag.css" layer(primitives);
56
57
  @import "./primitives/tabs.css" layer(primitives);
57
58
  @import "./primitives/notice.css" layer(primitives);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keystone-sites/marketing-design-system",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Keystone's marketing design system: tokens, the tick grid, type, primitives, site chrome, and the landing kit. Source-shipped CSS and TSX for Next.js consumers.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -135,6 +135,8 @@
135
135
  "./primitives/prose.css": "./primitives/prose.css",
136
136
  "./primitives/prose": "./primitives/prose.tsx",
137
137
  "./primitives/ramps.css": "./primitives/ramps.css",
138
+ "./primitives/skeleton.css": "./primitives/skeleton.css",
139
+ "./primitives/skeleton": "./primitives/skeleton.tsx",
138
140
  "./primitives/slider.css": "./primitives/slider.css",
139
141
  "./primitives/slider": "./primitives/slider.tsx",
140
142
  "./primitives/slug.css": "./primitives/slug.css",
@@ -0,0 +1,79 @@
1
+ /* Skeleton: a shimmering stand-in the size of the content it waits for.
2
+ A measured skeleton wraps transparent sample text so its box is the
3
+ value's box under the host's type; a drawn one takes its size from the
4
+ host. The shimmer is a highlight sweeping the ground — a background
5
+ position animating, never a colour transition. Reduced motion settles
6
+ it (base.css) as a still block. */
7
+
8
+ /* Designed constants for this file. The colours resolve on the element,
9
+ not on :root, so a themed host (data-theme) supplies its own tokens. */
10
+ :root {
11
+ /* The text line's box inside its line-height, and the short last line. */
12
+ --skeleton-text-h: 0.72em;
13
+ --skeleton-last-line: 62%;
14
+ }
15
+
16
+ .skeleton {
17
+ --skeleton-ground: var(--color-bg-400);
18
+ --skeleton-highlight: var(--color-bg-200);
19
+ display: inline-block;
20
+ vertical-align: middle;
21
+ box-sizing: border-box;
22
+ border-radius: var(--radius-xs);
23
+ color: transparent;
24
+ background-color: var(--skeleton-ground);
25
+ background-image: linear-gradient(
26
+ 90deg,
27
+ var(--skeleton-ground) 0%,
28
+ var(--skeleton-highlight) 50%,
29
+ var(--skeleton-ground) 100%
30
+ );
31
+ background-size: 200% 100%;
32
+ background-position: 200% 0;
33
+ pointer-events: none;
34
+ user-select: none;
35
+ animation: skeleton-shimmer var(--motion-shimmer-duration) var(--motion-shimmer-ease) infinite;
36
+ }
37
+ .skeleton * {
38
+ visibility: hidden;
39
+ }
40
+ /* A text stand-in sits on the line like the glyphs it replaces. */
41
+ .skeleton[data-shape="text"] {
42
+ height: var(--skeleton-text-h);
43
+ min-width: 1ch;
44
+ }
45
+ .skeleton[data-shape="text"] .skeleton-measure {
46
+ display: inline-block;
47
+ height: 0;
48
+ overflow: hidden;
49
+ white-space: pre;
50
+ }
51
+ .skeleton[data-shape="block"] {
52
+ display: block;
53
+ width: 100%;
54
+ height: 100%;
55
+ }
56
+ .skeleton[data-shape="circle"] {
57
+ flex: none;
58
+ border-radius: var(--radius-full);
59
+ }
60
+
61
+ /* Lines of copy: full lines and a short last one, stepped by the line gap. */
62
+ .skeleton-lines {
63
+ display: flex;
64
+ flex-direction: column;
65
+ gap: calc(1lh - var(--skeleton-text-h));
66
+ width: 100%;
67
+ }
68
+ .skeleton-lines > .skeleton {
69
+ width: 100%;
70
+ }
71
+ .skeleton-lines > .skeleton:last-child {
72
+ width: var(--skeleton-last-line);
73
+ }
74
+
75
+ @keyframes skeleton-shimmer {
76
+ to {
77
+ background-position: -200% 0;
78
+ }
79
+ }
@@ -0,0 +1,56 @@
1
+ /** Skeleton: the shimmering stand-in for content that has not arrived.
2
+ *
3
+ * The law: a surface never paints a temporary value while it loads. A
4
+ * value that is not yet known renders as a skeleton the size the value
5
+ * will be, so nothing moves when it lands. Two forms:
6
+ *
7
+ * - **Measured** (`measure`): a text stand-in that sizes itself to a
8
+ * sample of the final value under the host's own type ("00" for a
9
+ * two-digit score, "Not run yet" for the longest label). The sample is
10
+ * transparent; the shimmer paints its box. Mount it exactly where the
11
+ * value will render, with the same `type` classes.
12
+ * - **Drawn** (`shape`): a block, a circle, or `lines` of copy, sized
13
+ * from the host (`width`/`height` on the element or its class) when
14
+ * no sample text exists — an image, a ring, a paragraph.
15
+ *
16
+ * Decorative to assistive technology: the host region carries
17
+ * `aria-busy` while any skeleton is mounted. Reduced motion renders it
18
+ * settled (base.css). Styles live in skeleton.css. */
19
+
20
+ type Shape = "block" | "circle" | "text";
21
+
22
+ interface SkeletonProps {
23
+ /** Sample text the stand-in sizes itself to, under the host's type. */
24
+ measure?: string;
25
+ /** A drawn stand-in with no sample: a block, a circle, or a text line. */
26
+ shape?: Shape;
27
+ /** Drawn lines of copy; the last line runs short, as a paragraph does. */
28
+ lines?: number;
29
+ className?: string;
30
+ }
31
+
32
+ function cx(...parts: Array<string | undefined | false>): string {
33
+ return parts.filter(Boolean).join(" ");
34
+ }
35
+
36
+ export function Skeleton({ measure, shape, lines, className }: SkeletonProps) {
37
+ if (lines && lines > 1) {
38
+ return (
39
+ <span className={cx("skeleton-lines", className)} aria-hidden="true">
40
+ {Array.from({ length: lines }, (_, i) => (
41
+ <span key={i} className="skeleton" data-shape="text" />
42
+ ))}
43
+ </span>
44
+ );
45
+ }
46
+ if (measure !== undefined) {
47
+ return (
48
+ <span className={cx("skeleton", className)} data-shape="text" aria-hidden="true">
49
+ <span className="skeleton-measure">{measure}</span>
50
+ </span>
51
+ );
52
+ }
53
+ return (
54
+ <span className={cx("skeleton", className)} data-shape={shape ?? "block"} aria-hidden="true" />
55
+ );
56
+ }
package/tokens/motion.css CHANGED
@@ -81,6 +81,11 @@
81
81
  /* Inactive carousel images remain translucent so the lattice reads through. */
82
82
  --motion-ghost-opacity: 0.5;
83
83
 
84
+ /* Skeletons shimmer: a highlight sweeps a waiting block's ground at a
85
+ steady pace, until the value it stands in for arrives. */
86
+ --motion-shimmer-duration: 1600ms;
87
+ --motion-shimmer-ease: linear;
88
+
84
89
  /* Two-clock entrances ink quickly and settle more slowly. */
85
90
  --motion-entrance-ring-fade-dur: 700ms;
86
91
  --motion-entrance-ring-move-dur: 900ms;