@backgold/template-kit 0.0.0-stage → 0.1.1

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 (349) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/chunk-RJAVFRC6.js +67 -0
  4. package/dist/constants-BAIo_Q5U.d-lQbj1e1-.d.ts +48 -0
  5. package/dist/content-api-Cox1-wz5.d.ts +1096 -0
  6. package/dist/contract/content-api-examples.d.ts +72 -0
  7. package/dist/contract/content-api-examples.js +926 -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 +253 -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 +61 -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 +80 -0
  57. package/src/components/sections/About/index.astro +60 -0
  58. package/src/components/sections/About/left.astro +57 -0
  59. package/src/components/sections/About/letter.astro +111 -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 +126 -0
  102. package/src/components/sections/ContentPost/player.astro +254 -0
  103. package/src/components/sections/ContentPost/prose.astro +80 -0
  104. package/src/components/sections/ContentPost/theater.astro +329 -0
  105. package/src/components/sections/Countdown/index.astro +53 -0
  106. package/src/components/sections/Course/Bar.astro +46 -0
  107. package/src/components/sections/Course/CourseHead.astro +123 -0
  108. package/src/components/sections/Course/Crumbs.astro +44 -0
  109. package/src/components/sections/Course/Icon.astro +29 -0
  110. package/src/components/sections/Course/Ring.astro +62 -0
  111. package/src/components/sections/Course/Syllabus.astro +146 -0
  112. package/src/components/sections/Course/course.ts +146 -0
  113. package/src/components/sections/Course/index.astro +143 -0
  114. package/src/components/sections/Course/outline.astro +39 -0
  115. package/src/components/sections/Cta/banner.astro +64 -0
  116. package/src/components/sections/Cta/card.astro +88 -0
  117. package/src/components/sections/Cta/index.astro +31 -0
  118. package/src/components/sections/Cta/photo.astro +114 -0
  119. package/src/components/sections/Cta/strip.astro +91 -0
  120. package/src/components/sections/Donate/index.astro +136 -0
  121. package/src/components/sections/Donate/story.astro +7 -0
  122. package/src/components/sections/Event/card.astro +14 -0
  123. package/src/components/sections/Event/index.astro +14 -0
  124. package/src/components/sections/EventsList/AgendaMonths.astro +105 -0
  125. package/src/components/sections/EventsList/CalendarLine.astro +23 -0
  126. package/src/components/sections/EventsList/EventRows.astro +196 -0
  127. package/src/components/sections/EventsList/LiveCounts.astro +75 -0
  128. package/src/components/sections/EventsList/TypeTabs.astro +53 -0
  129. package/src/components/sections/EventsList/agenda.astro +55 -0
  130. package/src/components/sections/EventsList/calendar.astro +392 -0
  131. package/src/components/sections/EventsList/cards.astro +186 -0
  132. package/src/components/sections/EventsList/cohorts.astro +205 -0
  133. package/src/components/sections/EventsList/compact.astro +163 -0
  134. package/src/components/sections/EventsList/events.ts +168 -0
  135. package/src/components/sections/EventsList/index.astro +46 -0
  136. package/src/components/sections/EventsList/map.astro +436 -0
  137. package/src/components/sections/EventsList/shifts.astro +355 -0
  138. package/src/components/sections/EventsList/week.astro +361 -0
  139. package/src/components/sections/Faq/Contact.astro +63 -0
  140. package/src/components/sections/Faq/Questions.astro +98 -0
  141. package/src/components/sections/Faq/cards.astro +74 -0
  142. package/src/components/sections/Faq/faq.ts +101 -0
  143. package/src/components/sections/Faq/index.astro +49 -0
  144. package/src/components/sections/Faq/topics.astro +178 -0
  145. package/src/components/sections/Financials/Foot.astro +38 -0
  146. package/src/components/sections/Financials/Head.astro +47 -0
  147. package/src/components/sections/Financials/donut.astro +197 -0
  148. package/src/components/sections/Financials/financials.ts +52 -0
  149. package/src/components/sections/Financials/index.astro +148 -0
  150. package/src/components/sections/Financials/table.astro +157 -0
  151. package/src/components/sections/FormBlock/index.astro +33 -0
  152. package/src/components/sections/FormBlock/wide.astro +7 -0
  153. package/src/components/sections/Hero/cover.astro +176 -0
  154. package/src/components/sections/Hero/donate.astro +209 -0
  155. package/src/components/sections/Hero/field.astro +390 -0
  156. package/src/components/sections/Hero/index.astro +52 -0
  157. package/src/components/sections/Hero/overlap.astro +151 -0
  158. package/src/components/sections/Hero/rotating.astro +30 -0
  159. package/src/components/sections/Hero/split.astro +99 -0
  160. package/src/components/sections/Hero/statement.astro +55 -0
  161. package/src/components/sections/Hero/video.astro +399 -0
  162. package/src/components/sections/Issues/checklist.astro +204 -0
  163. package/src/components/sections/Issues/drawer.astro +237 -0
  164. package/src/components/sections/Issues/index.astro +115 -0
  165. package/src/components/sections/Issues/issues.ts +37 -0
  166. package/src/components/sections/Issues/numbered.astro +79 -0
  167. package/src/components/sections/Issues/rows.astro +137 -0
  168. package/src/components/sections/Issues/steps.astro +81 -0
  169. package/src/components/sections/Issues/tabs.astro +322 -0
  170. package/src/components/sections/Leaderboard/index.astro +29 -0
  171. package/src/components/sections/Lesson/Door.astro +121 -0
  172. package/src/components/sections/Lesson/LessonBody.astro +416 -0
  173. package/src/components/sections/Lesson/Rail.astro +182 -0
  174. package/src/components/sections/Lesson/Tracker.astro +137 -0
  175. package/src/components/sections/Lesson/index.astro +27 -0
  176. package/src/components/sections/Lesson/lesson.ts +233 -0
  177. package/src/components/sections/Lesson/reading.astro +21 -0
  178. package/src/components/sections/Map/CoverageLine.astro +19 -0
  179. package/src/components/sections/Map/RegionMap.astro +109 -0
  180. package/src/components/sections/Map/bar.astro +160 -0
  181. package/src/components/sections/Map/index.astro +192 -0
  182. package/src/components/sections/Map/map.astro +275 -0
  183. package/src/components/sections/MediaKit/BioCard.astro +108 -0
  184. package/src/components/sections/MediaKit/Downloads.astro +88 -0
  185. package/src/components/sections/MediaKit/index.astro +183 -0
  186. package/src/components/sections/MediaKit/kit.ts +140 -0
  187. package/src/components/sections/MediaKit/press.astro +189 -0
  188. package/src/components/sections/MediaKit/speaker.astro +205 -0
  189. package/src/components/sections/Membership/Benefits.astro +42 -0
  190. package/src/components/sections/Membership/Check.astro +12 -0
  191. package/src/components/sections/Membership/Price.astro +61 -0
  192. package/src/components/sections/Membership/compare.astro +312 -0
  193. package/src/components/sections/Membership/index.astro +281 -0
  194. package/src/components/sections/Membership/offers.ts +169 -0
  195. package/src/components/sections/Membership/tiers.astro +217 -0
  196. package/src/components/sections/MovementMap/index.astro +50 -0
  197. package/src/components/sections/MovementTicker/index.astro +43 -0
  198. package/src/components/sections/Pathways/Doors.astro +147 -0
  199. package/src/components/sections/Pathways/Head.astro +37 -0
  200. package/src/components/sections/Pathways/index.astro +27 -0
  201. package/src/components/sections/Pathways/pathways.ts +100 -0
  202. package/src/components/sections/Pathways/quiz.astro +286 -0
  203. package/src/components/sections/Pathways/tabs.astro +271 -0
  204. package/src/components/sections/PdfEmbed/card.astro +99 -0
  205. package/src/components/sections/PdfEmbed/index.astro +26 -0
  206. package/src/components/sections/PdfEmbed/medium.astro +7 -0
  207. package/src/components/sections/PdfEmbed/tall.astro +7 -0
  208. package/src/components/sections/Petition/coverage.astro +14 -0
  209. package/src/components/sections/Petition/image.astro +14 -0
  210. package/src/components/sections/Petition/index.astro +14 -0
  211. package/src/components/sections/Petition/map.astro +14 -0
  212. package/src/components/sections/PlatformPlanks/anchors.ts +66 -0
  213. package/src/components/sections/PlatformPlanks/columns.astro +171 -0
  214. package/src/components/sections/PlatformPlanks/index.astro +56 -0
  215. package/src/components/sections/PlatformPlanks/longread.astro +250 -0
  216. package/src/components/sections/PollBlock/index.astro +30 -0
  217. package/src/components/sections/Portfolio/featured.astro +343 -0
  218. package/src/components/sections/Portfolio/index.astro +571 -0
  219. package/src/components/sections/Portfolio/strip.astro +173 -0
  220. package/src/components/sections/Portfolio/work.ts +100 -0
  221. package/src/components/sections/Progress/MatchClock.astro +166 -0
  222. package/src/components/sections/Progress/compact.astro +150 -0
  223. package/src/components/sections/Progress/index.astro +32 -0
  224. package/src/components/sections/Progress/match.astro +126 -0
  225. package/src/components/sections/Progress/ring.astro +179 -0
  226. package/src/components/sections/QuickDonate/DonateCard.astro +149 -0
  227. package/src/components/sections/QuickDonate/Picker.astro +95 -0
  228. package/src/components/sections/QuickDonate/band.astro +164 -0
  229. package/src/components/sections/QuickDonate/bar.astro +208 -0
  230. package/src/components/sections/QuickDonate/donate.ts +126 -0
  231. package/src/components/sections/QuickDonate/hero.astro +143 -0
  232. package/src/components/sections/QuickDonate/index.astro +73 -0
  233. package/src/components/sections/QuickDonate/jar.astro +225 -0
  234. package/src/components/sections/QuickDonate/ladder.astro +248 -0
  235. package/src/components/sections/QuoteStrip/carousel.astro +340 -0
  236. package/src/components/sections/QuoteStrip/index.astro +58 -0
  237. package/src/components/sections/QuoteStrip/logos.astro +226 -0
  238. package/src/components/sections/QuoteStrip/quotes.ts +61 -0
  239. package/src/components/sections/QuoteStrip/single.astro +92 -0
  240. package/src/components/sections/QuoteStrip/ticker.astro +319 -0
  241. package/src/components/sections/QuoteStrip/wall.astro +113 -0
  242. package/src/components/sections/Resources/band.astro +93 -0
  243. package/src/components/sections/Resources/featured.astro +239 -0
  244. package/src/components/sections/Resources/index.astro +225 -0
  245. package/src/components/sections/Resources/resources.ts +92 -0
  246. package/src/components/sections/SampleBallot/Position.astro +39 -0
  247. package/src/components/sections/SampleBallot/ballot.ts +92 -0
  248. package/src/components/sections/SampleBallot/cards.astro +299 -0
  249. package/src/components/sections/SampleBallot/index.astro +326 -0
  250. package/src/components/sections/SampleBallot/measures.astro +172 -0
  251. package/src/components/sections/Scorecard/grades.astro +141 -0
  252. package/src/components/sections/Scorecard/index.astro +294 -0
  253. package/src/components/sections/Scorecard/promise.astro +167 -0
  254. package/src/components/sections/Scorecard/votes.ts +83 -0
  255. package/src/components/sections/SectionHead.astro +31 -0
  256. package/src/components/sections/Services/Button.astro +24 -0
  257. package/src/components/sections/Services/Check.astro +12 -0
  258. package/src/components/sections/Services/Includes.astro +42 -0
  259. package/src/components/sections/Services/compare.astro +328 -0
  260. package/src/components/sections/Services/index.astro +187 -0
  261. package/src/components/sections/Services/list.astro +181 -0
  262. package/src/components/sections/Services/services.ts +80 -0
  263. package/src/components/sections/ShareKit/Actions.astro +71 -0
  264. package/src/components/sections/ShareKit/Buttons.astro +62 -0
  265. package/src/components/sections/ShareKit/compact.astro +123 -0
  266. package/src/components/sections/ShareKit/index.astro +160 -0
  267. package/src/components/sections/ShareKit/share.ts +60 -0
  268. package/src/components/sections/ShareKit/strip.astro +173 -0
  269. package/src/components/sections/SignupCapture/band.astro +7 -0
  270. package/src/components/sections/SignupCapture/index.astro +103 -0
  271. package/src/components/sections/SignupCapture/inline.astro +7 -0
  272. package/src/components/sections/SocialFeed/index.astro +34 -0
  273. package/src/components/sections/StatCards/feature.astro +143 -0
  274. package/src/components/sections/StatCards/index.astro +51 -0
  275. package/src/components/sections/StatCards/ribbon.astro +113 -0
  276. package/src/components/sections/StatCards/wall.astro +177 -0
  277. package/src/components/sections/Store/featured.astro +14 -0
  278. package/src/components/sections/Store/index.astro +14 -0
  279. package/src/components/sections/Stories/Status.astro +42 -0
  280. package/src/components/sections/Stories/StoryCards.astro +171 -0
  281. package/src/components/sections/Stories/cards.astro +42 -0
  282. package/src/components/sections/Stories/index.astro +238 -0
  283. package/src/components/sections/Stories/stories.ts +97 -0
  284. package/src/components/sections/Stories/timeline.astro +135 -0
  285. package/src/components/sections/TeamGrid/board.astro +280 -0
  286. package/src/components/sections/TeamGrid/index.astro +71 -0
  287. package/src/components/sections/TeamGrid/list.astro +306 -0
  288. package/src/components/sections/TeamGrid/people.ts +178 -0
  289. package/src/components/sections/VideoEmbed/index.astro +52 -0
  290. package/src/components/sections/VideoEmbed/landscape.astro +7 -0
  291. package/src/components/sections/VideoEmbed/portrait.astro +7 -0
  292. package/src/components/sections/VideoEmbed/square.astro +7 -0
  293. package/src/components/sections/VoterTools/DaysLeft.astro +33 -0
  294. package/src/components/sections/VoterTools/Lookup.astro +43 -0
  295. package/src/components/sections/VoterTools/dates.astro +153 -0
  296. package/src/components/sections/VoterTools/index.astro +231 -0
  297. package/src/components/sections/VoterTools/polling.astro +144 -0
  298. package/src/components/sections/VoterTools/voter-tools.ts +71 -0
  299. package/src/components/sections/index.ts +373 -0
  300. package/src/components/sections/modules/Headed.astro +39 -0
  301. package/src/components/sections/modules/ModuleFrame.astro +181 -0
  302. package/src/components/store/CollectionPage.astro +40 -0
  303. package/src/components/store/ProductCard.astro +32 -0
  304. package/src/components/store/ProductGrid.astro +16 -0
  305. package/src/components/store/ProductPage.astro +146 -0
  306. package/src/components/store/StorePage.astro +137 -0
  307. package/src/components/store/StoreScript.astro +572 -0
  308. package/src/components/volunteer/ShiftLive.astro +90 -0
  309. package/src/components/volunteer/detail.astro +247 -0
  310. package/src/components/volunteer/list.astro +298 -0
  311. package/src/components/volunteer/props.ts +21 -0
  312. package/src/env.d.ts +22 -0
  313. package/src/index.d.ts +10 -0
  314. package/src/index.js +63 -0
  315. package/src/layouts/Site.astro +387 -0
  316. package/src/lib/academy.ts +146 -0
  317. package/src/lib/brand.ts +534 -0
  318. package/src/lib/chrome.ts +121 -0
  319. package/src/lib/donate-frame.ts +104 -0
  320. package/src/lib/entries.ts +190 -0
  321. package/src/lib/env.ts +34 -0
  322. package/src/lib/event-map-draw.ts +91 -0
  323. package/src/lib/events.ts +476 -0
  324. package/src/lib/fonts.ts +116 -0
  325. package/src/lib/footer.ts +24 -0
  326. package/src/lib/format.ts +160 -0
  327. package/src/lib/geo.ts +131 -0
  328. package/src/lib/live.ts +55 -0
  329. package/src/lib/menu.ts +48 -0
  330. package/src/lib/petition-text.ts +29 -0
  331. package/src/lib/reading.ts +17 -0
  332. package/src/lib/regions.ts +215 -0
  333. package/src/lib/section.ts +105 -0
  334. package/src/lib/shifts.ts +187 -0
  335. package/src/lib/store.ts +521 -0
  336. package/src/lib/stream-time.ts +20 -0
  337. package/src/lib/stream.ts +141 -0
  338. package/src/lib/visitor.ts +54 -0
  339. package/src/routes/catch-all.astro +435 -0
  340. package/src/routes/form.astro +30 -0
  341. package/src/routes/live.astro +49 -0
  342. package/src/routes/not-found.astro +18 -0
  343. package/src/routes/preview.astro +60 -0
  344. package/src/routes/setup.astro +62 -0
  345. package/src/routes/volunteer-shift.astro +61 -0
  346. package/src/styles/entries.css +784 -0
  347. package/src/styles/site.css +1910 -0
  348. package/src/styles/store.css +634 -0
  349. package/src/template.ts +182 -0
