@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,436 @@
1
+ ---
2
+ // EventsList · Map (REPORT §3, "Upcoming events: add a Map view"): the
3
+ // section head (the kicker, the heading and the "All events" link), then the
4
+ // events as a list beside a map with a numbered pin for each event that has a
5
+ // pinned location. Each row is the shifts idiom: a date tile, the event's
6
+ // number when it has a pin, the title linking to the event's page on this
7
+ // site (which frames BackGold's RSVP and tickets), the time and the place with
8
+ // a quiet "Add to calendar" link to its calendar file, the type as a chip, the
9
+ // live counts (filled in by LiveCounts after the page loads; empty without
10
+ // scripts) and whether it still takes registrations. `options.actions`
11
+ // 'buttons' adds the row's button to the same page ("RSVP", "Get tickets",
12
+ // "Details" in the outline once registration has closed); 'link' (or none)
13
+ // leaves the title the only link. Each pin is a link to its event's page,
14
+ // named by the event's title.
15
+ //
16
+ // The map is a mosaic of OpenStreetMap's own tiles, worked out here on the
17
+ // server: the template's map runtime (Map/RegionMap.astro, lib/geo.ts) draws
18
+ // county and district outlines in their own drawing space with no projection,
19
+ // so a latitude and longitude cannot be placed on it. In Web Mercator, the
20
+ // map is a 3:2 window 512 tile pixels across, centred on the pins at the
21
+ // highest zoom (3 to 16; 14 for a single pin) that holds them all with about
22
+ // 15% room around them; it never touches more than 3 by 3 tiles. Each tile is
23
+ // an image the browser loads lazily from tile.openstreetmap.org, and each pin
24
+ // is placed by its projected position within the window. Nothing is fetched
25
+ // here and no script runs: OpenStreetMap is already the event page's map
26
+ // source. Its licence asks for the "© OpenStreetMap contributors" line under
27
+ // the map, which links to their copyright page.
28
+ //
29
+ // Wider screens put the list at the left and the map at the right, where it
30
+ // stays in view as the list scrolls; a phone shows the map first, then the
31
+ // list. An event with no pin is in the list only, unnumbered, as is a pin
32
+ // left outside the window when the pins spread wider than zoom 3 can hold.
33
+ // With no pinned event the list is drawn alone: no empty map. With no events
34
+ // the head stands over the section's empty-events line ("No upcoming events
35
+ // right now." when it has none); with neither events nor a heading nothing is
36
+ // drawn. While the tiles load, or when they cannot, the pins stand on the
37
+ // band's surface in their places.
38
+ import type { ComponentProps } from 'astro/types'
39
+ import type Default from './index.astro'
40
+ import Band from '../Band.astro'
41
+ import LiveCounts from './LiveCounts.astro'
42
+ import SectionHead from '../SectionHead.astro'
43
+ import { actionsOf, eventsOf, type EventRow } from './events'
44
+ import { links } from '../../../lib/section'
45
+ import { text } from '../../../lib/format'
46
+
47
+ type Props = ComponentProps<typeof Default>
48
+
49
+ const { section } = Astro.props
50
+ const heading = text(section.copy.heading)
51
+ const invitation = text(section.copy.eventsEmptyCta)
52
+ const buttons = actionsOf(section) === 'buttons'
53
+ const events = eventsOf(section)
54
+
55
+ const TILE = 256
56
+ const MIN_ZOOM = 3
57
+ const MAX_ZOOM = 16
58
+ const SINGLE_ZOOM = 14
59
+ /**
60
+ * The map's window in tile pixels, 3:2. At most 512 across and down, so it
61
+ * never touches more than 3 tiles each way wherever it falls on the grid.
62
+ */
63
+ const VIEW_W = 512
64
+ const VIEW_H = 344
65
+ /** Room left around the pins: 15% of their spread, and never less than a pin's width at the smallest scale. */
66
+ const PAD_SHARE = 0.15
67
+ const PAD_MIN = 32
68
+
69
+ const worldX = (lng: number, z: number) => ((lng + 180) / 360) * TILE * 2 ** z
70
+ const worldY = (lat: number, z: number) => {
71
+ const s = Math.sin((Math.max(-85.0511, Math.min(85.0511, lat)) * Math.PI) / 180)
72
+ return (0.5 - Math.log((1 + s) / (1 - s)) / (4 * Math.PI)) * TILE * 2 ** z
73
+ }
74
+ const fits = (min: number, max: number, view: number) => max - min + 2 * Math.max((max - min) * PAD_SHARE, PAD_MIN) <= view
75
+
76
+ type Placed = EventRow & { lat: number; lng: number }
77
+
78
+ interface Pin {
79
+ n: number
80
+ event: EventRow
81
+ /** The pin's place within the window, as percentages from its left and top. */
82
+ left: number
83
+ top: number
84
+ }
85
+
86
+ interface Mosaic {
87
+ cols: number
88
+ /** Where the tile grid sits within the window, and how wide it is, as percentages of the window. */
89
+ left: number
90
+ top: number
91
+ width: number
92
+ tiles: { src: string | null }[]
93
+ pins: Pin[]
94
+ }
95
+
96
+ /**
97
+ * The window centred on the pins at the highest zoom that holds them all
98
+ * with room around them. Pins spread too far for zoom 3 get its window
99
+ * centred on them, and the ones outside it stay in the list unnumbered.
100
+ */
101
+ function mosaicOf(points: Placed[]): Mosaic | null {
102
+ if (points.length === 0) return null
103
+ const project = (z: number) => ({ xs: points.map((p) => worldX(p.lng, z)), ys: points.map((p) => worldY(p.lat, z)) })
104
+ let z = points.length === 1 ? SINGLE_ZOOM : MAX_ZOOM
105
+ let { xs, ys } = project(z)
106
+ while (z > MIN_ZOOM && !(fits(Math.min(...xs), Math.max(...xs), VIEW_W) && fits(Math.min(...ys), Math.max(...ys), VIEW_H))) {
107
+ z -= 1
108
+ ;({ xs, ys } = project(z))
109
+ }
110
+ const world = 2 ** z
111
+ const left = (Math.min(...xs) + Math.max(...xs)) / 2 - VIEW_W / 2
112
+ // Across, the world wraps; down, it ends at the poles.
113
+ const top = Math.max(0, Math.min(world * TILE - VIEW_H, (Math.min(...ys) + Math.max(...ys)) / 2 - VIEW_H / 2))
114
+ const tx = Math.floor(left / TILE)
115
+ const ty = Math.floor(top / TILE)
116
+ const cols = Math.floor((left + VIEW_W - 1) / TILE) - tx + 1
117
+ const rows = Math.floor((top + VIEW_H - 1) / TILE) - ty + 1
118
+ const tiles = Array.from({ length: cols * rows }, (_, i) => {
119
+ const x = (((tx + (i % cols)) % world) + world) % world
120
+ const y = ty + Math.floor(i / cols)
121
+ return { src: y >= 0 && y < world ? `https://tile.openstreetmap.org/${z}/${x}/${y}.png` : null }
122
+ })
123
+ const pins: Pin[] = []
124
+ points.forEach((event, i) => {
125
+ const x = xs[i]! - left
126
+ const y = ys[i]! - top
127
+ if (x >= 0 && x <= VIEW_W && y >= 0 && y <= VIEW_H) pins.push({ n: pins.length + 1, event, left: (x / VIEW_W) * 100, top: (y / VIEW_H) * 100 })
128
+ })
129
+ if (pins.length === 0) return null
130
+ return {
131
+ cols,
132
+ left: ((tx * TILE - left) / VIEW_W) * 100,
133
+ top: ((ty * TILE - top) / VIEW_H) * 100,
134
+ width: ((cols * TILE) / VIEW_W) * 100,
135
+ tiles,
136
+ pins,
137
+ }
138
+ }
139
+
140
+ const mosaic = mosaicOf(events.filter((e): e is Placed => e.lat !== null && e.lng !== null))
141
+ const numberOf = new Map<EventRow, number>(mosaic?.pins.map((p) => [p.event, p.n]) ?? [])
142
+ const pct = (n: number) => `${n.toFixed(3)}%`
143
+ ---
144
+ {(heading || events.length > 0) && (
145
+ <Band section={section} class="events events-map">
146
+ <SectionHead kicker={text(section.copy.kicker)} heading={heading} more={links(section)} />
147
+ {events.length > 0 ? (
148
+ <div class:list={['evm', { 'evm-with-map': mosaic }]}>
149
+ {mosaic && (
150
+ <figure class="evm-map" aria-label="Map of the events">
151
+ <div class="evm-mosaic">
152
+ <div class="evm-tiles" aria-hidden="true" style={`--cols: ${mosaic.cols}; left: ${pct(mosaic.left)}; top: ${pct(mosaic.top)}; width: ${pct(mosaic.width)}`}>
153
+ {mosaic.tiles.map((tile) => (tile.src ? <img src={tile.src} width="256" height="256" loading="lazy" decoding="async" alt="" /> : <span></span>))}
154
+ </div>
155
+ {mosaic.pins.map((pin) =>
156
+ pin.event.link ? (
157
+ <a class="evm-pin" href={pin.event.link.href} rel={pin.event.link.rel} aria-label={pin.event.title} style={`left: ${pct(pin.left)}; top: ${pct(pin.top)}`}>{pin.n}</a>
158
+ ) : (
159
+ <span class="evm-pin" aria-hidden="true" style={`left: ${pct(pin.left)}; top: ${pct(pin.top)}`}>{pin.n}</span>
160
+ ),
161
+ )}
162
+ </div>
163
+ <figcaption class="evm-credit">
164
+ <a href="https://www.openstreetmap.org/copyright" rel="noopener">© OpenStreetMap contributors</a>
165
+ </figcaption>
166
+ </figure>
167
+ )}
168
+ <ul class="evm-list" role="list">
169
+ {events.map((event) => (
170
+ <li class="evm-row">
171
+ {event.when && event.startsAt ? (
172
+ <time class="evm-tile" datetime={event.startsAt}>
173
+ <span class="evm-month" aria-hidden="true">{event.when.monthShort}</span>
174
+ <b aria-hidden="true">{event.when.day}</b>
175
+ {event.when.weekday && <span class="evm-weekday" aria-hidden="true">{event.when.weekday}</span>}
176
+ <span class="visually-hidden">{event.when.full}</span>
177
+ </time>
178
+ ) : (
179
+ <span class="evm-tile" aria-hidden="true"><b>–</b></span>
180
+ )}
181
+ <div class="evm-body">
182
+ <h3 class="evm-title">
183
+ {mosaic && numberOf.has(event) && <span class="evm-num" aria-hidden="true">{numberOf.get(event)}</span>}
184
+ {event.link ? <a href={event.link.href} rel={event.link.rel}>{event.title}</a> : event.title}
185
+ </h3>
186
+ {(event.when?.time || event.place || event.calendar) && (
187
+ <p class="evm-meta">
188
+ {[event.when?.time, event.place].filter(Boolean).join(' · ')}
189
+ {event.calendar && (
190
+ <>
191
+ {(event.when?.time || event.place) && ' · '}
192
+ <a href={event.calendar.href} rel={event.calendar.rel}>{event.calendar.label}<span class="visually-hidden">: {event.title}</span></a>
193
+ </>
194
+ )}
195
+ </p>
196
+ )}
197
+ {(event.type || event.id || event.closed) && (
198
+ <p class="evm-facts">
199
+ {event.type && <span class="chip chip-wash">{event.type}</span>}
200
+ {event.id && <span class="evm-live" data-bg-live={event.id}></span>}
201
+ {event.closed && <span class="evm-closed">Registration closed</span>}
202
+ </p>
203
+ )}
204
+ {buttons && event.action && (
205
+ <p class="evm-action">
206
+ <a class:list={['button', 'button-small', event.closed ? 'button-quiet' : 'button-2']} href={event.action.href} rel={event.action.rel}>
207
+ {event.action.label}<span class="visually-hidden">: {event.title}</span>
208
+ </a>
209
+ </p>
210
+ )}
211
+ </div>
212
+ </li>
213
+ ))}
214
+ </ul>
215
+ </div>
216
+ ) : (
217
+ <p class="evm-empty">{invitation ?? 'No upcoming events right now.'}</p>
218
+ )}
219
+ <LiveCounts />
220
+ </Band>
221
+ )}
222
+
223
+ <style>
224
+ /* A phone: the map first, then the list. */
225
+ .evm {
226
+ display: grid;
227
+ gap: 1.5rem;
228
+ }
229
+ .evm-map {
230
+ min-width: 0;
231
+ margin: 0;
232
+ }
233
+ /* The window onto the tiles: 3:2, as wide as its column. */
234
+ .evm-mosaic {
235
+ position: relative;
236
+ aspect-ratio: 512 / 344;
237
+ overflow: hidden;
238
+ border: 1px solid var(--line);
239
+ border-radius: var(--radius-card);
240
+ background: var(--surface);
241
+ box-shadow: var(--shadow);
242
+ }
243
+ .evm-tiles {
244
+ position: absolute;
245
+ display: grid;
246
+ grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
247
+ }
248
+ .evm-tiles > * {
249
+ display: block;
250
+ width: 100%;
251
+ height: auto;
252
+ aspect-ratio: 1;
253
+ }
254
+ /* A numbered pin in the band's button inks, centred on its place, with a hairline of the surface so it reads on any tile. */
255
+ .evm-pin {
256
+ position: absolute;
257
+ display: grid;
258
+ place-items: center;
259
+ width: 1.75rem;
260
+ height: 1.75rem;
261
+ border: 1px solid var(--surface);
262
+ border-radius: var(--pill);
263
+ background: var(--button);
264
+ box-shadow: var(--shadow);
265
+ color: var(--button-ink);
266
+ font-size: var(--text-sm);
267
+ font-weight: 800;
268
+ line-height: 1;
269
+ text-decoration: none;
270
+ transform: translate(-50%, -50%);
271
+ }
272
+ /* A 44px target around the 28px pin. */
273
+ a.evm-pin::before {
274
+ content: '';
275
+ position: absolute;
276
+ inset: -0.5rem;
277
+ }
278
+ a.evm-pin:hover,
279
+ a.evm-pin:focus-visible {
280
+ z-index: 1;
281
+ outline: 3px solid var(--ink);
282
+ outline-offset: 2px;
283
+ }
284
+ .evm-credit {
285
+ margin-top: 0.5rem;
286
+ color: var(--muted);
287
+ font-size: var(--text-xs);
288
+ }
289
+ .evm-credit a {
290
+ color: inherit;
291
+ }
292
+ .evm-list {
293
+ display: grid;
294
+ gap: 0.75rem;
295
+ min-width: 0;
296
+ margin: 0;
297
+ padding: 0;
298
+ list-style: none;
299
+ }
300
+ .evm-row {
301
+ display: grid;
302
+ grid-template-columns: 3.75rem minmax(0, 1fr);
303
+ gap: 1rem;
304
+ align-items: start;
305
+ min-width: 0;
306
+ padding: 1rem;
307
+ border: 1px solid var(--line);
308
+ border-radius: var(--radius-card);
309
+ background: var(--surface);
310
+ }
311
+ .evm-tile {
312
+ display: grid;
313
+ justify-items: center;
314
+ padding: 0.5rem 0 0.5625rem;
315
+ border-radius: var(--radius);
316
+ background: color-mix(in srgb, var(--ink) 5%, transparent);
317
+ line-height: 1;
318
+ text-align: center;
319
+ }
320
+ .evm-tile b {
321
+ font-family: var(--font-display);
322
+ font-size: 1.75rem;
323
+ font-weight: 800;
324
+ letter-spacing: -0.02em;
325
+ }
326
+ .evm-month {
327
+ margin-bottom: 0.3125rem;
328
+ color: var(--accent);
329
+ font-size: var(--text-xs);
330
+ font-weight: 700;
331
+ letter-spacing: 0.14em;
332
+ text-transform: uppercase;
333
+ }
334
+ .evm-weekday {
335
+ margin-top: 0.3125rem;
336
+ color: var(--muted);
337
+ font-size: 0.6875rem;
338
+ font-weight: 700;
339
+ letter-spacing: 0.08em;
340
+ text-transform: uppercase;
341
+ }
342
+ .evm-body {
343
+ display: grid;
344
+ gap: 0.375rem;
345
+ min-width: 0;
346
+ }
347
+ .evm-body > * {
348
+ margin: 0;
349
+ }
350
+ .evm-title {
351
+ font-family: var(--font-display);
352
+ font-size: var(--text-lg);
353
+ font-weight: 700;
354
+ line-height: 1.25;
355
+ letter-spacing: -0.01em;
356
+ }
357
+ .evm-title a {
358
+ color: var(--ink);
359
+ text-decoration: none;
360
+ }
361
+ .evm-title a:hover {
362
+ text-decoration: underline;
363
+ }
364
+ /* The row's number, the pin's twin. */
365
+ .evm-num {
366
+ display: inline-grid;
367
+ place-items: center;
368
+ width: 1.5rem;
369
+ height: 1.5rem;
370
+ margin-right: 0.5rem;
371
+ border-radius: var(--pill);
372
+ background: var(--button);
373
+ color: var(--button-ink);
374
+ font-family: var(--font);
375
+ font-size: var(--text-xs);
376
+ font-weight: 800;
377
+ letter-spacing: 0;
378
+ vertical-align: 0.125em;
379
+ }
380
+ .evm-meta {
381
+ color: var(--muted);
382
+ font-size: var(--text-sm);
383
+ }
384
+ .evm-meta a {
385
+ white-space: nowrap;
386
+ }
387
+ .evm-facts {
388
+ display: flex;
389
+ flex-wrap: wrap;
390
+ align-items: center;
391
+ gap: 0.375rem 0.75rem;
392
+ font-size: var(--text-sm);
393
+ }
394
+ .evm-live {
395
+ color: var(--ink);
396
+ font-weight: 700;
397
+ }
398
+ .evm-live:empty {
399
+ display: none;
400
+ }
401
+ .evm-closed {
402
+ color: var(--muted);
403
+ font-weight: 700;
404
+ }
405
+ .evm-action {
406
+ padding-top: 0.25rem;
407
+ }
408
+ .evm-empty {
409
+ margin: 0;
410
+ padding: 1.125rem 1.25rem;
411
+ border: 2px dashed color-mix(in srgb, var(--ink) 22%, transparent);
412
+ border-radius: var(--radius);
413
+ color: var(--muted);
414
+ }
415
+ /* Wider: the list at the left, the map at the right, held in view while the list scrolls. */
416
+ @media (min-width: 56rem) {
417
+ .evm-with-map {
418
+ grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
419
+ gap: 2rem;
420
+ align-items: start;
421
+ }
422
+ .evm-with-map .evm-map {
423
+ position: sticky;
424
+ top: 1.5rem;
425
+ grid-column: 2;
426
+ grid-row: 1;
427
+ }
428
+ .evm-with-map .evm-credit {
429
+ text-align: right;
430
+ }
431
+ .evm-with-map .evm-list {
432
+ grid-column: 1;
433
+ grid-row: 1;
434
+ }
435
+ }
436
+ </style>