@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,166 +0,0 @@
1
- # Grid and layout
2
-
3
- > Canonical for every consumer of `@keystone-sites/marketing-design-system`.
4
- > Paths are package-root (`grid/engine.css`, `grid/gates.cjs`). Edit here;
5
- > consumers reference, never copy.
6
-
7
- The engine, painting, hairlines, and lattice alignment live in
8
- `grid/engine.css`. These laws govern on top of them.
9
-
10
- ## The band system
11
-
12
- Five anchors where a design exists and renders exact; four structural gates
13
- at the bands' geometric midpoints, gated by **container queries** on
14
- `.site-root` — never media queries.
15
-
16
- | band | gate (written as) | opens at | anchor | tick `--t` |
17
- |---|---|---|---|---|
18
- | `rm` | — | — | 384 | 32px |
19
- | `rs` | `@container (--rs)` | 470 | 576 | 48px |
20
- | `rt` | `@container (--rt)` | 665 | 768 | 64px |
21
- | `rd1` | `@container (--rd1)` | 860 | 960 | 80px |
22
- | `rd2` | `@container (--rd2)` | 1130 | 1344 | 112px |
23
-
24
- Gates are always written by name — `(--rs)`, `(--rt)`, `(--rd1)`, `(--rd2)`,
25
- and the closed forms `(--below-rs)`, `(--below-rt)`, `(--below-rd1)`,
26
- `(--rt-only)`, `(--rd1-only)` — and resolved by the PostCSS plugin `grid/gates.cjs`; a pixel
27
- width never appears in a container query.
28
-
29
- - The tick is the page container's width ÷ 12, capped at 112px. Base CSS is
30
- the 384 design (mobile-first); each gate overrides upward.
31
- - **Nearest-anchor rendering.** Every width renders the nearest anchor's
32
- design: stretched below its anchor, compressed above the gate. In a
33
- compressed slice the weights collapse to a pure zoom of that anchor, so wrap
34
- counts and designed clearances hold by construction.
35
- - Above 1344 the tick caps, the weights pin at 0/1, and the 1344 design
36
- renders byte-exact at every wider width. The page box (12t) centers on a
37
- whole-pixel offset (`--page-x`); the freed gutters paint the side fields
38
- (`.gf-*`, deterministic server-side hash, never animated). Fixed chrome
39
- carries `--page-x`.
40
- - Three-anchor pages may be designed at 384 · 768 · 1344 only. `rs` renders
41
- the 384 design on its tick; `rd1` derives from the 1344 design unless the
42
- section rules otherwise. A frame drawn later supersedes the derivation.
43
- - JavaScript that needs the band measures the container (ResizeObserver) or
44
- reads computed style — never `matchMedia`.
45
- - Design and acceptance cover all five anchors and one width per structural
46
- slice, scrollbar forced on. The automated grid sweep is only for lattice
47
- contract changes.
48
-
49
- ## The four units
50
-
51
- Every dimension belongs to exactly one unit. Classifying it is the first
52
- decision.
53
-
54
- 1. **Ticks** — structure: column positions, section heights, exposure regions,
55
- component footprints. Written in `--t`; fluid by construction.
56
- 2. **Weights** — text columns: wrap-pinning widths and text-block heights in
57
- flow margins interpolate `calc(var(--wA)*V0 + var(--wB)*V1)` between the
58
- band's anchors.
59
- 3. **Em at anchor ratios** — line-internal spacing: inline gaps, chip paddings
60
- ride the type.
61
- 4. **Material** — fixed px per band: buttons, icons, marks, control inners.
62
- Primitives are material (fixed px per size variant, never band-aware);
63
- sections choose the size variant per band and own each instance's width.
64
-
65
- A px value that secretly encodes ticks, weights, or type is a defect: it breaks
66
- rag, fit, or clearance in the compressed slices. Constants that reference `--t`
67
- or the weights are declared on `.page`, never `:root`.
68
-
69
- ## The grid and type laws
70
-
71
- - **Hold-then-switch.** Type interpolates between a band's two anchors only
72
- when both carry the same structure. At a structural switch, type holds its
73
- last designed value across the band and switches with the structure at the
74
- gate.
75
- - **Size and line-height interpolate; weight and tracking are band
76
- constants**, restated per band.
77
- - **Band constants ride the weights.** A designed value constant across a band
78
- is `calc((var(--wA) + var(--wB)) * V)`, never `Vpx`, so it zooms with the
79
- tick in the compressed slices. Fixed px broke wraps and rail clearance the
80
- day sections met the compressed slices.
81
- - **Line-inclusive content boxes.** A bordered box whose edge lies on exposed
82
- lattice is sized `k·t + 1px`, so its border lands on the line's pixel. A box
83
- sized `k·t` exactly doubles the hairline.
84
- - **The tick wins.** A whole-tick box height governs over its declared padding
85
- sum; slack compresses padding or sits as clear space.
86
- - **Content clears the lattice.** Flowed content never touches a tick line or
87
- another block and keeps at least half a tick of vertical clearance from the
88
- next section or a bottom-anchored block. Copy never silently compresses a
89
- gap and never overlaps a sibling: when it needs more room the frame grows
90
- (see *Flow frames*). **The painted lattice rides the growth**: a region
91
- drawn against content anchors to the edge it belongs to (`gy` from the
92
- section top, `gyb` from the section bottom, both to stretch between them),
93
- so it moves with the frame. A cell left on its drawn row while content
94
- moves is a defect.
95
- - **Derived states.** When design supplies one archetype state, siblings
96
- derive as the smallest whole-tick height that fits their content at the
97
- band's internals; the derivation is written in a comment at the value.
98
- - **Choreographies settle.** A load choreography ends explicitly on the final
99
- beat's `animationend`; band-gated variants re-entering the tree have nothing
100
- to replay.
101
- - **Proportional primitives.** A primitive may be declared proportional (the
102
- pricing button): every interior value is a designed-px-over-anchor-cell
103
- fraction, so a mount that passes the page tick scales the control with the
104
- grid. The tell in Figma: when a set's cells equal the anchor ticks
105
- (32/48/64/80/112), read those px as `1t`.
106
- - **Overlay chrome** (the nav) never participates in a section's tick stack.
107
- - **Audits at rest.** Mid-flight motion may be fractional-tick by design; the
108
- stack-sum, landmark, and exposed-cell clearance audits assert at rest in
109
- every state. A clearance failure is a collision first.
110
- - **Rendered truth over metadata.** Every landmark is verified against
111
- rendered bounds, never Figma metadata `x`/`y`.
112
-
113
- ## Flow frames
114
-
115
- A design fixes every block's rows at its anchor; a render between anchors,
116
- or with longer copy, must not collide. Every section is therefore a **flow
117
- frame**: the designed rows are minimums, and content that needs more room
118
- pushes everything after it down by exactly what it needs.
119
-
120
- - A section, card, or text block declares its designed rows as
121
- `min-height: calc(var(--t) * k)`, never `height`. Media frames and
122
- controls that hold a fixed tick footprint (`k·t` images, buttons, the
123
- system diagram) are **tick blocks** and keep `height`.
124
- - A text block that owns rows uses `.flow-budget` with `--budget` set to
125
- those rows; its trailing half tick is the clearance to the next block and
126
- is slack inside the budget.
127
- - Blocks stack in normal flow: CSS grid (`grid-template-areas`, one row per
128
- designed row band, `minmax(k·t, auto)` rows) or a flex column. A block's
129
- designed offset from the previous block is `margin-top`; a bottom-anchored
130
- block in a frame is `margin-top: auto`, not `position: absolute; bottom`.
131
- A shared-pixel seam is `margin-bottom: -1px` on the flowed box.
132
- - Text wraps inside `max-width`, never a fixed `width`.
133
- - A gap derived by subtraction (a designed top minus the block above, a
134
- tick minus a material row) floors with `max()` at a spacing token. Type
135
- stops zooming below the smallest anchor while the tick keeps shrinking, so
136
- an unfloored derivation goes negative and blocks collide.
137
- - **The flow contract is what the grid checks verify.** At an anchor every
138
- section renders its designed rows exactly — growth at an anchor is a defect
139
- in the section. Between anchors a section may grow by what its copy needs;
140
- every later section moves down by that growth, and the stack sum carries
141
- it. Landmarks inside a grown section are audited at the anchors.
142
- - Regions anchor to the section edge they belong to (`gy`, `gyb`, or both to
143
- stretch); nothing publishes per-content "extra ticks".
144
-
145
- ## Layout must scale — no fragile positioning
146
-
147
- Absolute positioning is acceptable only for: media fills (`inset: 0;
148
- object-fit: cover` in a grid-sized parent); the exposure vocabulary
149
- (`--gx`/`--gy`/`--gyb` ticks); overlay layers (nav chrome, modal backdrops,
150
- decorative pseudo-elements, a menu anchored to its control, a tag hanging off
151
- a card edge); a true escape from document flow (viewport-fixed controls, the
152
- case-study rail). Everything else is normal flow.
153
-
154
- | Anti-pattern | Fix |
155
- |---|---|
156
- | Fixed px coordinates from Figma's ruler | ticks/weights, grid areas or flex order + `margin-top` |
157
- | `position: absolute; top: k·t` on ordinary content | grid row / flow order with a tick `margin-top` |
158
- | `height: k·t` on a section or text frame | `min-height: k·t` (flow frame) |
159
- | Fixed px widths on text containers | `max-width` weight-riding wrap boxes |
160
- | Per-content height overrides (`extraTicks`, breakpoint-specific `height`) | flow frame that grows with its content |
161
- | `line-height: 0` as a spacing hack | flex column + gap |
162
- | Magic gaps | tick or em expressions per the four units |
163
- | Media queries for band switches | container queries at the gates |
164
-
165
- Always: no fixed widths that overflow at 384; touch targets ≥ 44 × 44 px;
166
- no hover-only interactions.
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env node
2
- /** Writes the `exports` map in package.json from the filesystem.
3
- *
4
- * Consumers import extensionless subpaths (`.../grid/field`,
5
- * `.../sections/nav`) and CSS by filename (`.../index.css`). Bundlers and
6
- * TypeScript resolve those through `exports`, so every shipped module and
7
- * stylesheet is listed explicitly; run this after adding or moving a file.
8
- *
9
- * node scripts/generate-exports.mjs
10
- */
11
- import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
12
- import { dirname, join, relative } from "node:path";
13
- import { fileURLToPath } from "node:url";
14
-
15
- const root = join(dirname(fileURLToPath(import.meta.url)), "..");
16
- const pkgPath = join(root, "package.json");
17
- const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
18
-
19
- const DIRS = ["tokens", "grid", "primitives", "sections", "lib", "themes"];
20
- const ROOT_FILES = [
21
- "index.css",
22
- "base.css",
23
- "widgets.css",
24
- "icons.tsx",
25
- "media.ts",
26
- "site.ts",
27
- "site-links.ts",
28
- "css-vars.d.ts",
29
- ];
30
-
31
- const exportsMap = { ".": "./index.css", "./package.json": "./package.json" };
32
-
33
- function add(file) {
34
- const rel = "./" + relative(root, file).split("\\").join("/");
35
- if (rel.endsWith(".d.ts")) return; // ambient augmentation, referenced by path
36
- if (/\.test\.tsx?$/.test(rel)) return; // unit tests stay out of the surface
37
- if (
38
- rel.endsWith(".css") ||
39
- rel.endsWith(".json") ||
40
- rel.endsWith(".js") ||
41
- rel.endsWith(".cjs")
42
- ) {
43
- exportsMap[rel] = rel;
44
- return;
45
- }
46
- const bare = rel.replace(/\.(tsx?|mjs)$/, "");
47
- exportsMap[bare] = rel;
48
- }
49
-
50
- for (const f of ROOT_FILES) add(join(root, f));
51
- for (const d of DIRS) {
52
- const dir = join(root, d);
53
- for (const name of readdirSync(dir).sort()) {
54
- const file = join(dir, name);
55
- if (statSync(file).isFile()) add(file);
56
- }
57
- }
58
-
59
- pkg.exports = exportsMap;
60
- writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
61
- console.log(`exports: ${Object.keys(exportsMap).length} entries`);
@@ -1,130 +0,0 @@
1
- // Generates tokens/type.css from the Figma text-style data.
2
- // Run with: node scripts/generate-type-css.mjs
3
-
4
- import { readFileSync, writeFileSync } from "node:fs";
5
- import { dirname, join } from "node:path";
6
- import { fileURLToPath } from "node:url";
7
-
8
- const root = join(dirname(fileURLToPath(import.meta.url)), "..");
9
- const src = join(root, "tokens/type-styles.json");
10
- const out = join(root, "tokens/type.css");
11
-
12
- const { styles, extracted } = JSON.parse(readFileSync(src, "utf8"));
13
-
14
- const WEIGHTS = {
15
- Thin: 100,
16
- Extralight: 200,
17
- Light: 300,
18
- Regular: 400,
19
- Medium: 500,
20
- Semibold: 600,
21
- };
22
-
23
- // GT Standard sets weight and optical size independently.
24
- const TEXT_OPSZ = {
25
- "3xs": 24,
26
- "2xs": 24,
27
- xs: 24,
28
- "nav-label": 24,
29
- sm: 26,
30
- md: 26,
31
- lg: 26,
32
- xl: 26,
33
- "2xl": 26,
34
- };
35
- const DISPLAY_SANS_OPSZ = {
36
- "2xs": 28,
37
- };
38
-
39
- function weightName(style) {
40
- const [head, ...rest] = style.split(" ");
41
- if (head === "S" || head === "M" || head === "L") return rest.join(" ");
42
- return style;
43
- }
44
-
45
- function gtOpsz(name) {
46
- const [family, step] = name.split("/");
47
- if (family === "text") {
48
- if (!(step in TEXT_OPSZ)) throw new Error(`unknown text step: ${name}`);
49
- return TEXT_OPSZ[step];
50
- }
51
- if (family === "display-sans") {
52
- return DISPLAY_SANS_OPSZ[step] ?? 30;
53
- }
54
- throw new Error(`unknown GT style: ${name}`);
55
- }
56
-
57
- function parseStyle(s) {
58
- const weight = WEIGHTS[weightName(s.style)];
59
- if (!weight) throw new Error(`unknown weight in ${s.name}: ${s.style}`);
60
- if (s.family === "PP Kyoto") {
61
- return { font: "var(--font-serif)", weight, opsz: null };
62
- }
63
- if (s.family !== "GT Standard Standard VF") {
64
- throw new Error(`unknown family: ${s.family}`);
65
- }
66
- return { font: "var(--font-sans)", weight, opsz: gtOpsz(s.name) };
67
- }
68
-
69
- function varBase(name) {
70
- return `--ts-${name.toLowerCase().replaceAll("/", "-").replaceAll("+", "-plus")}`;
71
- }
72
-
73
- function em(percent) {
74
- const n = parseFloat(percent) / 100;
75
- return n === 0 ? "0em" : `${Number(n.toFixed(4))}em`;
76
- }
77
-
78
- const lines = [];
79
- lines.push(`/* Generated typography tokens. Do not edit directly.`);
80
- lines.push(` Source: type-styles.json (Figma text styles, extracted ${extracted}).`);
81
- lines.push(` Regenerate: node scripts/generate-type-css.mjs`);
82
- lines.push(``);
83
- lines.push(` Per style: -font is a CSS font shorthand (weight size/lh family);`);
84
- lines.push(` -fs and -lh are the same size and line-height as unitless design`);
85
- lines.push(` px (for .type ramps: --fs-rm: var(--ts-x-fs)); -ls is letter-spacing;`);
86
- lines.push(` -opsz is the pinned GT Standard optical size; -ps is Figma`);
87
- lines.push(` paragraph spacing; -case is text-transform. Kyoto styles have no`);
88
- lines.push(` -opsz. Consume through the .type class (primitives/text.css),`);
89
- lines.push(` usually via the .ts-<style> class generated below. */`);
90
- lines.push(``);
91
- lines.push(`/* Per-style opsz:`);
92
- lines.push(``);
93
- lines.push(` opsz is set on the variable font directly (not via Figma L/M/S`);
94
- lines.push(` named instances): text 3xs/2xs/xs/nav-label = 24; text sm–2xl`);
95
- lines.push(` = 26; display-sans 2xs = 28; display-sans xs and up = 30. */`);
96
- lines.push(``);
97
- lines.push(`:root {`);
98
-
99
- for (const s of styles) {
100
- const { font, weight, opsz } = parseStyle(s);
101
- const b = varBase(s.name);
102
- lines.push(` ${b}-font: ${weight} ${s.size}px/${s.lh}px ${font};`);
103
- lines.push(` ${b}-fs: ${s.size};`);
104
- lines.push(` ${b}-lh: ${s.lh};`);
105
- lines.push(` ${b}-ls: ${em(s.ls)};`);
106
- if (opsz !== null) lines.push(` ${b}-opsz: ${opsz};`);
107
- if (s.ps) lines.push(` ${b}-ps: ${s.ps}px;`);
108
- if (s.case === "UPPER") lines.push(` ${b}-case: uppercase;`);
109
- }
110
-
111
- lines.push(`}`);
112
- lines.push(``);
113
- lines.push(`/* One class per style. \`type ts-<style>\` is the whole declaration for`);
114
- lines.push(` text that keeps one style; a band that switches style restates the`);
115
- lines.push(` variables in its own @container block, which wins by layer order. */`);
116
- lines.push(``);
117
-
118
- for (const s of styles) {
119
- const { opsz } = parseStyle(s);
120
- const b = varBase(s.name);
121
- const decls = [`--font: var(${b}-font)`, `--ls: var(${b}-ls)`];
122
- if (opsz !== null) decls.push(`--opsz: var(${b}-opsz)`);
123
- if (s.case === "UPPER") decls.push(`--case: var(${b}-case)`);
124
- decls.push(`--fs-rm: var(${b}-fs)`, `--lh-rm: var(${b}-lh)`);
125
- lines.push(`.${b.slice(2)} {`, ...decls.map((d) => ` ${d};`), `}`);
126
- }
127
- lines.push(``);
128
-
129
- writeFileSync(out, lines.join("\n"));
130
- console.log(`wrote ${out} (${styles.length} styles)`);
@@ -1,102 +0,0 @@
1
- "use client";
2
-
3
- /** Single-open FAQ state, content measurement, and rail extension cells. */
4
-
5
- import { useLayoutEffect, useRef, useState, type ReactNode } from "react";
6
- import { FaqQuestion } from "../primitives/faq-question";
7
-
8
- export interface FaqItem {
9
- id: string;
10
- question: string;
11
- answer: ReactNode;
12
- }
13
-
14
- /* The first growth row follows the static rail run in each band. */
15
- const EXT_BANDS = [
16
- { band: "rm", gx: [11], gy0: 15 },
17
- { band: "rs", gx: [11], gy0: 9 },
18
- { band: "rt", gx: [11], gy0: 6 },
19
- { band: "rd1", gx: [11], gy0: 6 },
20
- { band: "rd2", gx: [11], gy0: 6 },
21
- ] as const;
22
-
23
- export function FaqIsland({ items }: { items: readonly FaqItem[] }) {
24
- const listRef = useRef<HTMLUListElement>(null);
25
- const [openId, setOpenId] = useState<string | null>(null);
26
- /** Measured open − closed ticks per item, current band. */
27
- const [extras, setExtras] = useState<number[]>([]);
28
-
29
- useLayoutEffect(() => {
30
- const list = listRef.current;
31
- if (!list) return;
32
- const sec = list.closest<HTMLElement>(".sec");
33
- const rows = [...list.querySelectorAll<HTMLElement>(".fq")];
34
- if (!sec || rows.length === 0) return;
35
- const answers = rows.map((row) => row.querySelector<HTMLElement>(".fq-answer"));
36
-
37
- const measure = () => {
38
- const t = sec.getBoundingClientRect().width / 12;
39
- if (!(t > 0)) return;
40
- const next = rows.map((row, i) => {
41
- const answer = answers[i];
42
- if (!answer) return 0;
43
- const style = getComputedStyle(row);
44
- const closed = parseFloat(style.getPropertyValue("--fq-closed")) || 1;
45
- /* The drawer's margin-top is --fq-gap resolved to px. */
46
- const gap = parseFloat(getComputedStyle(answer).marginTop) || 0;
47
- const contentBottom =
48
- answer.getBoundingClientRect().bottom - row.getBoundingClientRect().top;
49
- /* The smallest whole tick that leaves at least the drawer gap
50
- beneath the answer; mirroring the top pad rounded four-line
51
- answers up a whole tick of air. */
52
- const open = Math.max(closed, Math.ceil((contentBottom + gap - 0.5) / t));
53
- row.style.setProperty("--fq-open", String(open));
54
- row.style.setProperty("--drawer-extra", String(open - closed));
55
- return open - closed;
56
- });
57
- setExtras((prev) =>
58
- prev.length === next.length && prev.every((v, i) => v === next[i]) ? prev : next,
59
- );
60
- };
61
-
62
- /* Re-measure on every tick, band, or height change. */
63
- const ro = new ResizeObserver(measure);
64
- ro.observe(sec);
65
- document.fonts?.ready.then(measure).catch(() => {});
66
- return () => ro.disconnect();
67
- }, []);
68
-
69
- const openIdx = items.findIndex((item) => item.id === openId);
70
- const activeExtra = openIdx >= 0 ? (extras[openIdx] ?? 0) : 0;
71
- const maxExtra = extras.reduce((a, b) => Math.max(a, b), 0);
72
-
73
- return (
74
- <>
75
- <div className="faq-railext" aria-hidden="true">
76
- {EXT_BANDS.map(({ band, gx, gy0 }) =>
77
- gx.flatMap((col) =>
78
- Array.from({ length: maxExtra }, (_, i) => (
79
- <i
80
- key={`${band}-${col}-${i}`}
81
- className={`faq-ext ${band}${i < activeExtra ? " on" : ""}`}
82
- style={{ "--gx": col, "--gy": gy0 + i, "--i": i }}
83
- />
84
- )),
85
- ),
86
- )}
87
- </div>
88
- <ul className="faq-questions" data-landmark="questions" ref={listRef}>
89
- {items.map((item) => (
90
- <FaqQuestion
91
- key={item.id}
92
- id={`faq-${item.id}`}
93
- open={openId === item.id}
94
- onToggle={() => setOpenId((prev) => (prev === item.id ? null : item.id))}
95
- question={item.question}
96
- answer={item.answer}
97
- />
98
- ))}
99
- </ul>
100
- </>
101
- );
102
- }
package/sections/faq.css DELETED
@@ -1,213 +0,0 @@
1
- /* FAQ. 384 (1176:41769): header 11t × 3t over six 2t rows. 768
2
- (1176:41460): header 4t × 6t beside six 1t rows of 7t. 1344
3
- (1161:26591): header 5t beside six 1t rows of 6t. The east rail runs
4
- down column 12; the island extends it as drawers open. */
5
-
6
- .faq-section {
7
- --faq-u: calc(var(--wA) + var(--wB));
8
- width: 100%;
9
- }
10
-
11
- /* Header. */
12
-
13
- /* The header owns its tick rows as a minimum and grows with the heading. */
14
- .faq-header {
15
- border-top: 1px solid var(--color-border-000);
16
- display: flex;
17
- flex-direction: column;
18
- justify-content: center;
19
- box-sizing: border-box;
20
- width: calc(var(--t) * 11);
21
- min-height: calc(var(--t) * 3);
22
- /* The hairline sits inside the designed 18, so the pad gives up its pixel. */
23
- padding: calc(var(--faq-u) * 18 - 1px) 0 calc(var(--faq-u) * 18) calc(var(--t) / 2);
24
- }
25
- @container (--rt) {
26
- .faq-header {
27
- position: absolute;
28
- top: 0;
29
- left: 0;
30
- justify-content: flex-start;
31
- width: calc(var(--t) * 4);
32
- min-height: calc(var(--t) * 6);
33
- padding: 0 0 0 var(--t);
34
- }
35
- }
36
- @container (--rd2) {
37
- .faq-header {
38
- width: calc(var(--t) * 5);
39
- padding: calc(var(--faq-u) * 40) calc(var(--faq-u) * 128) calc(var(--faq-u) * 32) var(--t);
40
- }
41
- }
42
-
43
- /* The 768 heading occupies a centred two-tick sub-box. */
44
- .faq-head-box {
45
- display: contents;
46
- }
47
- @container (--rt) {
48
- .faq-head-box {
49
- display: flex;
50
- align-items: center;
51
- height: calc(var(--t) * 2);
52
- }
53
- }
54
- @container (--rd2) {
55
- .faq-head-box {
56
- display: contents;
57
- }
58
- }
59
-
60
- /* Typography: 24/30 until the 1344 design lifts it to 42/50. */
61
- .faq-head {
62
- margin: var(--space-none);
63
- color: var(--color-text-100);
64
- max-width: calc(var(--faq-u) * 176);
65
- --fs-rt: var(--fs-rm);
66
- --lh-rt: var(--lh-rm);
67
- --fs-rd2: var(--ts-display-serif-md-plus-extralight-fs);
68
- --lh-rd2: var(--ts-display-serif-md-plus-extralight-lh);
69
- --fs-px: calc(var(--faq-u) * var(--fs-band));
70
- --lh-px: calc(var(--faq-u) * var(--lh-band));
71
- }
72
- @container (--rt) {
73
- .faq-head {
74
- max-width: calc(var(--faq-u) * 160);
75
- }
76
- }
77
- @container (--rd2) {
78
- .faq-head {
79
- max-width: calc(var(--faq-u) * 320);
80
- --font: var(--ts-display-serif-md-plus-extralight-font);
81
- --ls: var(--ts-display-serif-md-plus-extralight-ls);
82
- }
83
- }
84
-
85
- /* Questions. */
86
-
87
- .faq-questions {
88
- list-style: none;
89
- margin: var(--space-none);
90
- padding: var(--space-none);
91
- width: calc(var(--t) * 11);
92
- }
93
- @container (--rt) {
94
- .faq-questions {
95
- width: calc(var(--t) * 7);
96
- margin-left: calc(var(--t) * 4);
97
- }
98
- }
99
- @container (--rd2) {
100
- .faq-questions {
101
- width: calc(var(--t) * 6);
102
- margin-left: calc(var(--t) * 5);
103
- }
104
- }
105
-
106
- /* Per-band disclosure geometry. Rows are two ticks at 384 and one from
107
- rs up; rs keeps the 384 type in a one-tick row with tighter padding. */
108
- .faq-section .fq {
109
- width: 100%;
110
- height: calc(var(--t) * 2);
111
- --fq-closed: 2;
112
- --fq-pt: calc(var(--faq-u) * 20);
113
- --fq-pr: calc(var(--faq-u) * 16);
114
- --fq-pb: calc(var(--faq-u) * 20);
115
- --fq-pl: calc(var(--faq-u) * 16);
116
- --fq-qrow: calc(var(--faq-u) * 24);
117
- --fq-gap: calc(var(--faq-u) * 16);
118
- --fq-a-inset: 0px;
119
- --fq-u: var(--faq-u);
120
- --fq-q-f: var(--ts-text-md-light-font);
121
- --fq-q-fs-rm: 16; --fq-q-fs-rd2: 18;
122
- --fq-q-lh-rm: 22; --fq-q-lh-rd2: 26;
123
- --fq-q-ls: var(--ts-text-md-light-ls);
124
- --fq-q-opsz: var(--ts-text-md-light-opsz);
125
- --fq-a-f: var(--ts-text-md-light-font);
126
- --fq-a-fs-rm: 16; --fq-a-fs-rd2: 18;
127
- --fq-a-lh-rm: 22; --fq-a-lh-rd2: 26;
128
- --fq-a-ls: var(--ts-text-md-light-ls);
129
- --fq-a-opsz: var(--ts-text-md-light-opsz);
130
- }
131
- @container (--rs) {
132
- .faq-section .fq {
133
- height: var(--t);
134
- --fq-closed: 1;
135
- --fq-pt: calc(var(--faq-u) * 12);
136
- --fq-pb: calc(var(--faq-u) * 12);
137
- }
138
- }
139
- @container (--rt) {
140
- .faq-section .fq {
141
- --fq-pt: calc(var(--faq-u) * 20);
142
- --fq-pr: calc(var(--faq-u) * 40);
143
- --fq-pb: calc(var(--faq-u) * 20);
144
- --fq-pl: calc(var(--faq-u) * 40);
145
- }
146
- }
147
- @container (--rd2) {
148
- .faq-section .fq {
149
- --fq-pt: calc(var(--faq-u) * 40);
150
- --fq-pb: calc(var(--faq-u) * 40);
151
- --fq-qrow: calc(var(--faq-u) * 32);
152
- --fq-a-inset: calc(var(--faq-u) * 96);
153
- --fq-q-f: var(--ts-text-lg-light-font);
154
- --fq-q-ls: var(--ts-text-lg-light-ls);
155
- --fq-q-opsz: var(--ts-text-lg-light-opsz);
156
- --fq-a-f: var(--ts-text-lg-light-font);
157
- --fq-a-ls: var(--ts-text-lg-light-ls);
158
- --fq-a-opsz: var(--ts-text-lg-light-opsz);
159
- }
160
- }
161
- .faq-section .fq[data-open] {
162
- height: calc(var(--t) * var(--fq-open, var(--fq-closed)));
163
- }
164
-
165
- /* Rail cells extend with drawer growth. */
166
-
167
- .faq-railext {
168
- position: absolute;
169
- inset: 0;
170
- z-index: -1;
171
- pointer-events: none;
172
- }
173
- .faq-ext {
174
- position: absolute;
175
- box-sizing: border-box;
176
- left: calc(var(--t) * var(--gx));
177
- top: calc(var(--t) * var(--gy));
178
- width: calc(var(--t) + 1px);
179
- height: calc(var(--t) + 1px);
180
- border: 1px solid var(--line);
181
- opacity: 0;
182
- transition: opacity var(--motion-drawer-duration) var(--motion-drawer-ease);
183
- }
184
- .faq-ext.on {
185
- opacity: 1;
186
- /* cascade away from the drawer, nearest cell first; close fades with
187
- the collapse — no stagger (the base rule above) */
188
- transition-delay: calc(var(--i) * var(--motion-rail-stagger));
189
- }
190
-
191
- /* Compound band gating. */
192
- .faq-ext.rs,
193
- .faq-ext.rt,
194
- .faq-ext.rd1,
195
- .faq-ext.rd2 {
196
- display: none;
197
- }
198
- @container (--rs) {
199
- .faq-ext.rm { display: none; }
200
- .faq-ext.rs { display: block; }
201
- }
202
- @container (--rt) {
203
- .faq-ext.rs { display: none; }
204
- .faq-ext.rt { display: block; }
205
- }
206
- @container (--rd1) {
207
- .faq-ext.rt { display: none; }
208
- .faq-ext.rd1 { display: block; }
209
- }
210
- @container (--rd2) {
211
- .faq-ext.rd1 { display: none; }
212
- .faq-ext.rd2 { display: block; }
213
- }