@@ -0,0 +1,137 @@
1
+ ---
2
+ // A lesson's script (board D3), for any layout that draws a lesson: placed
3
+ // inside the lesson's root (the element with class `ls`), it reads that
4
+ // root's `data-lesson`, `data-course-slug`, `data-lesson-slug`,
5
+ // `data-progress` and `data-resume`, its <video> or YouTube frame and the two
6
+ // Mark complete forms under `.ls-complete` (the first marks it, the second
7
+ // marks it as not done; each is shown while the other is hidden). It picks
8
+ // the file up at the saved place, trades the 1080p copy for the 720p one
9
+ // (`data-src-720`) on a viewport 768px wide or narrower, sends both forms
10
+ // through fetch and swaps them in place (each form posts on its own when
11
+ // fetch fails), saves the place on pause and every 15 seconds of play, and
12
+ // marks the lesson at the video's end: the file through the <video>
13
+ // events, YouTube through its player API, loaded only when the root carries
14
+ // `data-lesson` and the lesson is on YouTube. Without `data-lesson` only the
15
+ // resume and the 720p swap run. Put it in for a visitor, or for a file
16
+ // with copies.
17
+ ---
18
+ <script is:inline>
19
+ ;(function (root) {
20
+ if (!root) return
21
+ var video = root.querySelector('video')
22
+ var tube = root.querySelector('iframe[data-provider="youtube"]')
23
+ var resume = Number(root.getAttribute('data-resume')) || 0
24
+ // The resume listener is on before the copy below loads, so the saved place applies to it.
25
+ if (video && resume > 0) {
26
+ video.addEventListener('loadedmetadata', function () {
27
+ if (!video.duration || resume < video.duration - 3) video.currentTime = resume
28
+ })
29
+ }
30
+ // The 720p copy on a narrow viewport, picked once at load; a resize mid-play keeps what is playing.
31
+ var narrow = video && video.getAttribute('data-src-720')
32
+ if (narrow && window.matchMedia && window.matchMedia('(max-width: 768px)').matches && video.currentSrc !== narrow && video.getAttribute('src') !== narrow) {
33
+ video.src = narrow
34
+ video.load()
35
+ }
36
+ if (!root.hasAttribute('data-lesson') || !window.fetch) return
37
+ var path = root.getAttribute('data-progress')
38
+ var course = root.getAttribute('data-course-slug')
39
+ var lesson = root.getAttribute('data-lesson-slug')
40
+ var forms = root.querySelectorAll('.ls-complete form')
41
+ var send = function (body, keep) {
42
+ body.course = course
43
+ body.lesson = lesson
44
+ return fetch(path, {
45
+ method: 'POST',
46
+ credentials: 'same-origin',
47
+ headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
48
+ body: JSON.stringify(body),
49
+ keepalive: !!keep,
50
+ })
51
+ }
52
+ var show = function (done) {
53
+ forms[0].hidden = done
54
+ forms[1].hidden = !done
55
+ }
56
+ for (var f = 0; f < forms.length; f++) {
57
+ forms[f].addEventListener('submit', function (event) {
58
+ var form = event.currentTarget
59
+ var done = form.getAttribute('data-complete') === 'true'
60
+ event.preventDefault()
61
+ send({ completed: done })
62
+ .then(function (res) {
63
+ if (!res.ok) throw new Error(String(res.status))
64
+ show(done)
65
+ forms[done ? 1 : 0].querySelector('button').focus()
66
+ })
67
+ .catch(function () {
68
+ form.submit()
69
+ })
70
+ })
71
+ }
72
+ var finish = function () {
73
+ send({ completed: true })
74
+ .then(function (res) {
75
+ if (res.ok) show(true)
76
+ })
77
+ .catch(function () {})
78
+ }
79
+ if (video) {
80
+ var last = 0
81
+ var save = function (keep) {
82
+ var at = Math.floor(video.currentTime)
83
+ last = Date.now()
84
+ if (at > 0 && !video.ended) send({ position_seconds: at }, keep).catch(function () {})
85
+ }
86
+ video.addEventListener('play', function () {
87
+ last = Date.now()
88
+ })
89
+ video.addEventListener('timeupdate', function () {
90
+ if (!video.paused && Date.now() - last >= 15000) save(false)
91
+ })
92
+ video.addEventListener('pause', function () {
93
+ if (!video.ended) save(true)
94
+ })
95
+ video.addEventListener('ended', finish)
96
+ return
97
+ }
98
+ if (!tube) return
99
+ // YouTube's player API (enablejsapi=1 on the frame): the place on pause and every 15 seconds of play, the lesson at the end.
100
+ var player = null
101
+ var timer = null
102
+ var saveTube = function (keep) {
103
+ if (!player || typeof player.getCurrentTime !== 'function') return
104
+ var at = Math.floor(player.getCurrentTime())
105
+ if (at > 0) send({ position_seconds: at }, keep).catch(function () {})
106
+ }
107
+ var onState = function (event) {
108
+ var YT = window.YT
109
+ if (!YT) return
110
+ if (timer) {
111
+ clearInterval(timer)
112
+ timer = null
113
+ }
114
+ if (event.data === YT.PlayerState.PLAYING) timer = setInterval(function () { saveTube(false) }, 15000)
115
+ else if (event.data === YT.PlayerState.PAUSED) saveTube(true)
116
+ else if (event.data === YT.PlayerState.ENDED) finish()
117
+ }
118
+ var start = function () {
119
+ player = new window.YT.Player(tube, { events: { onStateChange: onState } })
120
+ }
121
+ if (window.YT && window.YT.Player) {
122
+ start()
123
+ } else {
124
+ var queue = (window.__bgYouTubeReady = window.__bgYouTubeReady || [])
125
+ queue.push(start)
126
+ if (queue.length === 1) {
127
+ window.onYouTubeIframeAPIReady = function () {
128
+ for (var q = 0; q < queue.length; q++) queue[q]()
129
+ }
130
+ var tag = document.createElement('script')
131
+ tag.src = 'https://www.youtube.com/iframe_api'
132
+ tag.async = true
133
+ document.head.appendChild(tag)
134
+ }
135
+ }
136
+ })(document.currentScript.closest('.ls'))
137
+ </script>
@@ -0,0 +1,27 @@
1
+ ---
2
+ // Lesson · Player (board D3): the lesson at this address (lesson.ts) as
3
+ // LessonBody draws it, the course's rail at the right on a wide screen and
4
+ // after the lesson on a phone. Nothing is drawn without a lesson. The
5
+ // default layout; it draws `player` and any layout the kit has no file for.
6
+ import type { Section } from '@backgold/content'
7
+ import Band from '../Band.astro'
8
+ import LessonBody from './LessonBody.astro'
9
+ import { lessonOf, type LessonView } from './lesson'
10
+
11
+ interface Props {
12
+ section: Section
13
+ variant?: string
14
+ /** Drawn as the lesson's own page: its title is the <h1>. */
15
+ lead?: boolean
16
+ /** The lesson, already read (the lesson route); left out, the section reads it. */
17
+ view?: LessonView | null
18
+ }
19
+
20
+ const { section, lead = false } = Astro.props
21
+ const view = Astro.props.view !== undefined ? Astro.props.view : await lessonOf(section, Astro)
22
+ ---
23
+ {view && (
24
+ <Band section={section} class="lesson lesson-player">
25
+ <LessonBody view={view} section={section} layout="player" lead={lead} />
26
+ </Band>
27
+ )}
@@ -0,0 +1,233 @@
1
+ // A Lesson as its player and reading layouts draw it (board D3), from the
2
+ // Content API's lesson answer (`GET /courses/:course/:lesson`) read through
3
+ // lib/visitor.ts: as the visitor while one is signed in, else as the public
4
+ // reader.
5
+ //
6
+ // The lesson is the one at this address (`/<courses base>/<course>/<lesson>`,
7
+ // Course/course.ts). On a page that pins a course (`options.courseSlug`) and
8
+ // is not at a lesson's address, it is the visitor's next lesson, else the
9
+ // course's first.
10
+ //
11
+ // A locked lesson is what the api left of it: its title, cover, length and
12
+ // place in the course, no video and no notes. The page draws its teaser and
13
+ // the door the lock names: `signed_in` the sign-in door (the newsletter box
14
+ // unticked, riding along to the sign-in as `newsletter=1`), `members` the
15
+ // Join door, `tag` the door that says to ask. Which door is the api's call
16
+ // (`lesson.lock.reason`); nothing here decides who qualifies.
17
+
18
+ import type { Section } from '@backgold/content'
19
+ import type { Areas, CourseLesson, CourseProgress, EntryLock, LessonResponse, Visitor } from '#contract/content-api'
20
+ import { renderMarkdown, safeHref, safeSrc, signInHref, signOutHref } from '@backgold/astro/server'
21
+ import { playerOf } from '../../../lib/entries'
22
+ import { countAndLength, inSentence, lessonSignInTitle, lockWordOf } from '../../../lib/academy'
23
+ import { listOf, text } from '../../../lib/format'
24
+ import { academyReads } from '../../../lib/visitor'
25
+ import { pinnedCourseOf, routeOf, type AcademyContext } from '../Course/course'
26
+
27
+ export interface RailRow {
28
+ n: number
29
+ slug: string
30
+ name: string
31
+ href: string | null
32
+ seconds: number | null
33
+ /** The lesson's still (its cover), else the course's cover; null with neither, for a thumbnail beside the row. */
34
+ cover: string | null
35
+ /** This lesson, the one on the page. */
36
+ now: boolean
37
+ done: boolean
38
+ locked: boolean
39
+ /** Where this visitor stopped in it, in seconds; null signed out, once finished, or without a saved place. */
40
+ place: number | null
41
+ /** The row's word: Done, Now, Members, a tag's name, Free, Sign in; null where the length stands alone. */
42
+ word: string | null
43
+ }
44
+
45
+ export type Door =
46
+ | { kind: 'sign-in'; returnPath: string; title: string; newsletter: string }
47
+ | { kind: 'join'; n: number; orgName: string | null; name: string | null; signOut: string; signIn: string }
48
+ | { kind: 'tag'; tag: string | null; orgName: string | null }
49
+
50
+ export interface Neighbor {
51
+ n: number
52
+ name: string
53
+ href: string | null
54
+ }
55
+
56
+ export type LessonVideo =
57
+ | { kind: 'file'; src: string; poster: string | null; sources: { '720': string | null; '1080': string | null } | null }
58
+ | { kind: 'embed'; src: string; provider: 'youtube' | 'vimeo' }
59
+
60
+ export interface LessonView {
61
+ courseSlug: string
62
+ slug: string
63
+ n: number
64
+ total: number
65
+ name: string
66
+ seconds: number | null
67
+ courseTitle: string
68
+ courseHref: string | null
69
+ coursesHref: string | null
70
+ /**
71
+ * The video, for a reader who may watch it; null when locked or not up yet.
72
+ * A `file` is the org's own upload, played in the browser's player:
73
+ * `sources` are its copies, 720p for a narrow viewport, 1080p for a wide
74
+ * one; the original at `src` is the fallback and the download link, and
75
+ * `sources` is null until the copies are ready (a size the source was too
76
+ * small for is null). An `embed` is a YouTube or Vimeo address (an imported
77
+ * video, lib/entries.ts playerOf) played in that player at `src`;
78
+ * `provider` says which, since only YouTube's player reports its progress.
79
+ */
80
+ video: LessonVideo | null
81
+ /** The cover, for the locked teaser. */
82
+ cover: string | null
83
+ locked: boolean
84
+ /** The teaser's words over the cover: "Sign in to watch", "For members". */
85
+ lockWord: string | null
86
+ door: Door | null
87
+ visitor: Visitor | null
88
+ completed: boolean
89
+ /** Where this visitor stopped, in seconds; null without one, or once finished. */
90
+ resumeAt: number | null
91
+ /** The notes (the lesson's body) as sanitized HTML; null when it has none or is locked. */
92
+ notes: string | null
93
+ previous: Neighbor | null
94
+ next: Neighbor | null
95
+ rail: {
96
+ rows: RailRow[]
97
+ progress: CourseProgress | null
98
+ /** Signed out: "12 lessons · 1 h 1 min" and "Lesson 1 is free". */
99
+ count: string
100
+ free: string | null
101
+ }
102
+ /** This page's address, for the doors' and the progress form's way back. */
103
+ path: string
104
+ }
105
+
106
+ /** The newsletter the sign-in door offers: the first email sign-up an area holds, by its kicker ("The Harbor letter"). */
107
+ function newsletterOf(areas: Areas | null | undefined): string {
108
+ for (const items of Object.values(areas ?? {})) {
109
+ for (const item of items) {
110
+ for (const section of item.sections) {
111
+ const name = section.type === 'SignupCapture' ? text(section.copy.kicker) : null
112
+ if (name) return inSentence(name)
113
+ }
114
+ }
115
+ }
116
+ return 'the newsletter'
117
+ }
118
+
119
+ /** The lock's door; `title` is what the portal's sign-in door names ("Lesson 3: Read a budget, in Foundations"). */
120
+ function doorOf(lock: EntryLock, n: number, visitor: Visitor | null, path: string, title: string, areas: Areas | null | undefined, orgName: string | null): Door {
121
+ if (lock.reason === 'members') {
122
+ const signIn = signInHref(path, title)
123
+ return { kind: 'join', n, orgName, name: visitor ? (visitor.first_name ?? visitor.email) : null, signOut: signOutHref(signIn), signIn }
124
+ }
125
+ if (lock.reason === 'tag') return { kind: 'tag', tag: lock.tag_label, orgName }
126
+ return { kind: 'sign-in', returnPath: path, title, newsletter: newsletterOf(areas) }
127
+ }
128
+
129
+ /** A locked row's word: Sign in, the tag's name ("Fall Cohort"), else Members. */
130
+ function railLockWordOf(lock: EntryLock | null): string {
131
+ if (lock?.reason === 'signed_in') return 'Sign in'
132
+ if (lock?.reason === 'tag') return lock.tag_label?.trim() || 'By invitation'
133
+ return 'Members'
134
+ }
135
+
136
+ function railWordOf(lesson: CourseLesson, now: boolean, signedIn: boolean): string | null {
137
+ if (lesson.locked) {
138
+ const word = railLockWordOf(lesson.lock)
139
+ return now ? `Now · ${word}` : word
140
+ }
141
+ if (now) return 'Now'
142
+ if (signedIn) return lesson.completed ? 'Done' : null
143
+ return lesson.access === 'public' ? 'Free' : null
144
+ }
145
+
146
+ const neighborOf = (lessons: CourseLesson[], slug: string | undefined): Neighbor | null => {
147
+ const i = slug ? lessons.findIndex((l) => l.slug === slug) : -1
148
+ return i === -1 ? null : { n: i + 1, name: lessons[i]!.title, href: safeHref(lessons[i]!.url) }
149
+ }
150
+
151
+ /** The lesson as the layouts draw it, for this visitor (null signed out), this page's address and the organization's name. */
152
+ export function lessonView(answer: LessonResponse, visitor: Visitor | null, path: string, orgName: string | null): LessonView {
153
+ const { lesson, course } = answer
154
+ const lessons = [...course.lessons].sort((a, b) => a.position - b.position)
155
+ const index = lessons.findIndex((l) => l.slug === lesson.slug)
156
+ const n = index + 1
157
+ const row = lessons[index]
158
+ const locked = lesson.locked === true || row?.locked === true
159
+ const lock = lesson.lock ?? row?.lock ?? null
160
+ const src = locked ? null : safeSrc(lesson.media_url)
161
+ const cover = lesson.hero ? safeSrc(lesson.hero.url) : null
162
+ const copies = locked ? null : lesson.renditions
163
+ const sources = copies ? { '720': safeSrc(copies['720']), '1080': safeSrc(copies['1080']) } : null
164
+ const player = src ? playerOf(src) : null
165
+ const completed = visitor !== null && row?.completed === true
166
+ const position = visitor && !completed ? (row?.position_seconds ?? null) : null
167
+ const free = lessons.flatMap((l, i) => (l.access === 'public' ? [String(i + 1)] : []))
168
+ const notes = !locked && lesson.body.markdown.trim() ? renderMarkdown(lesson.body.markdown) : ''
169
+ const courseCover = course.hero ? safeSrc(course.hero.url) : null
170
+ return {
171
+ courseSlug: course.slug,
172
+ slug: lesson.slug,
173
+ n: n || 1,
174
+ total: lessons.length,
175
+ name: lesson.title,
176
+ seconds: lesson.duration_seconds ?? row?.duration_seconds ?? null,
177
+ courseTitle: course.title,
178
+ courseHref: safeHref(course.url),
179
+ coursesHref: safeHref(course.url.replace(/\/[^/]+\/?$/, '')),
180
+ video: !src
181
+ ? null
182
+ : player
183
+ ? { kind: 'embed', src: player, provider: player.includes('vimeo.com') ? 'vimeo' : 'youtube' }
184
+ : { kind: 'file', src, poster: cover, sources: sources && (sources['720'] || sources['1080']) ? sources : null },
185
+ cover,
186
+ locked,
187
+ lockWord: locked && lock ? lockWordOf(lock) : null,
188
+ door: locked && lock ? doorOf(lock, n, visitor, path, lessonSignInTitle(answer), answer.areas, orgName) : null,
189
+ visitor,
190
+ completed,
191
+ resumeAt: position !== null && position > 0 ? position : null,
192
+ notes: notes.trim() ? notes : null,
193
+ previous: neighborOf(lessons, answer.previous?.slug),
194
+ next: neighborOf(lessons, answer.next?.slug),
195
+ rail: {
196
+ rows: lessons.map((l, i) => ({
197
+ n: i + 1,
198
+ slug: l.slug,
199
+ name: l.title,
200
+ href: safeHref(l.url),
201
+ seconds: l.duration_seconds,
202
+ cover: (l.hero ? safeSrc(l.hero.url) : null) ?? courseCover,
203
+ now: l.slug === lesson.slug,
204
+ done: visitor !== null && l.completed,
205
+ locked: l.locked,
206
+ place: visitor !== null && !l.completed && l.position_seconds !== null && l.position_seconds > 0 ? l.position_seconds : null,
207
+ word: railWordOf(l, l.slug === lesson.slug, visitor !== null),
208
+ })),
209
+ progress: visitor ? course.progress : null,
210
+ count: countAndLength(course.lesson_count || lessons.length, course.total_seconds),
211
+ free: free.length === 0 ? null : free.length === 1 ? `Lesson ${free[0]} is free` : `Lessons ${listOf(free)} are free`,
212
+ },
213
+ path,
214
+ }
215
+ }
216
+
217
+ /** The lesson this section names (course.ts's address or pin), read for this visitor; null when there is none. */
218
+ export async function lessonOf(section: Section, astro: AcademyContext): Promise<LessonView | null> {
219
+ const reads = academyReads(astro)
220
+ const route = await routeOf(astro)
221
+ const pinned = pinnedCourseOf(section)
222
+ const courseSlug = pinned ?? route?.course ?? null
223
+ if (!courseSlug) return null
224
+ let lessonSlug = route && route.course === courseSlug ? route.lesson : null
225
+ if (!lessonSlug) {
226
+ const course = (await reads.course(courseSlug))?.course
227
+ const lessons = [...(course?.lessons ?? [])].sort((a, b) => a.position - b.position)
228
+ lessonSlug = (reads.visitor ? course?.progress?.next_lesson_slug : null) ?? lessons[0]?.slug ?? null
229
+ }
230
+ if (!lessonSlug) return null
231
+ const answer = await reads.lesson(courseSlug, lessonSlug)
232
+ return answer ? lessonView(answer, reads.visitor, astro.url.pathname, reads.orgName) : null
233
+ }
@@ -0,0 +1,21 @@
1
+ ---
2
+ // Lesson · Reading: the same lesson held to the reading column, for a lesson
3
+ // that is mostly its notes: the player, the head, completion and the notes
4
+ // in one column, Previous and Next, then the course's rail last
5
+ // (LessonBody, lesson.ts). Nothing is drawn without a lesson.
6
+ import type { ComponentProps } from 'astro/types'
7
+ import type Default from './index.astro'
8
+ import Band from '../Band.astro'
9
+ import LessonBody from './LessonBody.astro'
10
+ import { lessonOf } from './lesson'
11
+
12
+ type Props = ComponentProps<typeof Default>
13
+
14
+ const { section, lead = false } = Astro.props
15
+ const view = Astro.props.view !== undefined ? Astro.props.view : await lessonOf(section, Astro)
16
+ ---
17
+ {view && (
18
+ <Band section={section} class="lesson lesson-reading">
19
+ <LessonBody view={view} section={section} layout="reading" lead={lead} />
20
+ </Band>
21
+ )}
@@ -0,0 +1,19 @@
1
+ ---
2
+ // The coverage line both Map layouts draw under the heading (src/lib/
3
+ // regions.ts coverage): the count in the text colour, then the status label
4
+ // it counts, muted, as written ("8 of 254 counties · Organized").
5
+ import type { Coverage } from '../../../lib/regions'
6
+
7
+ interface Props {
8
+ coverage: Coverage
9
+ }
10
+
11
+ const { coverage } = Astro.props
12
+ ---
13
+ <p class="lede"><span class="coverage-count">{coverage.count}</span> · {coverage.label}</p>
14
+
15
+ <style>
16
+ .coverage-count {
17
+ color: var(--ink);
18
+ }
19
+ </style>
@@ -0,0 +1,109 @@
1
+ ---
2
+ // The map both Map layouts draw when the section has its geometry
3
+ // (src/lib/regions.ts drawMap): one path per place in BackGold's geometry
4
+ // for the section's set, drawn on the server, coloured by its row's status
5
+ // (lit in the main call's colour, dark as the open ground, starting
6
+ // between), with the place's name and status as its tooltip; a lit place
7
+ // with a link opens it. A framed map (`focusRegion`) dims every other place.
8
+ // The key follows, with a starting entry only when a row is starting. The
9
+ // directory under it names every lit and starting place and counts the
10
+ // rest, so the map and its key are hidden from screen readers and the map's
11
+ // links (lit places only) are out of the tab order: a keyboard meets each
12
+ // link once, in the directory.
13
+ import type { DrawnMap, MapLabels } from '../../../lib/regions'
14
+
15
+ interface Props {
16
+ drawn: DrawnMap
17
+ labels: MapLabels
18
+ /** True when a row is starting: the key gets its entry. */
19
+ starting: boolean
20
+ /** 'large' for the map layout, 'compact' over the directory's cards. */
21
+ size: 'large' | 'compact'
22
+ }
23
+
24
+ const { drawn, labels, starting, size } = Astro.props
25
+ ---
26
+ <div class:list={['region-map', `region-map-${size}`]} aria-hidden="true">
27
+ <svg class="region-map-svg" viewBox={drawn.viewBox} preserveAspectRatio="xMidYMid meet" focusable="false">
28
+ {drawn.regions.map((r) => {
29
+ const classes = ['region', `region-${r.status}`, r.focus && 'region-focus', drawn.focus && !r.focus && 'region-dim']
30
+ const title = `${r.label} · ${labels[r.status]}`
31
+ return r.link ? (
32
+ <a href={r.link.href} rel={r.link.rel} tabindex="-1"><path class:list={classes} d={r.d}><title>{title}</title></path></a>
33
+ ) : (
34
+ <path class:list={classes} d={r.d}><title>{title}</title></path>
35
+ )
36
+ })}
37
+ </svg>
38
+ <p class="key">
39
+ <span><i class="key-swatch key-swatch-lit"></i>{labels.lit}</span>
40
+ {starting && <span><i class="key-swatch key-swatch-starting"></i>{labels.starting}</span>}
41
+ <span><i class="key-swatch"></i>{labels.dark}</span>
42
+ </p>
43
+ </div>
44
+
45
+ <style>
46
+ .region-map {
47
+ --open-ground: color-mix(in srgb, var(--ink) 9%, var(--bg-band-background));
48
+ --starting-fill: color-mix(in srgb, var(--button) 45%, var(--open-ground));
49
+ margin-top: 1.5rem;
50
+ }
51
+ .region-map-svg {
52
+ display: block;
53
+ width: 100%;
54
+ height: auto;
55
+ max-height: min(80vh, 46rem);
56
+ }
57
+ .region-map-compact .region-map-svg {
58
+ max-height: min(60vh, 30rem);
59
+ }
60
+ .region {
61
+ fill: var(--open-ground);
62
+ stroke: var(--bg-band-background);
63
+ stroke-width: 0.75px;
64
+ stroke-linejoin: round;
65
+ vector-effect: non-scaling-stroke;
66
+ }
67
+ .region-lit {
68
+ fill: var(--button);
69
+ }
70
+ .region-starting {
71
+ fill: var(--starting-fill);
72
+ }
73
+ a:hover .region-lit {
74
+ fill: color-mix(in srgb, var(--button) 80%, var(--ink));
75
+ }
76
+ .region-dim {
77
+ opacity: 0.7;
78
+ }
79
+ .region-focus {
80
+ stroke: var(--ink);
81
+ stroke-width: 2px;
82
+ }
83
+ .key {
84
+ display: flex;
85
+ flex-wrap: wrap;
86
+ justify-content: center;
87
+ gap: 0.5rem 1.25rem;
88
+ margin: 0.75rem 0 0;
89
+ color: var(--muted);
90
+ font-size: var(--text-sm);
91
+ }
92
+ .key-swatch {
93
+ display: inline-block;
94
+ width: 0.75rem;
95
+ height: 0.75rem;
96
+ margin-right: 0.375rem;
97
+ border-radius: 0.1875rem;
98
+ vertical-align: -0.0625rem;
99
+ background: var(--open-ground);
100
+ border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
101
+ }
102
+ .key-swatch-lit {
103
+ background: var(--button);
104
+ border-color: var(--button);
105
+ }
106
+ .key-swatch-starting {
107
+ background: var(--starting-fill);
108
+ }
109
+ </style>