@keystone-sites/marketing-design-system 1.0.26 → 2.0.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.
Files changed (204) hide show
  1. package/README.md +47 -67
  2. package/fonts/gt-america-300-italic.woff2 +0 -0
  3. package/fonts/gt-america-300.woff2 +0 -0
  4. package/fonts/gt-america-400-italic.woff2 +0 -0
  5. package/fonts/gt-america-400.woff2 +0 -0
  6. package/fonts/gt-america-500.woff2 +0 -0
  7. package/fonts/gt-america-extended-300.woff2 +0 -0
  8. package/fonts/gt-america-extended-400.woff2 +0 -0
  9. package/fonts/gt-america-extended-500.woff2 +0 -0
  10. package/fonts/gt-america-extended-700.woff2 +0 -0
  11. package/fonts/gt-america-mono-300.woff2 +0 -0
  12. package/fonts/gt-america-mono-500.woff2 +0 -0
  13. package/fonts/pp-kyoto-vf.woff2 +0 -0
  14. package/package.json +46 -203
  15. package/src/base.css +300 -0
  16. package/src/fonts.css +131 -0
  17. package/src/hue.ts +17 -0
  18. package/src/icon.tsx +56 -0
  19. package/src/mark.tsx +14 -0
  20. package/src/motion.ts +123 -0
  21. package/src/parts/chip.css +84 -0
  22. package/src/parts/chip.tsx +40 -0
  23. package/src/parts/composer.css +195 -0
  24. package/src/parts/composer.tsx +220 -0
  25. package/src/parts/cx.ts +2 -0
  26. package/src/parts/faq.css +77 -0
  27. package/src/parts/faq.tsx +25 -0
  28. package/src/parts/footer.css +51 -0
  29. package/src/parts/footer.tsx +27 -0
  30. package/src/parts/nav.css +180 -0
  31. package/src/parts/nav.tsx +101 -0
  32. package/src/parts/photo.css +15 -0
  33. package/src/parts/photo.tsx +24 -0
  34. package/src/parts/plans.css +89 -0
  35. package/src/parts/plans.tsx +56 -0
  36. package/src/parts/prose.css +86 -0
  37. package/src/parts/prose.tsx +49 -0
  38. package/src/parts/shape.css +47 -0
  39. package/src/parts/shape.tsx +68 -0
  40. package/src/parts/split.tsx +49 -0
  41. package/src/parts/stamp.css +85 -0
  42. package/src/parts/stamp.tsx +36 -0
  43. package/src/parts/work-card.css +51 -0
  44. package/src/parts/work-card.tsx +40 -0
  45. package/src/set.css +439 -0
  46. package/src/styles.css +20 -0
  47. package/src/tokens/color.css +471 -0
  48. package/src/tokens/roles.css +12 -0
  49. package/src/tokens/type.css +11 -0
  50. package/src/wordmark.tsx +34 -0
  51. package/AGENTS.md +0 -192
  52. package/assets/media/brand/ks-lockup.svg +0 -13
  53. package/assets/media/brand/ks-logomark.svg +0 -4
  54. package/assets/media/brand/ks-wordmark-inline.svg +0 -13
  55. package/assets/media/brand/ks-wordmark.svg +0 -11
  56. package/assets/media/fonts/gt-standard-standard-vf.woff2 +0 -0
  57. package/assets/media/fonts/pp-kyoto-variable-upright-vf.woff2 +0 -0
  58. package/base.css +0 -113
  59. package/css-vars.d.ts +0 -10
  60. package/grid/engine.css +0 -367
  61. package/grid/field-hash.ts +0 -31
  62. package/grid/field.tsx +0 -48
  63. package/grid/gates.cjs +0 -35
  64. package/grid/region.tsx +0 -97
  65. package/icons.tsx +0 -1282
  66. package/index.css +0 -89
  67. package/lib/autoplay-gate.ts +0 -88
  68. package/lib/focus-trap.ts +0 -42
  69. package/lib/grader.ts +0 -123
  70. package/lib/legal-data.ts +0 -1
  71. package/lib/legal.ts +0 -41
  72. package/lib/noise.tsx +0 -114
  73. package/lib/phone.ts +0 -294
  74. package/lib/render-boundary.tsx +0 -27
  75. package/lib/scroll-lock.ts +0 -25
  76. package/lib/swipe.ts +0 -124
  77. package/lib/use-active-section.ts +0 -43
  78. package/lib/use-count-up.ts +0 -26
  79. package/lib/use-grader-search.ts +0 -143
  80. package/lib/use-popover.ts +0 -30
  81. package/lib/use-video-carousel.ts +0 -271
  82. package/media.ts +0 -558
  83. package/primitives/breadcrumb.css +0 -51
  84. package/primitives/breadcrumb.tsx +0 -46
  85. package/primitives/business-picker.css +0 -135
  86. package/primitives/business-picker.tsx +0 -298
  87. package/primitives/button-inline.css +0 -52
  88. package/primitives/button-inline.tsx +0 -38
  89. package/primitives/buttons.css +0 -551
  90. package/primitives/buttons.tsx +0 -330
  91. package/primitives/case-study-button.css +0 -71
  92. package/primitives/case-study-button.tsx +0 -28
  93. package/primitives/case-study-card.css +0 -318
  94. package/primitives/case-study-card.tsx +0 -116
  95. package/primitives/chip.css +0 -127
  96. package/primitives/chip.tsx +0 -53
  97. package/primitives/closer-row.css +0 -14
  98. package/primitives/closer-row.tsx +0 -22
  99. package/primitives/cta-row.css +0 -41
  100. package/primitives/cta-row.tsx +0 -39
  101. package/primitives/disclosure.css +0 -302
  102. package/primitives/disclosure.tsx +0 -277
  103. package/primitives/faq-question.css +0 -220
  104. package/primitives/faq-question.tsx +0 -55
  105. package/primitives/field.css +0 -279
  106. package/primitives/field.tsx +0 -376
  107. package/primitives/footer-item.css +0 -72
  108. package/primitives/footer-item.tsx +0 -42
  109. package/primitives/glyph-toggle.css +0 -62
  110. package/primitives/glyph-toggle.tsx +0 -42
  111. package/primitives/grader-menu.tsx +0 -84
  112. package/primitives/grader.css +0 -369
  113. package/primitives/grader.tsx +0 -285
  114. package/primitives/keystone-score.css +0 -156
  115. package/primitives/keystone-score.tsx +0 -204
  116. package/primitives/modal.css +0 -194
  117. package/primitives/modal.tsx +0 -204
  118. package/primitives/month-range.css +0 -80
  119. package/primitives/month-range.tsx +0 -183
  120. package/primitives/notice.css +0 -39
  121. package/primitives/notice.tsx +0 -56
  122. package/primitives/persona-card.css +0 -374
  123. package/primitives/persona-card.tsx +0 -74
  124. package/primitives/picture.css +0 -11
  125. package/primitives/picture.tsx +0 -41
  126. package/primitives/plan-card.css +0 -398
  127. package/primitives/plan-card.tsx +0 -153
  128. package/primitives/prose.css +0 -164
  129. package/primitives/prose.tsx +0 -194
  130. package/primitives/ramps.css +0 -77
  131. package/primitives/report-nav.css +0 -382
  132. package/primitives/report-nav.tsx +0 -353
  133. package/primitives/report.css +0 -601
  134. package/primitives/report.tsx +0 -357
  135. package/primitives/skeleton.css +0 -82
  136. package/primitives/skeleton.tsx +0 -56
  137. package/primitives/slider.css +0 -179
  138. package/primitives/slider.tsx +0 -69
  139. package/primitives/slug.css +0 -87
  140. package/primitives/slug.tsx +0 -37
  141. package/primitives/status.css +0 -427
  142. package/primitives/status.tsx +0 -323
  143. package/primitives/strip.css +0 -40
  144. package/primitives/surface.css +0 -88
  145. package/primitives/surface.tsx +0 -100
  146. package/primitives/table.css +0 -227
  147. package/primitives/table.tsx +0 -122
  148. package/primitives/tabs.css +0 -85
  149. package/primitives/tabs.tsx +0 -122
  150. package/primitives/tag.css +0 -46
  151. package/primitives/tag.tsx +0 -33
  152. package/primitives/text.css +0 -127
  153. package/primitives/toc.css +0 -65
  154. package/primitives/toc.tsx +0 -42
  155. package/primitives/tooltip.css +0 -56
  156. package/primitives/tooltip.tsx +0 -103
  157. package/rules/design-system.md +0 -154
  158. package/rules/grid-and-layout.md +0 -166
  159. package/scripts/generate-exports.mjs +0 -61
  160. package/scripts/generate-type-css.mjs +0 -130
  161. package/sections/faq-island.tsx +0 -102
  162. package/sections/faq.css +0 -213
  163. package/sections/faq.tsx +0 -46
  164. package/sections/footer-nav.tsx +0 -95
  165. package/sections/footer-signature.css +0 -223
  166. package/sections/footer-signature.tsx +0 -127
  167. package/sections/footer.css +0 -735
  168. package/sections/footer.tsx +0 -286
  169. package/sections/gallery-overlay.css +0 -213
  170. package/sections/gallery-overlay.tsx +0 -267
  171. package/sections/landing-benefits.css +0 -59
  172. package/sections/landing-benefits.tsx +0 -81
  173. package/sections/landing-closer.css +0 -23
  174. package/sections/landing-closer.tsx +0 -26
  175. package/sections/landing-hero.css +0 -80
  176. package/sections/landing-hero.tsx +0 -69
  177. package/sections/landing-quote.css +0 -19
  178. package/sections/landing-quote.tsx +0 -30
  179. package/sections/landing-sample.ts +0 -66
  180. package/sections/landing.css +0 -45
  181. package/sections/landing.tsx +0 -69
  182. package/sections/load-orchestrator.tsx +0 -43
  183. package/sections/load.css +0 -138
  184. package/sections/nav-desktop.css +0 -530
  185. package/sections/nav-desktop.tsx +0 -155
  186. package/sections/nav-menu.css +0 -57
  187. package/sections/nav-menu.tsx +0 -112
  188. package/sections/nav-mobile.css +0 -571
  189. package/sections/nav-mobile.tsx +0 -222
  190. package/sections/nav.css +0 -127
  191. package/sections/nav.tsx +0 -394
  192. package/sections/site-chat-data.ts +0 -16
  193. package/sections/site-chat-open.tsx +0 -25
  194. package/sections/site-chat.tsx +0 -67
  195. package/site-links.ts +0 -41
  196. package/site.ts +0 -2
  197. package/themes/inverted.css +0 -139
  198. package/tokens/fonts.css +0 -38
  199. package/tokens/motion.css +0 -150
  200. package/tokens/primitives.css +0 -163
  201. package/tokens/semantic.css +0 -159
  202. package/tokens/type-styles.json +0 -145
  203. package/tokens/type.css +0 -1548
  204. package/widgets.css +0 -78
