@backgold/template-kit 0.0.0-stage → 0.1.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 (340) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/chunk-KOB36GSF.js +62 -0
  4. package/dist/constants-DvTNj4JI.d-Batjcj3Z.d.ts +38 -0
  5. package/dist/content-api-CYeY0vU8.d.ts +849 -0
  6. package/dist/contract/content-api-examples.d.ts +58 -0
  7. package/dist/contract/content-api-examples.js +783 -0
  8. package/dist/contract/content-api.d.ts +2 -0
  9. package/dist/contract/content-api.js +1 -0
  10. package/dist/contract/site-templates.d.ts +252 -0
  11. package/dist/contract/site-templates.js +185 -0
  12. package/package.json +70 -3
  13. package/src/components/EntryCard.astro +35 -0
  14. package/src/components/EventMap.astro +118 -0
  15. package/src/components/EventPage.astro +194 -0
  16. package/src/components/FieldValue.astro +41 -0
  17. package/src/components/LeadingHero.astro +21 -0
  18. package/src/components/NotFound.astro +20 -0
  19. package/src/components/PageSections.astro +47 -0
  20. package/src/components/Prose.astro +18 -0
  21. package/src/components/chrome/Brand.astro +54 -0
  22. package/src/components/chrome/ClosingCall.astro +94 -0
  23. package/src/components/chrome/DonateStrip.astro +61 -0
  24. package/src/components/chrome/FooterColumns.astro +32 -0
  25. package/src/components/chrome/FooterContact.astro +28 -0
  26. package/src/components/chrome/MenuList.astro +45 -0
  27. package/src/components/chrome/ModeToggle.astro +125 -0
  28. package/src/components/chrome/SignedInNotice.astro +53 -0
  29. package/src/components/chrome/SignupBand.astro +12 -0
  30. package/src/components/chrome/TakeoverBanner.astro +56 -0
  31. package/src/components/chrome/VisitorAccount.astro +82 -0
  32. package/src/components/entries/AuthorBox.astro +47 -0
  33. package/src/components/entries/EntryFields.astro +29 -0
  34. package/src/components/entries/EntryHeader.astro +77 -0
  35. package/src/components/entries/ListFrame.astro +126 -0
  36. package/src/components/entries/ListSearch.astro +24 -0
  37. package/src/components/entries/Share.astro +24 -0
  38. package/src/components/entries/course/classroom.astro +26 -0
  39. package/src/components/entries/course/lesson.astro +18 -0
  40. package/src/components/entries/course/section.ts +20 -0
  41. package/src/components/entries/course/syllabus.astro +15 -0
  42. package/src/components/entries/index.ts +77 -0
  43. package/src/components/entries/newsletter/issue.astro +41 -0
  44. package/src/components/entries/newsletter/list.astro +26 -0
  45. package/src/components/entries/podcast/episode.astro +42 -0
  46. package/src/components/entries/podcast/list.astro +36 -0
  47. package/src/components/entries/post/article.astro +31 -0
  48. package/src/components/entries/post/list.astro +85 -0
  49. package/src/components/entries/props.ts +61 -0
  50. package/src/components/entries/video/cards.astro +39 -0
  51. package/src/components/entries/video/grid.astro +15 -0
  52. package/src/components/entries/video/watch.astro +41 -0
  53. package/src/components/live/LivePage.astro +215 -0
  54. package/src/components/live/LocalTime.astro +29 -0
  55. package/src/components/sections/About/books.astro +188 -0
  56. package/src/components/sections/About/credentials.ts +90 -0
  57. package/src/components/sections/About/index.astro +57 -0
  58. package/src/components/sections/About/left.astro +54 -0
  59. package/src/components/sections/About/letter.astro +108 -0
  60. package/src/components/sections/About/portrait.astro +308 -0
  61. package/src/components/sections/Advocacy/compact.astro +14 -0
  62. package/src/components/sections/Advocacy/index.astro +14 -0
  63. package/src/components/sections/Band.astro +39 -0
  64. package/src/components/sections/Blog/feature.astro +176 -0
  65. package/src/components/sections/Blog/index.astro +37 -0
  66. package/src/components/sections/Blog/latest.ts +80 -0
  67. package/src/components/sections/Blog/list.astro +186 -0
  68. package/src/components/sections/Booking/index.astro +139 -0
  69. package/src/components/sections/Booking/list.astro +144 -0
  70. package/src/components/sections/Booking/types.ts +60 -0
  71. package/src/components/sections/Calendar/agenda.astro +14 -0
  72. package/src/components/sections/Calendar/index.astro +14 -0
  73. package/src/components/sections/CandidateRoster/ballot.astro +394 -0
  74. package/src/components/sections/CandidateRoster/candidates.ts +69 -0
  75. package/src/components/sections/CandidateRoster/compact.astro +115 -0
  76. package/src/components/sections/CandidateRoster/index.astro +57 -0
  77. package/src/components/sections/CaseStudies/beforeafter.astro +222 -0
  78. package/src/components/sections/CaseStudies/cases.ts +111 -0
  79. package/src/components/sections/CaseStudies/grid.astro +261 -0
  80. package/src/components/sections/CaseStudies/index.astro +333 -0
  81. package/src/components/sections/Classroom/CourseCard.astro +181 -0
  82. package/src/components/sections/Classroom/Courses.astro +88 -0
  83. package/src/components/sections/Classroom/classroom.ts +141 -0
  84. package/src/components/sections/Classroom/index.astro +20 -0
  85. package/src/components/sections/Classroom/list.astro +15 -0
  86. package/src/components/sections/Collection/compact.astro +7 -0
  87. package/src/components/sections/Collection/entries.ts +62 -0
  88. package/src/components/sections/Collection/feature.astro +180 -0
  89. package/src/components/sections/Collection/index.astro +46 -0
  90. package/src/components/sections/Collection/library.astro +271 -0
  91. package/src/components/sections/Collection/list.astro +7 -0
  92. package/src/components/sections/Collection/outline.astro +134 -0
  93. package/src/components/sections/Collection/shelves.astro +191 -0
  94. package/src/components/sections/Comparison/Unlisted.astro +6 -0
  95. package/src/components/sections/Comparison/cards.astro +171 -0
  96. package/src/components/sections/Comparison/index.astro +191 -0
  97. package/src/components/sections/Comparison/sides.ts +98 -0
  98. package/src/components/sections/Comparison/spectrum.astro +261 -0
  99. package/src/components/sections/ContentPost/banner.astro +152 -0
  100. package/src/components/sections/ContentPost/index.astro +35 -0
  101. package/src/components/sections/ContentPost/lesson.ts +119 -0
  102. package/src/components/sections/ContentPost/player.astro +254 -0
  103. package/src/components/sections/ContentPost/theater.astro +329 -0
  104. package/src/components/sections/Countdown/index.astro +53 -0
  105. package/src/components/sections/Course/Bar.astro +46 -0
  106. package/src/components/sections/Course/CourseHead.astro +123 -0
  107. package/src/components/sections/Course/Crumbs.astro +44 -0
  108. package/src/components/sections/Course/Icon.astro +29 -0
  109. package/src/components/sections/Course/Ring.astro +62 -0
  110. package/src/components/sections/Course/Syllabus.astro +146 -0
  111. package/src/components/sections/Course/course.ts +146 -0
  112. package/src/components/sections/Course/index.astro +143 -0
  113. package/src/components/sections/Course/outline.astro +39 -0
  114. package/src/components/sections/Cta/banner.astro +64 -0
  115. package/src/components/sections/Cta/card.astro +88 -0
  116. package/src/components/sections/Cta/index.astro +31 -0
  117. package/src/components/sections/Cta/photo.astro +114 -0
  118. package/src/components/sections/Cta/strip.astro +91 -0
  119. package/src/components/sections/Donate/index.astro +136 -0
  120. package/src/components/sections/Donate/story.astro +7 -0
  121. package/src/components/sections/Event/card.astro +14 -0
  122. package/src/components/sections/Event/index.astro +14 -0
  123. package/src/components/sections/EventsList/AgendaMonths.astro +105 -0
  124. package/src/components/sections/EventsList/CalendarLine.astro +23 -0
  125. package/src/components/sections/EventsList/EventRows.astro +196 -0
  126. package/src/components/sections/EventsList/LiveCounts.astro +75 -0
  127. package/src/components/sections/EventsList/TypeTabs.astro +53 -0
  128. package/src/components/sections/EventsList/agenda.astro +55 -0
  129. package/src/components/sections/EventsList/calendar.astro +392 -0
  130. package/src/components/sections/EventsList/cards.astro +186 -0
  131. package/src/components/sections/EventsList/cohorts.astro +205 -0
  132. package/src/components/sections/EventsList/compact.astro +163 -0
  133. package/src/components/sections/EventsList/events.ts +168 -0
  134. package/src/components/sections/EventsList/index.astro +46 -0
  135. package/src/components/sections/EventsList/map.astro +436 -0
  136. package/src/components/sections/EventsList/shifts.astro +355 -0
  137. package/src/components/sections/EventsList/week.astro +361 -0
  138. package/src/components/sections/Faq/Contact.astro +63 -0
  139. package/src/components/sections/Faq/Questions.astro +98 -0
  140. package/src/components/sections/Faq/cards.astro +74 -0
  141. package/src/components/sections/Faq/faq.ts +101 -0
  142. package/src/components/sections/Faq/index.astro +49 -0
  143. package/src/components/sections/Faq/topics.astro +178 -0
  144. package/src/components/sections/Financials/Foot.astro +38 -0
  145. package/src/components/sections/Financials/Head.astro +47 -0
  146. package/src/components/sections/Financials/donut.astro +197 -0
  147. package/src/components/sections/Financials/financials.ts +52 -0
  148. package/src/components/sections/Financials/index.astro +148 -0
  149. package/src/components/sections/Financials/table.astro +157 -0
  150. package/src/components/sections/FormBlock/index.astro +33 -0
  151. package/src/components/sections/FormBlock/wide.astro +7 -0
  152. package/src/components/sections/Hero/cover.astro +170 -0
  153. package/src/components/sections/Hero/donate.astro +209 -0
  154. package/src/components/sections/Hero/field.astro +390 -0
  155. package/src/components/sections/Hero/index.astro +52 -0
  156. package/src/components/sections/Hero/overlap.astro +151 -0
  157. package/src/components/sections/Hero/rotating.astro +30 -0
  158. package/src/components/sections/Hero/split.astro +96 -0
  159. package/src/components/sections/Hero/statement.astro +55 -0
  160. package/src/components/sections/Hero/video.astro +399 -0
  161. package/src/components/sections/Issues/checklist.astro +204 -0
  162. package/src/components/sections/Issues/drawer.astro +237 -0
  163. package/src/components/sections/Issues/index.astro +115 -0
  164. package/src/components/sections/Issues/issues.ts +37 -0
  165. package/src/components/sections/Issues/numbered.astro +79 -0
  166. package/src/components/sections/Issues/rows.astro +137 -0
  167. package/src/components/sections/Issues/steps.astro +81 -0
  168. package/src/components/sections/Issues/tabs.astro +322 -0
  169. package/src/components/sections/Leaderboard/index.astro +29 -0
  170. package/src/components/sections/Lesson/Door.astro +121 -0
  171. package/src/components/sections/Lesson/LessonBody.astro +416 -0
  172. package/src/components/sections/Lesson/Rail.astro +182 -0
  173. package/src/components/sections/Lesson/Tracker.astro +137 -0
  174. package/src/components/sections/Lesson/index.astro +27 -0
  175. package/src/components/sections/Lesson/lesson.ts +233 -0
  176. package/src/components/sections/Lesson/reading.astro +21 -0
  177. package/src/components/sections/Map/CoverageLine.astro +19 -0
  178. package/src/components/sections/Map/RegionMap.astro +109 -0
  179. package/src/components/sections/Map/bar.astro +160 -0
  180. package/src/components/sections/Map/index.astro +192 -0
  181. package/src/components/sections/Map/map.astro +275 -0
  182. package/src/components/sections/MediaKit/BioCard.astro +108 -0
  183. package/src/components/sections/MediaKit/Downloads.astro +88 -0
  184. package/src/components/sections/MediaKit/index.astro +183 -0
  185. package/src/components/sections/MediaKit/kit.ts +140 -0
  186. package/src/components/sections/MediaKit/press.astro +189 -0
  187. package/src/components/sections/MediaKit/speaker.astro +205 -0
  188. package/src/components/sections/Membership/Benefits.astro +42 -0
  189. package/src/components/sections/Membership/Check.astro +12 -0
  190. package/src/components/sections/Membership/Price.astro +61 -0
  191. package/src/components/sections/Membership/compare.astro +312 -0
  192. package/src/components/sections/Membership/index.astro +281 -0
  193. package/src/components/sections/Membership/offers.ts +169 -0
  194. package/src/components/sections/Membership/tiers.astro +217 -0
  195. package/src/components/sections/MovementMap/index.astro +50 -0
  196. package/src/components/sections/MovementTicker/index.astro +43 -0
  197. package/src/components/sections/Pathways/Doors.astro +147 -0
  198. package/src/components/sections/Pathways/Head.astro +37 -0
  199. package/src/components/sections/Pathways/index.astro +27 -0
  200. package/src/components/sections/Pathways/pathways.ts +100 -0
  201. package/src/components/sections/Pathways/quiz.astro +286 -0
  202. package/src/components/sections/Pathways/tabs.astro +271 -0
  203. package/src/components/sections/PdfEmbed/card.astro +99 -0
  204. package/src/components/sections/PdfEmbed/index.astro +26 -0
  205. package/src/components/sections/PdfEmbed/medium.astro +7 -0
  206. package/src/components/sections/PdfEmbed/tall.astro +7 -0
  207. package/src/components/sections/Petition/coverage.astro +14 -0
  208. package/src/components/sections/Petition/image.astro +14 -0
  209. package/src/components/sections/Petition/index.astro +14 -0
  210. package/src/components/sections/Petition/map.astro +14 -0
  211. package/src/components/sections/PlatformPlanks/anchors.ts +66 -0
  212. package/src/components/sections/PlatformPlanks/columns.astro +171 -0
  213. package/src/components/sections/PlatformPlanks/index.astro +56 -0
  214. package/src/components/sections/PlatformPlanks/longread.astro +250 -0
  215. package/src/components/sections/PollBlock/index.astro +30 -0
  216. package/src/components/sections/Portfolio/featured.astro +343 -0
  217. package/src/components/sections/Portfolio/index.astro +571 -0
  218. package/src/components/sections/Portfolio/strip.astro +173 -0
  219. package/src/components/sections/Portfolio/work.ts +100 -0
  220. package/src/components/sections/Progress/MatchClock.astro +166 -0
  221. package/src/components/sections/Progress/compact.astro +150 -0
  222. package/src/components/sections/Progress/index.astro +32 -0
  223. package/src/components/sections/Progress/match.astro +126 -0
  224. package/src/components/sections/Progress/ring.astro +179 -0
  225. package/src/components/sections/QuickDonate/DonateCard.astro +149 -0
  226. package/src/components/sections/QuickDonate/Picker.astro +95 -0
  227. package/src/components/sections/QuickDonate/band.astro +164 -0
  228. package/src/components/sections/QuickDonate/bar.astro +208 -0
  229. package/src/components/sections/QuickDonate/donate.ts +126 -0
  230. package/src/components/sections/QuickDonate/hero.astro +143 -0
  231. package/src/components/sections/QuickDonate/index.astro +73 -0
  232. package/src/components/sections/QuickDonate/jar.astro +225 -0
  233. package/src/components/sections/QuickDonate/ladder.astro +248 -0
  234. package/src/components/sections/QuoteStrip/carousel.astro +340 -0
  235. package/src/components/sections/QuoteStrip/index.astro +58 -0
  236. package/src/components/sections/QuoteStrip/logos.astro +226 -0
  237. package/src/components/sections/QuoteStrip/quotes.ts +61 -0
  238. package/src/components/sections/QuoteStrip/single.astro +92 -0
  239. package/src/components/sections/QuoteStrip/ticker.astro +319 -0
  240. package/src/components/sections/QuoteStrip/wall.astro +113 -0
  241. package/src/components/sections/Resources/band.astro +93 -0
  242. package/src/components/sections/Resources/featured.astro +239 -0
  243. package/src/components/sections/Resources/index.astro +225 -0
  244. package/src/components/sections/Resources/resources.ts +92 -0
  245. package/src/components/sections/SampleBallot/Position.astro +39 -0
  246. package/src/components/sections/SampleBallot/ballot.ts +92 -0
  247. package/src/components/sections/SampleBallot/cards.astro +299 -0
  248. package/src/components/sections/SampleBallot/index.astro +326 -0
  249. package/src/components/sections/SampleBallot/measures.astro +172 -0
  250. package/src/components/sections/Scorecard/grades.astro +141 -0
  251. package/src/components/sections/Scorecard/index.astro +294 -0
  252. package/src/components/sections/Scorecard/promise.astro +167 -0
  253. package/src/components/sections/Scorecard/votes.ts +83 -0
  254. package/src/components/sections/SectionHead.astro +31 -0
  255. package/src/components/sections/Services/Button.astro +24 -0
  256. package/src/components/sections/Services/Check.astro +12 -0
  257. package/src/components/sections/Services/Includes.astro +42 -0
  258. package/src/components/sections/Services/compare.astro +328 -0
  259. package/src/components/sections/Services/index.astro +187 -0
  260. package/src/components/sections/Services/list.astro +181 -0
  261. package/src/components/sections/Services/services.ts +80 -0
  262. package/src/components/sections/ShareKit/Actions.astro +71 -0
  263. package/src/components/sections/ShareKit/Buttons.astro +62 -0
  264. package/src/components/sections/ShareKit/compact.astro +123 -0
  265. package/src/components/sections/ShareKit/index.astro +160 -0
  266. package/src/components/sections/ShareKit/share.ts +60 -0
  267. package/src/components/sections/ShareKit/strip.astro +173 -0
  268. package/src/components/sections/SignupCapture/band.astro +7 -0
  269. package/src/components/sections/SignupCapture/index.astro +103 -0
  270. package/src/components/sections/SignupCapture/inline.astro +7 -0
  271. package/src/components/sections/SocialFeed/index.astro +34 -0
  272. package/src/components/sections/StatCards/feature.astro +143 -0
  273. package/src/components/sections/StatCards/index.astro +51 -0
  274. package/src/components/sections/StatCards/ribbon.astro +113 -0
  275. package/src/components/sections/StatCards/wall.astro +177 -0
  276. package/src/components/sections/Store/featured.astro +14 -0
  277. package/src/components/sections/Store/index.astro +14 -0
  278. package/src/components/sections/Stories/Status.astro +42 -0
  279. package/src/components/sections/Stories/StoryCards.astro +171 -0
  280. package/src/components/sections/Stories/cards.astro +42 -0
  281. package/src/components/sections/Stories/index.astro +238 -0
  282. package/src/components/sections/Stories/stories.ts +97 -0
  283. package/src/components/sections/Stories/timeline.astro +135 -0
  284. package/src/components/sections/TeamGrid/board.astro +280 -0
  285. package/src/components/sections/TeamGrid/index.astro +71 -0
  286. package/src/components/sections/TeamGrid/list.astro +306 -0
  287. package/src/components/sections/TeamGrid/people.ts +178 -0
  288. package/src/components/sections/VideoEmbed/index.astro +52 -0
  289. package/src/components/sections/VideoEmbed/landscape.astro +7 -0
  290. package/src/components/sections/VideoEmbed/portrait.astro +7 -0
  291. package/src/components/sections/VideoEmbed/square.astro +7 -0
  292. package/src/components/sections/VoterTools/DaysLeft.astro +33 -0
  293. package/src/components/sections/VoterTools/dates.astro +149 -0
  294. package/src/components/sections/VoterTools/index.astro +228 -0
  295. package/src/components/sections/VoterTools/polling.astro +141 -0
  296. package/src/components/sections/VoterTools/voter-tools.ts +70 -0
  297. package/src/components/sections/index.ts +370 -0
  298. package/src/components/sections/modules/Headed.astro +39 -0
  299. package/src/components/sections/modules/ModuleFrame.astro +179 -0
  300. package/src/components/volunteer/ShiftLive.astro +90 -0
  301. package/src/components/volunteer/detail.astro +247 -0
  302. package/src/components/volunteer/list.astro +298 -0
  303. package/src/components/volunteer/props.ts +21 -0
  304. package/src/env.d.ts +22 -0
  305. package/src/index.d.ts +10 -0
  306. package/src/index.js +64 -0
  307. package/src/layouts/Site.astro +371 -0
  308. package/src/lib/academy.ts +146 -0
  309. package/src/lib/brand.ts +534 -0
  310. package/src/lib/chrome.ts +119 -0
  311. package/src/lib/donate-frame.ts +64 -0
  312. package/src/lib/entries.ts +190 -0
  313. package/src/lib/env.ts +34 -0
  314. package/src/lib/event-map-draw.ts +91 -0
  315. package/src/lib/events.ts +476 -0
  316. package/src/lib/fonts.ts +116 -0
  317. package/src/lib/footer.ts +24 -0
  318. package/src/lib/format.ts +160 -0
  319. package/src/lib/geo.ts +131 -0
  320. package/src/lib/live.ts +54 -0
  321. package/src/lib/menu.ts +48 -0
  322. package/src/lib/petition-text.ts +29 -0
  323. package/src/lib/reading.ts +17 -0
  324. package/src/lib/regions.ts +215 -0
  325. package/src/lib/section.ts +94 -0
  326. package/src/lib/shifts.ts +186 -0
  327. package/src/lib/stream-time.ts +20 -0
  328. package/src/lib/stream.ts +141 -0
  329. package/src/lib/visitor.ts +54 -0
  330. package/src/routes/catch-all.astro +286 -0
  331. package/src/routes/form.astro +30 -0
  332. package/src/routes/live.astro +49 -0
  333. package/src/routes/not-found.astro +18 -0
  334. package/src/routes/preview.astro +60 -0
  335. package/src/routes/setup.astro +62 -0
  336. package/src/routes/volunteer-shift.astro +61 -0
  337. package/src/routes/volunteer.astro +37 -0
  338. package/src/styles/entries.css +784 -0
  339. package/src/styles/site.css +1839 -0
  340. package/src/template.ts +182 -0
