@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
@@ -1,369 +0,0 @@
1
- /* Grader input state order is load-bearing:
2
- default → hover → focus → active → filled → brown → error. */
3
-
4
-
5
- .grader {
6
- --grader-ring-brown: #f1e9e4;
7
- position: relative; /* the select-menu anchors to the pill */
8
- display: flex;
9
- flex-direction: column;
10
- gap: var(--space-md);
11
- }
12
-
13
- .grader-field {
14
- display: flex;
15
- align-items: center;
16
- box-sizing: border-box;
17
- gap: var(--space-xl);
18
- /* All sizes share one padding scheme. */
19
- padding-inline: var(--space-lg) var(--space-md);
20
- background: var(--color-bg-000);
21
- border: 1px solid var(--_border);
22
- border-radius: var(--radius-full);
23
- box-shadow: 0 0 0 var(--ring-w) var(--_ring);
24
- /* default state palette (teal chrome) */
25
- --_border: var(--color-border-000);
26
- --_ring: var(--color-bg-200);
27
- --_ph: var(--color-text-500);
28
- --_ink: var(--color-text-200);
29
- transition-property: border-color, box-shadow;
30
- transition-duration: var(--motion-hover-duration);
31
- transition-timing-function: var(--motion-hover-ease);
32
- }
33
-
34
- /* Size: `--grader-size` comes from `data-size` or, for `size="inherit"`,
35
- from an ancestor, so a mount can step it per band. The field, its
36
- arrow and the menu read it. Fixed field heights keep type metrics from
37
- changing pill geometry. */
38
- .grader[data-size="lg"] { --grader-size: lg; }
39
- .grader[data-size="md"] { --grader-size: md; }
40
- .grader[data-size="sm"] { --grader-size: sm; }
41
- @container style(--grader-size: lg) {
42
- .grader-field {
43
- height: 56px;
44
- --btn-size: lg;
45
- --font: var(--ts-text-xl-light-font);
46
- --ls: var(--ts-text-xl-light-ls);
47
- --opsz: var(--ts-text-xl-light-opsz);
48
- }
49
- }
50
- @container style(--grader-size: md) {
51
- .grader-field {
52
- height: 48px;
53
- --btn-size: md;
54
- }
55
- }
56
- @container style(--grader-size: sm) {
57
- .grader-field {
58
- height: 44px;
59
- --btn-size: sm;
60
- }
61
- }
62
-
63
- .grader-sparkle {
64
- display: inline-flex;
65
- flex: none;
66
- }
67
-
68
- .grader-field input {
69
- flex: 1;
70
- min-width: 0;
71
- border: 0;
72
- padding: var(--space-none);
73
- background: none;
74
- outline: none;
75
- color: var(--_ink);
76
- }
77
- .grader-field input::placeholder {
78
- color: var(--_ph);
79
- opacity: 1;
80
- transition-property: color;
81
- transition-duration: var(--motion-hover-duration);
82
- transition-timing-function: var(--motion-hover-ease);
83
- }
84
-
85
- /* hover */
86
- @media (hover: hover) {
87
- .grader-field:hover {
88
- --_border: var(--color-teal-250);
89
- --_ring: var(--color-teal-200);
90
- --_ph: var(--color-text-400);
91
- }
92
- }
93
- .grader[data-state="hover"] .grader-field {
94
- --_border: var(--color-teal-250);
95
- --_ring: var(--color-teal-200);
96
- --_ph: var(--color-text-400);
97
- }
98
-
99
- /* focus (field focused, still empty) */
100
- .grader-field:focus-within,
101
- .grader[data-state="focus"] .grader-field {
102
- --_border: var(--color-teal-400);
103
- --_ring: var(--color-teal-300);
104
- --_ph: var(--color-text-400);
105
- }
106
-
107
- /* active (focused with content) */
108
- .grader-field:focus-within:has(input:not(:placeholder-shown)),
109
- .grader[data-state="active"] .grader-field {
110
- --_border: var(--color-teal-300);
111
- --_ring: var(--color-teal-200);
112
- }
113
-
114
- /* filled (content, not focused) */
115
- .grader-field:not(:focus-within):has(input:not(:placeholder-shown)),
116
- .grader[data-state="filled"] .grader-field {
117
- --_border: var(--color-teal-300);
118
- --_ring: var(--color-teal-200);
119
- }
120
-
121
- /* Brown chrome restates each teal state with stronger selectors. */
122
- .grader[data-chrome="brown"] .grader-field {
123
- --_border: var(--color-brown-200);
124
- --_ring: var(--grader-ring-brown);
125
- --_ph: var(--color-brown-500);
126
- --_ink: var(--color-brown-700);
127
- --sparkle-a: var(--color-brown-400);
128
- --sparkle-b: var(--color-brown-600);
129
- }
130
- @media (hover: hover) {
131
- .grader[data-chrome="brown"] .grader-field:hover {
132
- --_border: var(--color-brown-300);
133
- --_ring: var(--color-brown-200);
134
- }
135
- }
136
- .grader[data-chrome="brown"][data-state="hover"] .grader-field {
137
- --_border: var(--color-brown-300);
138
- --_ring: var(--color-brown-200);
139
- }
140
- .grader[data-chrome="brown"] .grader-field:focus-within,
141
- .grader[data-chrome="brown"][data-state="focus"] .grader-field {
142
- --_border: var(--color-brown-300);
143
- --_ring: var(--color-brown-300);
144
- }
145
- .grader[data-chrome="brown"] .grader-field:focus-within:has(input:not(:placeholder-shown)),
146
- .grader[data-chrome="brown"][data-state="active"] .grader-field,
147
- .grader[data-chrome="brown"] .grader-field:not(:focus-within):has(input:not(:placeholder-shown)),
148
- .grader[data-chrome="brown"][data-state="filled"] .grader-field {
149
- --_border: var(--color-brown-300);
150
- --_ring: var(--color-brown-200);
151
- }
152
-
153
- /* The arrow appears disabled while the field is empty. It stays
154
- pressable: a press hands the field the keyboard (grader.tsx). */
155
- .grader-field:has(input:placeholder-shown) .btn-arrow:not(:disabled),
156
- .grader[data-state="default"] .grader-field .btn-arrow:not(:disabled),
157
- .grader[data-state="hover"] .grader-field .btn-arrow:not(:disabled),
158
- .grader[data-state="focus"] .grader-field .btn-arrow:not(:disabled),
159
- .grader[data-state="active"] .grader-field .btn-arrow:not(:disabled) {
160
- background: var(--_bg-disabled);
161
- color: var(--_glyph-disabled);
162
- }
163
-
164
- /* error — must out-specify the :has() filled/active rules above;
165
- those selectors carry :has()/:not() specificity that otherwise
166
- keeps the teal ring. Restate every interactive twin so hover
167
- and focus-within cannot leak teal over red/400 + red/300. */
168
- .grader[data-error] .grader-field,
169
- .grader[data-error] .grader-field:hover,
170
- .grader[data-error] .grader-field:focus-within,
171
- .grader[data-error] .grader-field:focus-within:has(input:not(:placeholder-shown)),
172
- .grader[data-error] .grader-field:not(:focus-within):has(input:not(:placeholder-shown)) {
173
- --_border: var(--color-red-400);
174
- --_ring: var(--color-red-300);
175
- --sparkle-a: var(--color-red-400);
176
- --sparkle-b: var(--color-red-600);
177
- }
178
- .grader[data-error] .grader-field .btn-arrow:not(:disabled) {
179
- background: var(--_bg);
180
- color: var(--_glyph);
181
- }
182
-
183
- /* The box (ks-Grader 64:5612, Index/Search): the field on radius/md, the
184
- ink submit a block inside its 4px inset. lg and md are the pill's
185
- heights (56 · 48); sm is 48 too, the glyph-only submit (226:7862) at
186
- the same 40 as md's — the phone's size, where the words would crowd
187
- the field. The placeholder reads text/lg at md and sm where the pill's
188
- md reads text/md. The design draws the submit in ink while the field
189
- is empty, so the box keeps its chrome there; pressed, it hands the
190
- field the keyboard (grader.tsx). Its resting hover is bg/300's ring on
191
- the resting border, and focus and filled are the pill's. */
192
- .grader[data-shape="box"] .grader-field {
193
- border-radius: var(--radius-md);
194
- padding-inline: var(--space-lg) var(--space-xs);
195
- }
196
- @container style(--grader-size: md) {
197
- .grader[data-shape="box"] .grader-field {
198
- --font: var(--ts-text-lg-light-font);
199
- --ls: var(--ts-text-lg-light-ls);
200
- --opsz: var(--ts-text-lg-light-opsz);
201
- }
202
- }
203
- @container style(--grader-size: sm) {
204
- .grader[data-shape="box"] .grader-field {
205
- height: 48px;
206
- --font: var(--ts-text-lg-light-font);
207
- --ls: var(--ts-text-lg-light-ls);
208
- --opsz: var(--ts-text-lg-light-opsz);
209
- }
210
- }
211
- @media (hover: hover) {
212
- .grader[data-shape="box"]:not([data-error])
213
- .grader-field:not(:focus-within):has(input:placeholder-shown):hover {
214
- --_border: var(--color-border-000);
215
- --_ring: var(--color-bg-300);
216
- }
217
- }
218
- .grader[data-shape="box"][data-state="hover"]:not([data-error]) .grader-field {
219
- --_border: var(--color-border-000);
220
- --_ring: var(--color-bg-300);
221
- }
222
- .grader[data-shape="box"] .grader-field .btn-arrow:not(:disabled):not([data-loading]) {
223
- background: var(--_bg);
224
- color: var(--_glyph);
225
- }
226
-
227
- /* The suggestion menu overlays following content without shifting layout.
228
- It fits its rows; the search hook already caps how many each group shows.
229
- Sections are their own stacking contexts (grid/engine.css), so the one
230
- hosting an open menu rises above the sections that follow it. */
231
- .sec:has(.grader[data-open]) {
232
- z-index: var(--z-raised);
233
- }
234
- .grader-menu {
235
- --_menu-name-font: var(--ts-text-md-medium-font);
236
- --_menu-name-ls: var(--ts-text-md-medium-ls);
237
- --_menu-name-opsz: var(--ts-text-md-medium-opsz);
238
- --_menu-sub-font: var(--ts-text-md-light-font);
239
- --_menu-sub-ls: var(--ts-text-md-light-ls);
240
- --_menu-sub-opsz: var(--ts-text-md-light-opsz);
241
- --_menu-gap: var(--space-md);
242
- position: absolute;
243
- inset-inline: 0;
244
- top: calc(100% + var(--_menu-gap));
245
- z-index: var(--z-raised);
246
- display: flex;
247
- flex-direction: column;
248
- gap: var(--space-xs);
249
- margin: var(--space-none);
250
- padding: var(--space-md);
251
- background: var(--color-bg-000);
252
- border: 1px solid var(--color-border-000);
253
- border-radius: var(--radius-xl);
254
- box-shadow: var(--shadow-hard-square-md);
255
- /* A long result list scrolls inside the menu rather than running
256
- past the viewport. */
257
- max-height: min(22rem, 50dvh);
258
- overflow-y: auto;
259
- }
260
- /* Large pills use a larger menu gap; small pills a smaller menu type. */
261
- @container style(--grader-size: lg) {
262
- .grader-menu { --_menu-gap: var(--space-lg); }
263
- }
264
- @container style(--grader-size: sm) {
265
- .grader-menu {
266
- --_menu-name-font: var(--ts-text-sm-medium-font);
267
- --_menu-name-ls: var(--ts-text-sm-medium-ls);
268
- --_menu-name-opsz: var(--ts-text-sm-medium-opsz);
269
- --_menu-sub-font: var(--ts-text-sm-light-font);
270
- --_menu-sub-ls: var(--ts-text-sm-light-ls);
271
- --_menu-sub-opsz: var(--ts-text-sm-light-opsz);
272
- }
273
- }
274
-
275
- /* the two source groups (Google Places · websites): each a label over
276
- its rows. The label is the system's small caps label (text/nav-label,
277
- the eyebrow the nav and case-study cards carry) in text/400 — the
278
- address ink — padded to the row's inset so it aligns with the names.
279
- Groups sit a full row-gap (8) apart; rows keep their 4. */
280
- .grader-group {
281
- display: flex;
282
- flex-direction: column;
283
- gap: var(--space-xs);
284
- }
285
- .grader-group + .grader-group {
286
- margin-top: var(--space-xs);
287
- }
288
- .grader-group-rows {
289
- display: flex;
290
- flex-direction: column;
291
- gap: var(--space-xs);
292
- margin: var(--space-none);
293
- padding: var(--space-none);
294
- }
295
- .grader-group-label {
296
- display: block;
297
- padding: var(--space-sm) var(--space-md) var(--space-none);
298
- color: var(--color-text-400);
299
- }
300
-
301
- .grader-option {
302
- display: flex;
303
- flex-direction: column;
304
- width: 100%;
305
- min-width: 0;
306
- padding: var(--space-sm) var(--space-md) var(--space-md);
307
- border-radius: var(--radius-xs);
308
- text-align: left;
309
- cursor: pointer;
310
- transition-property: background-color;
311
- transition-duration: var(--motion-hover-duration);
312
- transition-timing-function: var(--motion-hover-ease);
313
- }
314
- .grader-option[data-active] {
315
- background: var(--color-bg-100);
316
- }
317
- @media (hover: hover) {
318
- .grader-option:hover {
319
- background: var(--color-bg-100);
320
- }
321
- }
322
- /* nudge (motion.css): the submit pressed over typed text with no row
323
- picked — the menu shakes side to side once, settling, to point at the
324
- pick to make. grader.tsx drops the attribute on the beat's
325
- animationend. Nothing on the menu paints during the shake, so moving
326
- it is safe (motion.css). */
327
- .grader[data-nudge] .grader-menu {
328
- animation: grader-nudge var(--motion-nudge-duration) var(--motion-nudge-ease);
329
- }
330
- @keyframes grader-nudge {
331
- 20% {
332
- translate: calc(-1 * var(--motion-nudge-distance)) 0;
333
- }
334
- 40% {
335
- translate: var(--motion-nudge-distance) 0;
336
- }
337
- 60% {
338
- translate: calc(var(--motion-nudge-distance) / -2) 0;
339
- }
340
- 80% {
341
- translate: calc(var(--motion-nudge-distance) / 2) 0;
342
- }
343
- }
344
-
345
- .grader-option-name,
346
- .grader-option-sub {
347
- display: block;
348
- overflow: hidden;
349
- white-space: nowrap;
350
- text-overflow: ellipsis;
351
- }
352
- .grader-option-name {
353
- --font: var(--_menu-name-font);
354
- --ls: var(--_menu-name-ls);
355
- --opsz: var(--_menu-name-opsz);
356
- color: var(--color-text-200);
357
- }
358
- .grader-option-sub {
359
- --font: var(--_menu-sub-font);
360
- --ls: var(--_menu-sub-ls);
361
- --opsz: var(--_menu-sub-opsz);
362
- color: var(--color-text-400);
363
- }
364
-
365
- .grader-error {
366
- margin: var(--space-none);
367
- padding-inline: var(--space-xl);
368
- color: var(--color-red-500);
369
- }
@@ -1,285 +0,0 @@
1
- "use client";
2
-
3
- /** Business grader search.
4
- * A no-JS submission still opens the Grader search. With JS, only a
5
- * suggestion the visitor picked — clicked, or highlighted and entered —
6
- * opens the Grader: submitting typed text never takes the top result on
7
- * the visitor's behalf, so an email address or a stray name goes
8
- * nowhere until a business is chosen from the list. A press on the
9
- * submit before then leaves the keyboard in the field — and puts it
10
- * there over an empty one — and shakes the suggestions once, so the
11
- * visitor sees the pick is theirs to make.
12
- * A host that is the Grader itself passes `onChoose` and navigates in place. */
13
-
14
- import { useId, useRef, useState } from "react";
15
- import type { FocusEvent, FormEvent, KeyboardEvent, MouseEvent } from "react";
16
- import { ButtonArrow } from "./buttons";
17
- import { GraderSelectMenu, type GraderMenuLabels } from "./grader-menu";
18
- import { IconSparkle } from "../icons";
19
- import { GRADER_URL, graderScanUrl, type GraderSuggestion } from "../lib/grader";
20
- import { useGraderSearch } from "../lib/use-grader-search";
21
-
22
- /** Grader deep-link parameter used by the no-JS form. */
23
- const FIELD_NAME = "name";
24
- const WINDOW_FEATURES = "noopener,noreferrer";
25
- /** Labels for the two result sources. */
26
- const GROUP_LABELS: GraderMenuLabels = { places: "Google Places", web: "Websites" };
27
-
28
- interface GraderInputProps {
29
- size?: "lg" | "md" | "sm" | "inherit";
30
- chrome?: "teal" | "brown";
31
- /** The pill with its round arrow, or the box (ks-Grader 64:5612) whose
32
- * ink submit draws the submit label as its words from md up. */
33
- shape?: "pill" | "box";
34
- label?: string;
35
- placeholder?: string;
36
- /** The submit control's name: spoken on the pill, drawn on the box. */
37
- submitLabel?: string;
38
- /** The suggestion listbox's accessible name. */
39
- menuLabel?: string;
40
- /** The two group labels inside the menu (Google Places · websites). */
41
- groupLabels?: GraderMenuLabels;
42
- /** Shown when a submit finds no business to grade. */
43
- noMatchMessage?: string;
44
- defaultValue?: string;
45
- forceState?: "hover" | "focus" | "active" | "filled";
46
- /** Handle the chosen business in place instead of opening a new tab. */
47
- onChoose?: (item: GraderSuggestion) => void;
48
- }
49
-
50
- interface ActiveRow {
51
- index: number;
52
- /** The query the index belongs to; a new answer highlights no row. */
53
- resultsFor: string;
54
- }
55
-
56
- /** No row highlighted: a new answer opens with nothing picked. */
57
- const NO_ROW = -1;
58
-
59
- export function GraderInput({
60
- size = "lg",
61
- chrome = "teal",
62
- shape = "pill",
63
- label = "Your business name",
64
- placeholder = "Your business name",
65
- submitLabel = "Grade my site",
66
- menuLabel = "Business suggestions",
67
- groupLabels = GROUP_LABELS,
68
- noMatchMessage = "We couldn’t find that business — choose one of the suggestions.",
69
- defaultValue = "",
70
- forceState,
71
- onChoose,
72
- }: GraderInputProps) {
73
- const baseId = useId();
74
- const listId = `${baseId}-list`;
75
- const errorId = `${baseId}-error`;
76
- const optionId = (index: number) => `${baseId}-opt-${index}`;
77
- const inputRef = useRef<HTMLInputElement>(null);
78
-
79
- const [query, setQuery] = useState(defaultValue);
80
- const [focused, setFocused] = useState(false);
81
- /** Escape hides the menu until the next edit or arrow key. */
82
- const [dismissed, setDismissed] = useState(false);
83
- const [active, setActive] = useState<ActiveRow>({ index: NO_ROW, resultsFor: "" });
84
- const [chosen, setChosen] = useState<GraderSuggestion | null>(null);
85
- const [error, setError] = useState(false);
86
- /** Submitted over typed text with no row picked: the menu shakes once
87
- * to point at the pick to make; cleared when that beat ends. */
88
- const [nudged, setNudged] = useState(false);
89
-
90
- const search = useGraderSearch(query, !chosen);
91
- const trimmed = query.trim();
92
- /** The row the visitor highlighted among the current results, or none. */
93
- const activeIndex =
94
- active.resultsFor === search.resultsFor
95
- ? Math.min(active.index, search.results.length - 1)
96
- : NO_ROW;
97
- const open = focused && !dismissed && !chosen && !error && search.results.length > 0;
98
- const searching = search.status === "loading";
99
- const highlighted = open ? search.results[activeIndex] : undefined;
100
- /** The submit has a business to open: a press scans it. */
101
- const live = highlighted !== undefined || (chosen !== null && chosen.name === trimmed);
102
-
103
- const inPlace = Boolean(onChoose);
104
-
105
- function openGrader(item: GraderSuggestion) {
106
- if (onChoose) onChoose(item);
107
- else window.open(graderScanUrl(item), "_blank", WINDOW_FEATURES);
108
- }
109
-
110
- function choose(item: GraderSuggestion) {
111
- setChosen(item);
112
- setQuery(item.name);
113
- setError(false);
114
- openGrader(item);
115
- }
116
-
117
- /** Enter or the submit button: the chosen or highlighted business opens
118
- * the Grader; typed text alone only shows the suggestions — or says there
119
- * are none — and waits for a pick; an empty field is handed the keyboard. */
120
- function submit() {
121
- if (!trimmed) {
122
- inputRef.current?.focus();
123
- return;
124
- }
125
- if (searching) return;
126
- if (chosen && chosen.name === trimmed) {
127
- openGrader(chosen);
128
- return;
129
- }
130
- if (search.results.length === 0) {
131
- setError(true);
132
- return;
133
- }
134
- if (highlighted) {
135
- choose(highlighted);
136
- return;
137
- }
138
- setDismissed(false);
139
- setNudged(true);
140
- }
141
-
142
- function onSubmit(e: FormEvent<HTMLFormElement>) {
143
- e.preventDefault();
144
- submit();
145
- }
146
-
147
- /** A press on the submit with nothing to open leaves the field focused,
148
- * so the visitor keeps typing — and keeps the keyboard on a phone. */
149
- function onSubmitMouseDown(e: MouseEvent<HTMLElement>) {
150
- if (!live) e.preventDefault();
151
- }
152
-
153
- function onKeyDown(e: KeyboardEvent<HTMLInputElement>) {
154
- if (e.nativeEvent.isComposing) return;
155
- setFocused(true);
156
- const count = search.results.length;
157
- switch (e.key) {
158
- case "ArrowDown":
159
- case "ArrowUp": {
160
- if (chosen) {
161
- // Reopen search on the chosen name with the top row active.
162
- e.preventDefault();
163
- setChosen(null);
164
- setDismissed(false);
165
- return;
166
- }
167
- if (!count) return;
168
- e.preventDefault();
169
- setDismissed(false);
170
- // Down from no row lands on the first; up from none or the first wraps to the last.
171
- const index =
172
- e.key === "ArrowDown"
173
- ? (activeIndex + 1) % count
174
- : activeIndex <= 0
175
- ? count - 1
176
- : activeIndex - 1;
177
- setActive({ index, resultsFor: search.resultsFor });
178
- break;
179
- }
180
- case "Home":
181
- case "End":
182
- if (!open) return;
183
- e.preventDefault();
184
- setActive({ index: e.key === "Home" ? 0 : count - 1, resultsFor: search.resultsFor });
185
- break;
186
- case "Escape":
187
- if (!open) return;
188
- e.preventDefault();
189
- setDismissed(true);
190
- break;
191
- default:
192
- return;
193
- }
194
- }
195
-
196
- function onBlur(e: FocusEvent<HTMLFormElement>) {
197
- // Keep the menu open while focus moves within the form.
198
- if (e.currentTarget.contains(e.relatedTarget)) return;
199
- setFocused(false);
200
- }
201
-
202
- return (
203
- <form
204
- className="grader"
205
- data-size={size === "inherit" ? undefined : size}
206
- data-chrome={chrome}
207
- data-shape={shape}
208
- data-error={error ? "" : undefined}
209
- data-state={forceState}
210
- data-open={open || undefined}
211
- data-nudge={nudged || undefined}
212
- action={`${GRADER_URL}/`}
213
- method="get"
214
- target={inPlace ? undefined : "_blank"}
215
- onSubmit={onSubmit}
216
- onFocus={() => setFocused(true)}
217
- onBlur={onBlur}
218
- onAnimationEnd={(e) => {
219
- if (e.animationName === "grader-nudge") setNudged(false);
220
- }}
221
- >
222
- <div className="grader-field ts-text-md-light">
223
- <span className="grader-sparkle">
224
- <IconSparkle />
225
- </span>
226
- <input
227
- ref={inputRef}
228
- className="type type-fixed"
229
- type="text"
230
- name={FIELD_NAME}
231
- value={query}
232
- onChange={(e) => {
233
- setQuery(e.target.value);
234
- // Typing also captures fields focused before hydration.
235
- setFocused(true);
236
- setChosen(null);
237
- setDismissed(false);
238
- setError(false);
239
- }}
240
- onKeyDown={onKeyDown}
241
- role="combobox"
242
- aria-label={label}
243
- aria-autocomplete="list"
244
- aria-busy={searching || undefined}
245
- aria-expanded={open}
246
- aria-controls={open ? listId : undefined}
247
- aria-activedescendant={open && activeIndex !== NO_ROW ? optionId(activeIndex) : undefined}
248
- aria-invalid={error || undefined}
249
- aria-describedby={error ? errorId : undefined}
250
- placeholder={placeholder}
251
- autoComplete="off"
252
- autoCorrect="off"
253
- spellCheck={false}
254
- />
255
- <ButtonArrow
256
- type="submit"
257
- size="inherit"
258
- shape={shape}
259
- // The box's submit is ink in every state; the pill's goes gray on error.
260
- chrome={shape === "box" ? "ink" : error ? "gray" : chrome}
261
- loading={searching}
262
- label={submitLabel}
263
- onMouseDown={onSubmitMouseDown}
264
- />
265
- </div>
266
- {open && (
267
- <GraderSelectMenu
268
- id={listId}
269
- label={menuLabel}
270
- groups={search.groups}
271
- groupLabels={groupLabels}
272
- activeIndex={activeIndex}
273
- optionId={optionId}
274
- onActivate={(index) => setActive({ index, resultsFor: search.resultsFor })}
275
- onChoose={choose}
276
- />
277
- )}
278
- {error && (
279
- <p className="type type-fixed ts-text-sm-light grader-error" id={errorId} role="alert">
280
- {noMatchMessage}
281
- </p>
282
- )}
283
- </form>
284
- );
285
- }