@@ -0,0 +1,84 @@
1
+ /* The Set's button (Figma › The Set › Chiplet): a key with a glyph or a shape before its label. */
2
+
3
+ .ks-chip {
4
+ --chip-bg: var(--stone);
5
+ --chip-fg: #242323;
6
+ display: inline-flex;
7
+ align-items: center;
8
+ gap: var(--key-gap);
9
+ height: var(--key);
10
+ padding-inline: var(--key-pad);
11
+ background: var(--chip-bg);
12
+ color: var(--chip-fg);
13
+ border-radius: 4px;
14
+ font-weight: 500;
15
+ font-size: var(--key-type);
16
+ line-height: 1;
17
+ white-space: nowrap;
18
+ transition:
19
+ background-color 160ms var(--out),
20
+ color 160ms var(--out),
21
+ transform 160ms var(--out),
22
+ box-shadow 160ms var(--out);
23
+ }
24
+ .ks-chip > :where(svg) {
25
+ font-size: var(--key-glyph);
26
+ }
27
+ .ks-chip:where(button, a):hover {
28
+ --chip-bg: color-mix(in oklab, var(--stone) 80%, var(--ink));
29
+ }
30
+ .ks-chip:where(button, a):active {
31
+ transform: translateY(1px);
32
+ }
33
+ .ks-chip[data-variant="pear"] {
34
+ --chip-bg: var(--pear-400);
35
+ --chip-fg: var(--pear-950);
36
+ }
37
+ .ks-chip[data-variant="pear"]:where(button, a):hover {
38
+ --chip-bg: var(--pear-300);
39
+ }
40
+ .ks-chip[data-variant="ink"] {
41
+ --chip-bg: var(--char);
42
+ --chip-fg: var(--text-paper);
43
+ border-radius: 0;
44
+ }
45
+ .ks-chip[data-variant="ink"]:where(button, a):hover {
46
+ --chip-bg: var(--ink);
47
+ }
48
+ .ks-chip[data-variant="white"] {
49
+ --chip-bg: var(--white);
50
+ --chip-fg: var(--ink);
51
+ }
52
+ .ks-chip[data-variant="white"]:where(button, a):hover {
53
+ --chip-bg: var(--canvas);
54
+ }
55
+ .ks-chip[data-variant="hue"] {
56
+ --chip-bg: var(--h-light);
57
+ --chip-fg: var(--h-deep);
58
+ }
59
+ .ks-chip[data-variant="hue"] > .ks-shape {
60
+ color: var(--h-full);
61
+ }
62
+ .ks-chip[data-variant="hue"]:where(button, a):hover {
63
+ --chip-bg: var(--h-mid);
64
+ }
65
+ .ks-chip[data-variant="full"] {
66
+ --chip-bg: var(--h-full);
67
+ --chip-fg: var(--h-ink);
68
+ }
69
+ .ks-chip[data-variant="full"]:where(button, a):hover {
70
+ --chip-bg: var(--h-mid);
71
+ }
72
+ .ks-chip[data-variant="ghost"] {
73
+ --chip-bg: transparent;
74
+ box-shadow: inset 0 0 0 1px var(--line);
75
+ }
76
+ .ks-chip[data-variant="ghost"]:where(button, a):hover {
77
+ --chip-bg: var(--white);
78
+ }
79
+ .ks-chip[data-size="sm"] {
80
+ height: calc(var(--u) * 0.8);
81
+ padding-inline: calc(var(--u) * 0.25) calc(var(--u) * 0.3);
82
+ gap: calc(var(--u) * 0.2);
83
+ font-size: max(12px, calc(var(--u) * 0.325));
84
+ }
@@ -0,0 +1,40 @@
1
+ import type { ButtonHTMLAttributes } from "react";
2
+ import type { Hue } from "../hue";
3
+ import { Icon, type IconName } from "../icon";
4
+ import { cx } from "./cx";
5
+ import { Shape, type ShapeName } from "./shape";
6
+
7
+ type Props = ButtonHTMLAttributes<HTMLButtonElement> & {
8
+ variant?: "stone" | "pear" | "ink" | "white" | "hue" | "full" | "ghost";
9
+ size?: "sm";
10
+ hue?: Hue;
11
+ icon?: IconName;
12
+ shape?: ShapeName;
13
+ };
14
+
15
+ /** The Set's button: a small squared key with an icon or a shape before its label. */
16
+ export function Chip({
17
+ variant = "stone",
18
+ size,
19
+ hue,
20
+ icon,
21
+ shape,
22
+ className,
23
+ children,
24
+ type = "button",
25
+ ...rest
26
+ }: Props) {
27
+ return (
28
+ <button
29
+ type={type}
30
+ className={cx("ks-chip", className)}
31
+ data-variant={variant}
32
+ data-size={size}
33
+ data-hue={hue}
34
+ {...rest}
35
+ >
36
+ {shape ? <Shape name={shape} /> : icon ? <Icon name={icon} /> : null}
37
+ {children}
38
+ </button>
39
+ );
40
+ }
@@ -0,0 +1,195 @@
1
+ /* The composer (Figma › The Set › Composer): a line to ask Keystone on, and its keys. */
2
+
3
+ .ks-composer {
4
+ position: relative;
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: 2px;
8
+ /* A percentage inside min() keeps the composer from holding a phone's column open at 18 cells. */
9
+ width: min(calc(var(--u) * 18), 100%);
10
+ padding: 8px;
11
+ background: var(--white);
12
+ border: 1px solid var(--line);
13
+ border-radius: 12px;
14
+ box-shadow: var(--lift);
15
+ text-align: left;
16
+ transition:
17
+ border-color 200ms var(--out),
18
+ box-shadow 320ms var(--out);
19
+ }
20
+ .ks-composer:focus-within {
21
+ border-color: color-mix(in oklab, var(--line) 50%, var(--ink));
22
+ box-shadow: var(--lift-lg);
23
+ }
24
+ .ks-composer__field {
25
+ position: relative;
26
+ display: block;
27
+ padding: 12px 8px;
28
+ cursor: text;
29
+ }
30
+ .ks-composer__input,
31
+ .ks-composer__ghost {
32
+ font-family: var(--sans);
33
+ font-weight: 400;
34
+ font-size: max(16px, calc(var(--u) * 0.45));
35
+ line-height: 28px;
36
+ letter-spacing: 0;
37
+ }
38
+ /* The line is 18 on 28 as drawn, at any width that isn't a phone's: the rest of the composer is
39
+ set in pixels, so its text doesn't shrink with the cell. */
40
+ @media (min-width: 721px) {
41
+ .ks-composer__input,
42
+ .ks-composer__ghost {
43
+ font-size: 18px;
44
+ }
45
+ }
46
+ /* The caret: 2px of ink (paper on ink). The field's own caret is a hairline its scroll box clips at
47
+ the start of a line, so the field gets a pixel of room either side, and while the line is empty
48
+ a drawn caret stands in for it, on the field rather than the ghost, which clips too. */
49
+ .ks-composer__input {
50
+ display: block;
51
+ width: calc(100% + 2px);
52
+ min-height: 28px;
53
+ max-height: 168px;
54
+ padding: 0 1px;
55
+ margin: 0 -1px;
56
+ border: 0;
57
+ outline: 0;
58
+ resize: none;
59
+ background: transparent;
60
+ color: var(--ink);
61
+ caret-color: var(--ink);
62
+ overflow-y: auto;
63
+ }
64
+ .ks .ks-composer__input:focus-visible {
65
+ outline: 0;
66
+ }
67
+ .ks-composer__ghost {
68
+ position: absolute;
69
+ inset: 12px 8px auto;
70
+ display: flex;
71
+ align-items: flex-start;
72
+ gap: 2px;
73
+ min-height: 28px;
74
+ color: var(--muted);
75
+ pointer-events: none;
76
+ user-select: none;
77
+ white-space: nowrap;
78
+ overflow: hidden;
79
+ }
80
+ .ks-composer:focus-within .ks-composer__field:has(.ks-composer__ghost)::after {
81
+ content: "";
82
+ position: absolute;
83
+ left: 7px;
84
+ top: 14px;
85
+ width: 2px;
86
+ height: 24px;
87
+ background: var(--ink);
88
+ animation: ks-blink 1.1s steps(1) infinite;
89
+ pointer-events: none;
90
+ }
91
+ @keyframes ks-blink {
92
+ 50% {
93
+ opacity: 0;
94
+ }
95
+ }
96
+ .ks-composer__bar {
97
+ display: flex;
98
+ align-items: center;
99
+ justify-content: space-between;
100
+ padding-top: 8px;
101
+ }
102
+ .ks-composer__actions {
103
+ display: flex;
104
+ gap: 8px;
105
+ }
106
+ .ks-iconbtn {
107
+ display: grid;
108
+ place-items: center;
109
+ width: var(--key);
110
+ height: var(--key);
111
+ border-radius: 4px;
112
+ background: var(--paper);
113
+ color: var(--ink);
114
+ font-size: var(--key-icon);
115
+ transition: background-color 120ms var(--out);
116
+ }
117
+ .ks .ks-iconbtn:hover {
118
+ background: var(--stone);
119
+ }
120
+ .ks-send {
121
+ display: grid;
122
+ place-items: center;
123
+ width: var(--key);
124
+ height: var(--key);
125
+ border-radius: 4px;
126
+ background: var(--pear-100);
127
+ color: var(--pear-450);
128
+ font-size: var(--key-icon);
129
+ transition:
130
+ background-color 200ms var(--out),
131
+ color 200ms var(--out),
132
+ transform 120ms var(--out);
133
+ }
134
+ .ks .ks-send:disabled {
135
+ cursor: default;
136
+ }
137
+ .ks-composer[data-ready] .ks-send {
138
+ background: var(--pear-400);
139
+ color: var(--pear-950);
140
+ }
141
+ .ks-composer[data-ready] .ks-send:hover {
142
+ background: var(--pear-300);
143
+ }
144
+ .ks-composer[data-ready] .ks-send:active {
145
+ transform: translateY(1px);
146
+ }
147
+ /* A prompt dropped in from the page: the send key answers. */
148
+ .ks-composer[data-loaded] .ks-send {
149
+ animation: ks-nudge 900ms var(--out) 420ms both;
150
+ }
151
+ @keyframes ks-nudge {
152
+ 0% {
153
+ box-shadow: 0 0 0 0 color-mix(in oklab, var(--pear-400) 70%, transparent);
154
+ }
155
+ 35% {
156
+ transform: scale(1.08);
157
+ }
158
+ 100% {
159
+ box-shadow: 0 0 0 14px transparent;
160
+ transform: scale(1);
161
+ }
162
+ }
163
+ .ks-composer[data-tone="ink"] {
164
+ background: #1f1e1d;
165
+ border-color: #3a3836;
166
+ box-shadow: 0 24px 60px rgb(0 0 0 / 0.5);
167
+ }
168
+ .ks-composer[data-tone="ink"] .ks-composer__input {
169
+ color: var(--text-paper);
170
+ caret-color: var(--text-paper);
171
+ }
172
+ .ks-composer[data-tone="ink"] .ks-composer__ghost {
173
+ color: #a39f93;
174
+ }
175
+ .ks-composer[data-tone="ink"] .ks-iconbtn {
176
+ background: #2c2b29;
177
+ color: var(--text-paper);
178
+ }
179
+ .ks-composer[data-tone="ink"] .ks-iconbtn:hover {
180
+ background: #3a3836;
181
+ }
182
+ .ks-composer[data-tone="ink"] .ks-send {
183
+ background: #343a12;
184
+ color: var(--pear-450);
185
+ }
186
+ .ks-composer[data-tone="ink"][data-ready] .ks-send {
187
+ background: var(--pear-400);
188
+ color: var(--pear-950);
189
+ }
190
+ .ks-composer[data-tone="ink"]:focus-within .ks-composer__field:has(.ks-composer__ghost)::after {
191
+ background: var(--text-paper);
192
+ }
193
+ .ks-composer__field:has(.ks-composer__ghost) .ks-composer__input {
194
+ caret-color: transparent;
195
+ }
@@ -0,0 +1,220 @@
1
+ "use client";
2
+
3
+ import {
4
+ type CSSProperties,
5
+ type ReactNode,
6
+ type RefObject,
7
+ useEffect,
8
+ useLayoutEffect,
9
+ useRef,
10
+ useState,
11
+ } from "react";
12
+ import { prefersReducedMotion } from "../motion";
13
+
14
+ // The composer (Figma › The Set › Composer): a line to ask Keystone on. A prompt chosen anywhere
15
+ // on the page is dropped into it; sending hands it to the page.
16
+
17
+ export type ComposerState = {
18
+ value: string;
19
+ setValue: (value: string) => void;
20
+ /** Drops a prompt in, typed fast, brings the composer into view and readies the send key. */
21
+ load: (prompt: string) => void;
22
+ /** Sends what is in the composer. Nothing happens while it is empty. */
23
+ send: () => void;
24
+ /** Puts the cursor in the composer (and scrolls to it). */
25
+ focus: () => void;
26
+ /** Counts the prompts dropped in; the composer replays its "ready" nudge on each. */
27
+ loaded: number;
28
+ ref: RefObject<HTMLDivElement | null>;
29
+ };
30
+
31
+ /**
32
+ * A composer's state. One per composer on the page; pass it to `<Composer composer={…} />`.
33
+ * `onSend` gets the trimmed prompt and the composer's element.
34
+ */
35
+ export function useComposer({
36
+ onSend,
37
+ }: {
38
+ onSend: (prompt: string, from: HTMLElement | null) => void;
39
+ }): ComposerState {
40
+ const [value, setValue] = useState("");
41
+ const [loaded, setLoaded] = useState(0);
42
+ const ref = useRef<HTMLDivElement>(null);
43
+ const typing = useRef(0);
44
+
45
+ useEffect(
46
+ () => () => {
47
+ cancelAnimationFrame(typing.current);
48
+ },
49
+ [],
50
+ );
51
+
52
+ function bring() {
53
+ const node = ref.current;
54
+ if (!node) return;
55
+ const rect = node.getBoundingClientRect();
56
+ const inView = rect.top >= 72 && rect.bottom <= window.innerHeight - 16;
57
+ if (!inView) {
58
+ const still = prefersReducedMotion();
59
+ // From far off, the page jumps to most of a window short of the composer and glides the
60
+ // rest: a long glide runs every pinned stage between through its parts, and the browser can
61
+ // be left with the composer half painted when it lands.
62
+ const away = rect.top + rect.height / 2 - window.innerHeight / 2;
63
+ if (!still && Math.abs(away) > window.innerHeight * 1.5) {
64
+ window.scrollTo({
65
+ top: window.scrollY + away - Math.sign(away) * window.innerHeight * 0.6,
66
+ behavior: "instant",
67
+ });
68
+ }
69
+ node.scrollIntoView({ block: "center", behavior: still ? "auto" : "smooth" });
70
+ }
71
+ node.querySelector("textarea")?.focus({ preventScroll: true });
72
+ }
73
+
74
+ function load(prompt: string) {
75
+ cancelAnimationFrame(typing.current);
76
+ setLoaded((count) => count + 1);
77
+ bring();
78
+ if (prefersReducedMotion()) {
79
+ setValue(prompt);
80
+ return;
81
+ }
82
+ // Typed in over a third of a second, however long it is: quick enough to feel dropped in,
83
+ // slow enough to be seen arriving.
84
+ const started = performance.now();
85
+ const step = (now: number) => {
86
+ const t = Math.min(1, (now - started) / 360);
87
+ setValue(prompt.slice(0, Math.max(1, Math.round(prompt.length * t))));
88
+ if (t < 1) typing.current = requestAnimationFrame(step);
89
+ };
90
+ typing.current = requestAnimationFrame(step);
91
+ }
92
+
93
+ function send() {
94
+ const prompt = value.trim();
95
+ if (!prompt) return;
96
+ cancelAnimationFrame(typing.current);
97
+ onSend(prompt, ref.current);
98
+ }
99
+
100
+ return { value, setValue, load, send, focus: bring, loaded, ref };
101
+ }
102
+
103
+ type Props = {
104
+ composer: ComposerState;
105
+ /** What the empty line shows. */
106
+ placeholder: ReactNode;
107
+ tone?: "ink";
108
+ className?: string;
109
+ style?: CSSProperties;
110
+ /** Extra controls on the left of the bar, after attach. */
111
+ tools?: ReactNode;
112
+ };
113
+
114
+ export function Composer({ composer, placeholder, tone, className, style, tools }: Props) {
115
+ const { value, setValue, send, loaded, ref } = composer;
116
+ const field = useRef<HTMLTextAreaElement>(null);
117
+ const ready = value.trim() !== "";
118
+
119
+ useLayoutEffect(() => {
120
+ const node = field.current;
121
+ if (!node) return;
122
+ node.style.height = "auto";
123
+ node.style.height = `${node.scrollHeight}px`;
124
+ }, [value]);
125
+
126
+ return (
127
+ <div
128
+ ref={ref}
129
+ className={className ? `ks-composer ${className}` : "ks-composer"}
130
+ style={style}
131
+ data-tone={tone}
132
+ data-ready={ready ? "" : undefined}
133
+ data-loaded={loaded > 0 && ready ? loaded : undefined}
134
+ >
135
+ <label className="ks-composer__field">
136
+ <span className="ks-sr">Ask Keystone</span>
137
+ <textarea
138
+ ref={field}
139
+ className="ks-composer__input"
140
+ rows={1}
141
+ value={value}
142
+ onChange={(event) => {
143
+ setValue(event.target.value);
144
+ }}
145
+ onKeyDown={(event) => {
146
+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
147
+ event.preventDefault();
148
+ send();
149
+ }
150
+ }}
151
+ enterKeyHint="send"
152
+ autoComplete="off"
153
+ spellCheck={false}
154
+ />
155
+ {value === "" ? (
156
+ <span className="ks-composer__ghost" aria-hidden>
157
+ {placeholder}
158
+ </span>
159
+ ) : null}
160
+ </label>
161
+ <div className="ks-composer__bar">
162
+ <div className="ks-composer__actions">
163
+ <span className="ks-iconbtn" aria-hidden>
164
+ <Plus />
165
+ </span>
166
+ {tools}
167
+ </div>
168
+ <div className="ks-composer__actions">
169
+ <span className="ks-iconbtn" aria-hidden>
170
+ <Mic />
171
+ </span>
172
+ {/* Keyed by the count of prompts dropped in, so each replays the send key's nudge. */}
173
+ <button
174
+ key={loaded}
175
+ type="button"
176
+ className="ks-send"
177
+ aria-label="Send to Keystone"
178
+ disabled={!ready}
179
+ onClick={send}
180
+ >
181
+ <Return />
182
+ </button>
183
+ </div>
184
+ </div>
185
+ </div>
186
+ );
187
+ }
188
+
189
+ // The composer's three glyphs, drawn on the 24px grid the Figma file uses.
190
+ const glyph = {
191
+ width: "1em",
192
+ height: "1em",
193
+ viewBox: "0 0 24 24",
194
+ fill: "none",
195
+ stroke: "currentColor",
196
+ strokeWidth: 1.5,
197
+ } as const;
198
+
199
+ function Plus() {
200
+ return (
201
+ <svg {...glyph} aria-hidden>
202
+ <path d="M12 5v14M5 12h14" strokeLinecap="square" />
203
+ </svg>
204
+ );
205
+ }
206
+ function Mic() {
207
+ return (
208
+ <svg {...glyph} aria-hidden>
209
+ <rect x="9" y="3.5" width="6" height="11" rx="3" />
210
+ <path d="M5.5 11.5a6.5 6.5 0 0 0 13 0M12 18v3" strokeLinecap="square" />
211
+ </svg>
212
+ );
213
+ }
214
+ function Return() {
215
+ return (
216
+ <svg {...glyph} aria-hidden>
217
+ <path d="M19 5v9H6M10 9.5 5.5 14l4.5 4.5" strokeLinecap="square" />
218
+ </svg>
219
+ );
220
+ }
@@ -0,0 +1,2 @@
1
+ export const cx = (...names: (string | false | null | undefined)[]) =>
2
+ names.filter(Boolean).join(" ");
@@ -0,0 +1,77 @@
1
+ /* Questions, each opening to its answer; one open at a time. */
2
+
3
+ .ks-faq {
4
+ border-top: 1px solid var(--line);
5
+ }
6
+ .ks-faq details {
7
+ border-bottom: 1px solid var(--line);
8
+ }
9
+ .ks-faq summary {
10
+ display: flex;
11
+ align-items: center;
12
+ justify-content: space-between;
13
+ gap: var(--u);
14
+ min-height: calc(var(--u) * 2);
15
+ padding-block: calc(var(--u) * 0.4);
16
+ cursor: pointer;
17
+ list-style: none;
18
+ font-family: var(--ext);
19
+ font-weight: 500;
20
+ font-size: calc(var(--u) * 0.55);
21
+ line-height: 1.25;
22
+ letter-spacing: -0.01em;
23
+ }
24
+ .ks-faq summary::-webkit-details-marker {
25
+ display: none;
26
+ }
27
+ .ks-faq__sign {
28
+ position: relative;
29
+ width: var(--u);
30
+ height: var(--u);
31
+ flex: none;
32
+ background: var(--white);
33
+ transition: background-color 200ms var(--out);
34
+ }
35
+ .ks-faq__sign::before,
36
+ .ks-faq__sign::after {
37
+ content: "";
38
+ position: absolute;
39
+ left: 50%;
40
+ top: 50%;
41
+ width: 14px;
42
+ height: 1.5px;
43
+ background: var(--ink);
44
+ translate: -50% -50%;
45
+ transition: rotate 320ms var(--out);
46
+ }
47
+ .ks-faq__sign::after {
48
+ rotate: 90deg;
49
+ }
50
+ .ks-faq details[open] .ks-faq__sign {
51
+ background: var(--pear-400);
52
+ }
53
+ .ks-faq details[open] .ks-faq__sign::after {
54
+ rotate: 0deg;
55
+ }
56
+ .ks-faq__answer {
57
+ max-width: 62ch;
58
+ padding-bottom: calc(var(--u) * 0.8);
59
+ font-size: var(--fs-lead);
60
+ line-height: 1.45;
61
+ color: var(--muted);
62
+ }
63
+ @supports (interpolate-size: allow-keywords) {
64
+ .ks-faq details {
65
+ interpolate-size: allow-keywords;
66
+ }
67
+ .ks-faq details::details-content {
68
+ block-size: 0;
69
+ overflow: clip;
70
+ transition:
71
+ block-size 360ms var(--out),
72
+ content-visibility 360ms allow-discrete;
73
+ }
74
+ .ks-faq details[open]::details-content {
75
+ block-size: auto;
76
+ }
77
+ }
@@ -0,0 +1,25 @@
1
+ import type { HTMLAttributes } from "react";
2
+ import { cx } from "./cx";
3
+
4
+ export type Question = { q: string; a: string };
5
+
6
+ /** Questions, each opening to its answer, the first open; opening one closes the rest. */
7
+ export function Faq({
8
+ items,
9
+ className,
10
+ ...rest
11
+ }: HTMLAttributes<HTMLDivElement> & { items: readonly Question[] }) {
12
+ return (
13
+ <div className={cx("ks-faq", className)} {...rest}>
14
+ {items.map((item, index) => (
15
+ <details key={item.q} name="ks-faq" open={index === 0}>
16
+ <summary>
17
+ {item.q}
18
+ <span className="ks-faq__sign" aria-hidden />
19
+ </summary>
20
+ <p className="ks-faq__answer">{item.a}</p>
21
+ </details>
22
+ ))}
23
+ </div>
24
+ );
25
+ }
@@ -0,0 +1,51 @@
1
+ /* A page's foot: the wordmark, large, on ink, with the page's links and small print beside it. */
2
+
3
+ .ks-footer {
4
+ position: relative;
5
+ background: var(--ink);
6
+ color: var(--text-paper);
7
+ }
8
+ .ks-footer__inner {
9
+ display: grid;
10
+ grid-template-columns: 1fr auto;
11
+ align-items: end;
12
+ gap: var(--u);
13
+ padding: calc(var(--u) * 2) var(--u) var(--u);
14
+ }
15
+ .ks-footer__word {
16
+ height: calc(var(--u) * 3);
17
+ width: auto;
18
+ }
19
+ .ks-footer__meta {
20
+ display: grid;
21
+ gap: 6px;
22
+ justify-items: end;
23
+ font-family: var(--mono);
24
+ font-weight: var(--mono-weight);
25
+ font-size: var(--fs-meta);
26
+ color: #a39f93;
27
+ }
28
+ .ks-footer__links {
29
+ display: flex;
30
+ flex-wrap: wrap;
31
+ justify-content: flex-end;
32
+ gap: 6px calc(var(--u) * 0.6);
33
+ color: var(--text-paper);
34
+ }
35
+ .ks-footer__links > * {
36
+ white-space: nowrap;
37
+ }
38
+ @media (max-width: 720px) {
39
+ .ks-footer__inner {
40
+ grid-template-columns: 1fr;
41
+ }
42
+ .ks-footer__meta {
43
+ justify-items: start;
44
+ }
45
+ .ks-footer__links {
46
+ justify-content: flex-start;
47
+ }
48
+ .ks-footer__word {
49
+ height: calc(var(--u) * 1.6);
50
+ }
51
+ }