@@ -0,0 +1,100 @@
1
+ // A Pathways section's rows as its layouts draw them: one pathway per row
2
+ // that has a title, in the organization's order (eight at most, as the
3
+ // catalogue allows). A pathway carries its line about who it is for, what
4
+ // the visitor leaves with, the address of its programs, its programs (each
5
+ // string one program; a " · " in it splits the program's name from its
6
+ // detail, "Deciding to run · 45 min") and the statements a visitor would say
7
+ // about themselves (`fits`), which the quiz offers as answers. The outcome is
8
+ // drawn after a bold "Leave with:", so an outcome typed with that label
9
+ // already in front ("Leave with: a filing plan") loses it rather than saying
10
+ // it twice. A row's `icon` is a name the template has no drawing for, so it
11
+ // is not drawn.
12
+
13
+ import type { Section } from '@backgold/content'
14
+ import { linkOf, rows, type Link } from '../../../lib/section'
15
+ import { text } from '../../../lib/format'
16
+
17
+ const MAX = 8
18
+ /** The quiz's rounds: one statement per pathway in each. */
19
+ const ROUNDS = 3
20
+ const LEAVE_WITH = /^\s*leave with\s*[:\-–—]\s*/i
21
+
22
+ export interface Program {
23
+ name: string
24
+ /** What follows the first " · ": "45 min", "Full day · Austin". */
25
+ detail: string | null
26
+ }
27
+
28
+ export interface Pathway {
29
+ /** "1", "2", … in row order: what a tab, a choice and a result are matched by. */
30
+ key: string
31
+ title: string
32
+ summary: string | null
33
+ outcome: string | null
34
+ link: Link | null
35
+ programs: Program[]
36
+ fits: string[]
37
+ }
38
+
39
+ export interface Choice {
40
+ key: string
41
+ statement: string
42
+ }
43
+
44
+ /** The text strings of an array field, blanks left out. */
45
+ function strings(value: unknown): string[] {
46
+ return Array.isArray(value) ? value.map(text).filter((s): s is string => s !== null).map((s) => s.trim()) : []
47
+ }
48
+
49
+ function programOf(value: string): Program {
50
+ const at = value.indexOf(' · ')
51
+ if (at === -1) return { name: value, detail: null }
52
+ const name = value.slice(0, at).trim()
53
+ const detail = value.slice(at + 3).trim()
54
+ return name ? { name, detail: detail || null } : { name: detail, detail: null }
55
+ }
56
+
57
+ export function pathwaysOf(section: Section): Pathway[] {
58
+ return rows(section)
59
+ .flatMap((row) => {
60
+ const title = text(row.title)?.trim()
61
+ if (!title) return []
62
+ const outcome = text(row.outcome)?.replace(LEAVE_WITH, '').trim() || null
63
+ return [
64
+ {
65
+ key: '',
66
+ title,
67
+ summary: text(row.summary),
68
+ outcome,
69
+ link: linkOf(title, row.href),
70
+ programs: strings(row.programs).map(programOf),
71
+ fits: strings(row.fits),
72
+ },
73
+ ]
74
+ })
75
+ .slice(0, MAX)
76
+ .map((p, i) => ({ ...p, key: String(i + 1) }))
77
+ }
78
+
79
+ /**
80
+ * The quiz's rounds: round r offers the r-th statement of every pathway that
81
+ * has one, starting each round one pathway further along the list so the
82
+ * first answer is not always the same pathway's. A round with fewer than two
83
+ * statements offers no choice and is left out; with no round left there is
84
+ * no quiz.
85
+ */
86
+ export function roundsOf(pathways: Pathway[]): Choice[][] {
87
+ const rounds: Choice[][] = []
88
+ for (let r = 0; r < ROUNDS; r++) {
89
+ const offered = pathways.filter((p) => p.fits[r]).map((p) => ({ key: p.key, statement: p.fits[r] }))
90
+ if (offered.length < 2) continue
91
+ const turn = rounds.length % offered.length
92
+ rounds.push([...offered.slice(turn), ...offered.slice(0, turn)])
93
+ }
94
+ return rounds
95
+ }
96
+
97
+ /** An id for an element of this section, unique on the page. */
98
+ export function idFor(section: Section, suffix: string): string {
99
+ return `${section.id}-${suffix}`.replace(/[^A-Za-z0-9_-]/g, '-')
100
+ }
@@ -0,0 +1,286 @@
1
+ ---
2
+ // Pathways · Quiz (mock 11, C, "3-question quiz"): the kicker, heading and
3
+ // body centred, then a card that asks in up to three rounds which statement
4
+ // sounds like the visitor. Round r offers the r-th of each pathway's `fits`
5
+ // statements as a button apiece (a pathway with no r-th statement sits that
6
+ // round out, and a round of fewer than two statements is left out),
7
+ // starting one pathway further along each round, under `quizHeading`. The
8
+ // card says "Question 2 of 3" over them and fills a bar under them a round
9
+ // at a time (a quiz of one round has neither). A pick counts for its
10
+ // pathway and moves to the next round, the focus on its "Question" line.
11
+ // After the last, the card gives way to a panel in the contrast band's
12
+ // colours (on a section that is already on the contrast band, a tint of its
13
+ // ink), the focus on its title:
14
+ // `resultLabel` small in capitals, the pathway with the most picks large
15
+ // (between pathways picked as often, the one picked first), "Leave with:"
16
+ // and its outcome, the `startLabel` button to its programs, and Start over,
17
+ // which clears the picks and asks the first round again.
18
+ //
19
+ // The quiz is the section's script and nothing else: the picks stay in the
20
+ // page, nothing is sent and nothing is stored. The card is drawn hidden and
21
+ // shown by the script, which hides the doors in its place, so with scripts
22
+ // off (or with no round that offers two statements) the section is the
23
+ // Doors layout. With no pathways and no heading it draws nothing.
24
+ import type { ComponentProps } from 'astro/types'
25
+ import type Default from './index.astro'
26
+ import Band from '../Band.astro'
27
+ import Doors from './Doors.astro'
28
+ import Head from './Head.astro'
29
+ import { idFor, pathwaysOf, roundsOf } from './pathways'
30
+ import { text } from '../../../lib/format'
31
+
32
+ type Props = ComponentProps<typeof Default>
33
+
34
+ const { section } = Astro.props
35
+ const heading = text(section.copy.heading)
36
+ const quizHeading = text(section.copy.quizHeading)
37
+ const resultLabel = text(section.copy.resultLabel)
38
+ const startLabel = text(section.copy.startLabel)
39
+ const pathways = pathwaysOf(section)
40
+ const rounds = roundsOf(pathways)
41
+ const offered = new Set(rounds.flat().map((choice) => choice.key))
42
+ const results = pathways.filter((p) => offered.has(p.key))
43
+ const headingId = idFor(section, 'quiz-heading')
44
+ // One round has no "Question 1 of 1" and no bar.
45
+ const steps = rounds.length > 1
46
+ ---
47
+ {(pathways.length > 0 || heading) && (
48
+ <Band section={section} class="pathways pathways-quiz">
49
+ <Head kicker={text(section.copy.kicker)} heading={heading} body={section.copy.body} />
50
+ <div class="quiz-frame" data-quiz-frame>
51
+ <div data-quiz-doors>
52
+ <Doors pathways={pathways} programsLabel={text(section.copy.programsLabel)} />
53
+ </div>
54
+ {rounds.length > 0 && (
55
+ <div class="quiz" data-quiz hidden>
56
+ <div class="quiz-card" data-quiz-card>
57
+ {quizHeading && <h3 class="quiz-heading" id={headingId}>{quizHeading}</h3>}
58
+ {rounds.map((round, r) => {
59
+ const stepId = steps ? idFor(section, `quiz-step-${r + 1}`) : null
60
+ const labelledBy = [quizHeading && headingId, stepId].filter(Boolean).join(' ')
61
+ return (
62
+ <div class="quiz-round" data-quiz-round hidden={r > 0}>
63
+ {stepId && <p class="quiz-step" id={stepId} tabindex="-1">Question {r + 1} of {rounds.length}</p>}
64
+ <div class="quiz-choices" role="group" aria-labelledby={labelledBy || undefined} aria-label={labelledBy ? undefined : (heading ?? undefined)}>
65
+ {round.map((choice) => (
66
+ <button type="button" class="quiz-choice" data-quiz-pick={choice.key}>{choice.statement}</button>
67
+ ))}
68
+ </div>
69
+ </div>
70
+ )
71
+ })}
72
+ {steps && (
73
+ <div class="meter quiz-meter" aria-hidden="true">
74
+ <span class="meter-fill" data-quiz-fill style={`width: ${100 / rounds.length}%`}></span>
75
+ </div>
76
+ )}
77
+ </div>
78
+ {results.map((p) => (
79
+ <div class="quiz-result bg-band-contrast" data-quiz-result={p.key} hidden>
80
+ {resultLabel && <p class="quiz-result-label">{resultLabel}</p>}
81
+ <h3 class="quiz-result-title" tabindex="-1">{p.title}</h3>
82
+ {p.outcome && <p class="quiz-result-outcome"><b>Leave with:</b> {p.outcome}</p>}
83
+ <p class="quiz-result-actions">
84
+ {p.link && startLabel && (
85
+ <a class="button" href={p.link.href} rel={p.link.rel}>{startLabel}<span aria-hidden="true"> →</span></a>
86
+ )}
87
+ <button type="button" class="quiz-again" data-quiz-again>Start over</button>
88
+ </p>
89
+ </div>
90
+ ))}
91
+ </div>
92
+ )}
93
+ {rounds.length > 0 && (
94
+ <script is:inline>
95
+ ;(function (root) {
96
+ if (!root) return
97
+ var quiz = root.querySelector('[data-quiz]')
98
+ var card = quiz.querySelector('[data-quiz-card]')
99
+ var rounds = quiz.querySelectorAll('[data-quiz-round]')
100
+ var results = quiz.querySelectorAll('[data-quiz-result]')
101
+ var fill = quiz.querySelector('[data-quiz-fill]')
102
+ var picks = []
103
+ var ask = function (r, focus) {
104
+ for (var i = 0; i < rounds.length; i++) rounds[i].hidden = i !== r
105
+ if (fill) fill.style.width = ((r + 1) / rounds.length) * 100 + '%'
106
+ if (focus) rounds[r].querySelector('.quiz-step, .quiz-choice').focus()
107
+ }
108
+ var finish = function () {
109
+ var counts = {}
110
+ var best = 0
111
+ var winner = null
112
+ for (var i = 0; i < picks.length; i++) {
113
+ counts[picks[i]] = (counts[picks[i]] || 0) + 1
114
+ if (counts[picks[i]] > best) best = counts[picks[i]]
115
+ }
116
+ for (var j = 0; j < picks.length && winner === null; j++) if (counts[picks[j]] === best) winner = picks[j]
117
+ card.hidden = true
118
+ for (var k = 0; k < results.length; k++) {
119
+ var won = results[k].getAttribute('data-quiz-result') === winner
120
+ results[k].hidden = !won
121
+ if (won) results[k].querySelector('.quiz-result-title').focus()
122
+ }
123
+ }
124
+ quiz.addEventListener('click', function (event) {
125
+ var pick = event.target.closest('[data-quiz-pick]')
126
+ if (pick) {
127
+ picks.push(pick.getAttribute('data-quiz-pick'))
128
+ if (picks.length < rounds.length) ask(picks.length, true)
129
+ else finish()
130
+ return
131
+ }
132
+ if (event.target.closest('[data-quiz-again]')) {
133
+ picks = []
134
+ for (var k = 0; k < results.length; k++) results[k].hidden = true
135
+ card.hidden = false
136
+ ask(0, true)
137
+ }
138
+ })
139
+ root.querySelector('[data-quiz-doors]').hidden = true
140
+ quiz.hidden = false
141
+ })(document.currentScript.closest('[data-quiz-frame]'))
142
+ </script>
143
+ )}
144
+ </div>
145
+ </Band>
146
+ )}
147
+
148
+ <style>
149
+ [data-quiz-doors][hidden],
150
+ .quiz[hidden],
151
+ .quiz-card[hidden],
152
+ .quiz-round[hidden],
153
+ .quiz-result[hidden] {
154
+ display: none;
155
+ }
156
+ .quiz {
157
+ max-width: 40rem;
158
+ margin-inline: auto;
159
+ }
160
+ .quiz-card {
161
+ display: flex;
162
+ flex-direction: column;
163
+ gap: 1rem;
164
+ padding: clamp(1.25rem, 0.9rem + 1.5vw, 2rem);
165
+ border: 1px solid var(--line);
166
+ border-radius: var(--radius-card);
167
+ background: var(--surface);
168
+ }
169
+ .quiz-card > *,
170
+ .quiz-round > * {
171
+ margin: 0;
172
+ }
173
+ .quiz-heading {
174
+ font-size: var(--h3);
175
+ font-weight: 700;
176
+ }
177
+ .quiz-round {
178
+ display: grid;
179
+ gap: 0.75rem;
180
+ }
181
+ .quiz-step {
182
+ color: var(--muted);
183
+ font-size: var(--text-xs);
184
+ font-weight: 700;
185
+ letter-spacing: 0.16em;
186
+ line-height: 1.4;
187
+ text-transform: uppercase;
188
+ }
189
+ .quiz-step:focus,
190
+ .quiz-result-title:focus {
191
+ outline: none;
192
+ }
193
+ .quiz-choices {
194
+ display: grid;
195
+ gap: 0.5rem;
196
+ }
197
+ .quiz-choice {
198
+ min-height: 3rem;
199
+ padding: 0.75rem 1.125rem;
200
+ border: 1.5px solid var(--line-strong);
201
+ border-radius: var(--radius);
202
+ background: var(--surface);
203
+ color: var(--ink);
204
+ font: inherit;
205
+ line-height: 1.4;
206
+ text-align: left;
207
+ cursor: pointer;
208
+ }
209
+ .quiz-choice:hover {
210
+ border-color: var(--ink);
211
+ background: color-mix(in srgb, var(--ink) 5%, var(--surface));
212
+ }
213
+ .quiz-card .quiz-meter {
214
+ margin-top: 0.5rem;
215
+ }
216
+ .quiz-result {
217
+ display: flex;
218
+ flex-direction: column;
219
+ align-items: center;
220
+ gap: 0.75rem;
221
+ padding: clamp(1.75rem, 1.2rem + 2vw, 2.75rem) clamp(1.25rem, 0.9rem + 1.5vw, 2.25rem);
222
+ border-radius: var(--radius-card);
223
+ background: var(--bg-band-background);
224
+ color: var(--bg-band-color);
225
+ text-align: center;
226
+ }
227
+ .quiz-result > * {
228
+ margin: 0;
229
+ }
230
+ :global(.bg-band-contrast) .quiz-result {
231
+ border: 1px solid var(--line);
232
+ background: color-mix(in srgb, var(--ink) 7%, transparent);
233
+ }
234
+ .quiz-result-label {
235
+ color: var(--muted);
236
+ font-size: var(--text-xs);
237
+ font-weight: 700;
238
+ letter-spacing: 0.16em;
239
+ line-height: 1.4;
240
+ text-transform: uppercase;
241
+ }
242
+ .quiz-result-title {
243
+ font-size: var(--h2);
244
+ font-weight: 800;
245
+ }
246
+ .quiz-result-outcome {
247
+ max-width: 30rem;
248
+ font-size: var(--text-lg);
249
+ line-height: 1.5;
250
+ }
251
+ .quiz-result .quiz-result-actions {
252
+ display: flex;
253
+ flex-wrap: wrap;
254
+ align-items: center;
255
+ justify-content: center;
256
+ gap: 0.75rem 1.5rem;
257
+ margin-top: 0.75rem;
258
+ }
259
+ .quiz-again {
260
+ min-height: 2.75rem;
261
+ padding: 0 0.25rem;
262
+ border: 0;
263
+ background: transparent;
264
+ color: var(--link);
265
+ font: inherit;
266
+ font-size: var(--text-sm);
267
+ font-weight: 700;
268
+ text-decoration: underline;
269
+ text-decoration-thickness: 1.5px;
270
+ text-underline-offset: 0.25em;
271
+ cursor: pointer;
272
+ }
273
+ .quiz-again:hover {
274
+ text-decoration-thickness: 2px;
275
+ }
276
+ @media (prefers-reduced-motion: no-preference) {
277
+ .quiz-choice {
278
+ transition:
279
+ border-color 0.15s ease,
280
+ background-color 0.15s ease;
281
+ }
282
+ .quiz-meter .meter-fill {
283
+ transition: width 0.3s ease;
284
+ }
285
+ }
286
+ </style>
@@ -0,0 +1,271 @@
1
+ ---
2
+ // Pathways · Tabs (mock 11, B, "Tabs + program list"): the kicker, heading
3
+ // and body, then a tab per pathway and the picked pathway under them. A
4
+ // pathway is a filled panel in the contrast band's colours (on a section
5
+ // that is already on the contrast band, a tint of its ink) with its title,
6
+ // the line about who it is for and the one button, `programsLabel`, to its
7
+ // programs; beside it, its programs as a list of rows, each program string
8
+ // drawn as the row's words, the part before a " · " as the program's name
9
+ // and the rest small under it ("Deciding to run" over "45 min"). A pathway
10
+ // with no programs is its panel alone, the width of the row; under 48rem
11
+ // the list goes under the panel.
12
+ //
13
+ // The tabs are a tablist of buttons, drawn hidden and shown by the
14
+ // section's script, which then shows one pathway at a time: the first,
15
+ // until another tab is clicked or reached with the arrow keys (Home and End
16
+ // go to the first and last). With scripts off every pathway shows, one
17
+ // under another, each under its own heading. Under 48rem the tabs are a
18
+ // wrapped row of chips. With one pathway there are no tabs. With no
19
+ // pathways and no heading it draws nothing.
20
+ import type { ComponentProps } from 'astro/types'
21
+ import type Default from './index.astro'
22
+ import Band from '../Band.astro'
23
+ import SectionHead from '../SectionHead.astro'
24
+ import Prose from '../../Prose.astro'
25
+ import { idFor, pathwaysOf } from './pathways'
26
+ import { text } from '../../../lib/format'
27
+
28
+ type Props = ComponentProps<typeof Default>
29
+
30
+ const { section } = Astro.props
31
+ const kicker = text(section.copy.kicker)
32
+ const heading = text(section.copy.heading)
33
+ const programsLabel = text(section.copy.programsLabel)
34
+ const pathways = pathwaysOf(section)
35
+ const tabbed = pathways.length > 1
36
+ ---
37
+ {(pathways.length > 0 || heading) && (
38
+ <Band section={section} class="pathways pathways-tabs">
39
+ <div class="paths-intro">
40
+ <SectionHead kicker={kicker} heading={heading} more={[]} />
41
+ <Prose value={section.copy.body} class="lede" />
42
+ </div>
43
+ {pathways.length > 0 && (
44
+ <div class="paths" data-paths>
45
+ {tabbed && (
46
+ <div class="paths-tabs" role="tablist" aria-label={heading ?? 'Pathways'} data-paths-tabs hidden>
47
+ {pathways.map((p, i) => (
48
+ <button
49
+ type="button"
50
+ role="tab"
51
+ id={idFor(section, `tab-${p.key}`)}
52
+ aria-selected={i === 0 ? 'true' : 'false'}
53
+ aria-controls={idFor(section, `path-${p.key}`)}
54
+ tabindex={i === 0 ? 0 : -1}
55
+ >{p.title}</button>
56
+ ))}
57
+ </div>
58
+ )}
59
+ <div class="paths-list">
60
+ {pathways.map((p) => (
61
+ <div class:list={['path', p.programs.length === 0 && 'path-solo']} id={idFor(section, `path-${p.key}`)} data-paths-panel>
62
+ <div class="path-card bg-band-contrast">
63
+ <h3 class="path-title">{p.title}</h3>
64
+ {p.summary && <p class="path-summary">{p.summary}</p>}
65
+ {p.link && programsLabel && <a class="button" href={p.link.href} rel={p.link.rel}>{programsLabel}</a>}
66
+ </div>
67
+ {p.programs.length > 0 && (
68
+ <ul class="path-programs" role="list">
69
+ {p.programs.map((program) => (
70
+ <li class="program">
71
+ <span class="program-name">{program.name}</span>
72
+ {program.detail && <span class="program-detail">{program.detail}</span>}
73
+ </li>
74
+ ))}
75
+ </ul>
76
+ )}
77
+ </div>
78
+ ))}
79
+ </div>
80
+ {tabbed && (
81
+ <script is:inline>
82
+ ;(function (root) {
83
+ if (!root) return
84
+ var list = root.querySelector('[data-paths-tabs]')
85
+ var tabs = list.querySelectorAll('[role="tab"]')
86
+ var panels = root.querySelectorAll('[data-paths-panel]')
87
+ var select = function (index, focus) {
88
+ for (var t = 0; t < tabs.length; t++) {
89
+ var on = t === index
90
+ tabs[t].setAttribute('aria-selected', on ? 'true' : 'false')
91
+ tabs[t].tabIndex = on ? 0 : -1
92
+ panels[t].hidden = !on
93
+ }
94
+ if (focus) tabs[index].focus()
95
+ }
96
+ var keys = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }
97
+ for (var t = 0; t < tabs.length; t++) {
98
+ tabs[t].addEventListener('click', function (event) {
99
+ select(Array.prototype.indexOf.call(tabs, event.currentTarget), false)
100
+ })
101
+ tabs[t].addEventListener('keydown', function (event) {
102
+ var at = Array.prototype.indexOf.call(tabs, event.currentTarget)
103
+ var next = event.key === 'Home' ? 0 : event.key === 'End' ? tabs.length - 1 : event.key in keys ? (at + keys[event.key] + tabs.length) % tabs.length : -1
104
+ if (next === -1) return
105
+ event.preventDefault()
106
+ select(next, true)
107
+ })
108
+ panels[t].setAttribute('role', 'tabpanel')
109
+ panels[t].setAttribute('aria-labelledby', tabs[t].id)
110
+ panels[t].tabIndex = 0
111
+ }
112
+ select(0, false)
113
+ list.hidden = false
114
+ root.setAttribute('data-paths-live', '')
115
+ })(document.currentScript.closest('[data-paths]'))
116
+ </script>
117
+ )}
118
+ </div>
119
+ )}
120
+ </Band>
121
+ )}
122
+
123
+ <style>
124
+ .paths-intro > :global(.lede) {
125
+ margin: -0.5rem 0 1.75rem;
126
+ }
127
+ .paths-intro > :global(.lede > :last-child) {
128
+ margin-bottom: 0;
129
+ }
130
+ .paths-tabs[hidden],
131
+ .path[hidden] {
132
+ display: none;
133
+ }
134
+ .paths-tabs {
135
+ display: flex;
136
+ flex-wrap: wrap;
137
+ gap: 0.5rem;
138
+ margin-bottom: 1.25rem;
139
+ }
140
+ .paths-tabs button {
141
+ min-height: 2.75rem;
142
+ padding: 0.375rem 1rem;
143
+ border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent);
144
+ border-radius: var(--pill);
145
+ background: transparent;
146
+ color: var(--ink);
147
+ font: inherit;
148
+ font-size: var(--text-sm);
149
+ font-weight: 600;
150
+ cursor: pointer;
151
+ }
152
+ .paths-tabs button:hover {
153
+ border-color: var(--ink);
154
+ }
155
+ .paths-tabs button[aria-selected='true'] {
156
+ border-color: var(--button-2);
157
+ background: var(--button-2);
158
+ color: var(--button-2-ink);
159
+ }
160
+ .paths-list {
161
+ display: grid;
162
+ gap: 2rem;
163
+ }
164
+ .path {
165
+ display: grid;
166
+ gap: 0.75rem;
167
+ min-width: 0;
168
+ }
169
+ .path:focus-visible {
170
+ outline-offset: 6px;
171
+ border-radius: var(--radius-card);
172
+ }
173
+ .path-card {
174
+ display: flex;
175
+ flex-direction: column;
176
+ align-items: flex-start;
177
+ gap: 0.75rem;
178
+ min-width: 0;
179
+ padding: clamp(1.375rem, 1rem + 1.5vw, 2rem);
180
+ border-radius: var(--radius-card);
181
+ background: var(--bg-band-background);
182
+ color: var(--bg-band-color);
183
+ }
184
+ .path-card > * {
185
+ margin: 0;
186
+ }
187
+ :global(.bg-band-contrast) .path-card {
188
+ border: 1px solid var(--line);
189
+ background: color-mix(in srgb, var(--ink) 7%, transparent);
190
+ }
191
+ .path-title {
192
+ font-size: var(--h3);
193
+ font-weight: 700;
194
+ }
195
+ .path-summary {
196
+ font-size: var(--text-lg);
197
+ line-height: 1.5;
198
+ max-width: 34rem;
199
+ }
200
+ .path-card .button {
201
+ margin-top: 0.5rem;
202
+ }
203
+ .path-programs {
204
+ display: grid;
205
+ gap: 0.5rem;
206
+ align-content: start;
207
+ margin: 0;
208
+ padding: 0;
209
+ list-style: none;
210
+ }
211
+ .program {
212
+ display: flex;
213
+ flex-direction: column;
214
+ gap: 0.125rem;
215
+ min-width: 0;
216
+ padding: 0.875rem 1.125rem;
217
+ border: 1px solid var(--line);
218
+ border-radius: var(--radius);
219
+ background: var(--surface);
220
+ }
221
+ .program-name {
222
+ font-weight: 700;
223
+ line-height: 1.35;
224
+ }
225
+ .program-detail {
226
+ color: var(--muted);
227
+ font-size: var(--text-sm);
228
+ }
229
+ @media (min-width: 48rem) {
230
+ .paths-tabs {
231
+ flex-wrap: nowrap;
232
+ gap: 0.25rem;
233
+ margin-bottom: 1.5rem;
234
+ overflow-x: auto;
235
+ box-shadow: inset 0 -2px 0 var(--line);
236
+ }
237
+ .paths-tabs button {
238
+ flex: 0 0 auto;
239
+ padding: 0.625rem 1rem;
240
+ border: 0;
241
+ border-bottom: 3px solid transparent;
242
+ border-radius: 0;
243
+ color: var(--muted);
244
+ font-size: var(--text);
245
+ white-space: nowrap;
246
+ }
247
+ .paths-tabs button:hover {
248
+ color: var(--ink);
249
+ }
250
+ .paths-tabs button[aria-selected='true'] {
251
+ border-color: var(--accent);
252
+ background: transparent;
253
+ color: var(--ink);
254
+ font-weight: 700;
255
+ }
256
+ .paths-tabs button:focus-visible {
257
+ outline-offset: -3px;
258
+ }
259
+ .path {
260
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
261
+ gap: 1.25rem;
262
+ align-items: start;
263
+ }
264
+ .path-solo {
265
+ grid-template-columns: minmax(0, 1fr);
266
+ }
267
+ .path-card {
268
+ min-height: 100%;
269
+ }
270
+ }
271
+ </style>