@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,299 @@
1
+ ---
2
+ // SampleBallot · Cards (mock 03, "Address-filtered cards"): the kicker over
3
+ // the heading, the body, then a card per race, three across on a wide
4
+ // screen and one on a phone. Each card has the candidate's headshot (their
5
+ // initials where there is none, as the candidate roster draws them), the
6
+ // office in small capitals, the name, which links to their page when the
7
+ // row has one, the place and the party, the line about them, and the
8
+ // endorsed chip on an endorsed race. The ballot measures come after under
9
+ // `measuresHeading`, one compact row each: the title (linked to its
10
+ // analysis when there is one), the position at the right, the line on it.
11
+ //
12
+ // No address is looked up here. When the races name more than one place,
13
+ // a chip per place ("All" first, then each place in the order the races
14
+ // name it) narrows the cards to that place's races, with "Showing N of M."
15
+ // for a screen reader. The chips are drawn hidden and shown by the
16
+ // section's script, so with scripts off every card shows and nothing is
17
+ // offered that cannot work. The measures always show. With no races, no
18
+ // measures and no heading it draws nothing.
19
+ import type { ComponentProps } from 'astro/types'
20
+ import type Default from './index.astro'
21
+ import Band from '../Band.astro'
22
+ import SectionHead from '../SectionHead.astro'
23
+ import Prose from '../../Prose.astro'
24
+ import Position from './Position.astro'
25
+ import { text } from '../../../lib/format'
26
+ import { initials } from '../CandidateRoster/candidates'
27
+ import { ballotOf, idFor } from './ballot'
28
+
29
+ type Props = ComponentProps<typeof Default>
30
+
31
+ const { section } = Astro.props
32
+ const kicker = text(section.copy.kicker)
33
+ const heading = text(section.copy.heading)
34
+ const endorsedLabel = text(section.copy.endorsedLabel) ?? 'Endorsed'
35
+ const measuresHeading = text(section.copy.measuresHeading) ?? 'Ballot measures'
36
+ const { races, measures } = ballotOf(section)
37
+ const regions = [...new Set(races.map((race) => race.region).filter((region): region is string => region !== null))]
38
+ const filter = regions.length > 1
39
+ const cardsId = idFor(section, 'races')
40
+ ---
41
+ {(races.length > 0 || measures.length > 0 || heading) && (
42
+ <Band section={section} class="sample-ballot sample-ballot-cards">
43
+ <SectionHead kicker={kicker} heading={heading} more={[]} />
44
+ <Prose value={section.copy.body} class="lede" />
45
+ {races.length > 0 && (
46
+ <div class="ballot-races" data-ballot-races>
47
+ {filter && (
48
+ <div class="ballot-regions" role="group" aria-label="Places" data-ballot-regions hidden>
49
+ <button type="button" aria-pressed="true" aria-controls={cardsId} data-region="">All</button>
50
+ {regions.map((region) => (
51
+ <button type="button" aria-pressed="false" aria-controls={cardsId} data-region={region}>{region}</button>
52
+ ))}
53
+ </div>
54
+ )}
55
+ <ul class="ballot-cards" id={cardsId} role="list">
56
+ {races.map((race) => (
57
+ <li class="ballot-card" data-region={race.region ?? ''}>
58
+ <div class="ballot-card-top">
59
+ {race.photo ? (
60
+ <img class="ballot-card-photo" src={race.photo} alt="" loading="lazy" decoding="async" />
61
+ ) : (
62
+ <span class="ballot-card-photo ballot-card-initials" aria-hidden="true">{initials(race.name)}</span>
63
+ )}
64
+ <div class="ballot-card-who">
65
+ {race.office && <p class="ballot-card-office">{race.office}</p>}
66
+ <h3 class="ballot-card-name">
67
+ {race.link ? <a href={race.link.href} rel={race.link.rel}>{race.name}</a> : race.name}
68
+ </h3>
69
+ {(race.region || race.party) && <p class="ballot-card-meta">{[race.region, race.party].filter(Boolean).join(' · ')}</p>}
70
+ </div>
71
+ </div>
72
+ {race.summary && <p class="ballot-card-summary">{race.summary}</p>}
73
+ {race.endorsed && <p class="ballot-card-chip"><span class="chip chip-accent">{endorsedLabel}</span></p>}
74
+ </li>
75
+ ))}
76
+ </ul>
77
+ {filter && <p class="ballot-showing" role="status" data-ballot-showing></p>}
78
+ {filter && (
79
+ <script is:inline>
80
+ ;(function (root) {
81
+ if (!root) return
82
+ var chips = root.querySelectorAll('[data-ballot-regions] [data-region]')
83
+ var cards = root.querySelectorAll('.ballot-cards > [data-region]')
84
+ var showing = root.querySelector('[data-ballot-showing]')
85
+ var choose = function (region) {
86
+ var shown = 0
87
+ for (var c = 0; c < chips.length; c++) chips[c].setAttribute('aria-pressed', chips[c].getAttribute('data-region') === region ? 'true' : 'false')
88
+ for (var i = 0; i < cards.length; i++) {
89
+ var match = !region || cards[i].getAttribute('data-region') === region
90
+ cards[i].hidden = !match
91
+ if (match) shown++
92
+ }
93
+ showing.textContent = shown === cards.length ? '' : 'Showing ' + shown + ' of ' + cards.length + '.'
94
+ }
95
+ for (var c = 0; c < chips.length; c++) {
96
+ chips[c].addEventListener('click', function (event) {
97
+ choose(event.currentTarget.getAttribute('data-region'))
98
+ })
99
+ }
100
+ root.querySelector('[data-ballot-regions]').hidden = false
101
+ })(document.currentScript.closest('[data-ballot-races]'))
102
+ </script>
103
+ )}
104
+ </div>
105
+ )}
106
+ {measures.length > 0 && (
107
+ <div class="ballot-measures">
108
+ <h3 class="ballot-measures-heading">{measuresHeading}</h3>
109
+ <ul class="ballot-measure-list" role="list">
110
+ {measures.map((measure) => (
111
+ <li class="ballot-measure">
112
+ <p class="ballot-measure-title">
113
+ {measure.link ? <a href={measure.link.href} rel={measure.link.rel}>{measure.title}</a> : measure.title}
114
+ </p>
115
+ {measure.position && <Position position={measure.position} />}
116
+ {measure.summary && <p class="ballot-measure-summary">{measure.summary}</p>}
117
+ </li>
118
+ ))}
119
+ </ul>
120
+ </div>
121
+ )}
122
+ </Band>
123
+ )}
124
+
125
+ <style>
126
+ .ballot-regions {
127
+ display: flex;
128
+ flex-wrap: wrap;
129
+ gap: 0.5rem;
130
+ margin-bottom: 1.25rem;
131
+ }
132
+ .ballot-regions[hidden],
133
+ .ballot-card[hidden] {
134
+ display: none;
135
+ }
136
+ .ballot-regions button {
137
+ min-height: 2.75rem;
138
+ padding: 0.375rem 0.875rem;
139
+ border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent);
140
+ border-radius: var(--pill);
141
+ background: transparent;
142
+ color: var(--ink);
143
+ font: inherit;
144
+ font-size: var(--text-sm);
145
+ font-weight: 600;
146
+ cursor: pointer;
147
+ }
148
+ .ballot-regions button:hover {
149
+ border-color: var(--ink);
150
+ }
151
+ .ballot-regions button[aria-pressed='true'] {
152
+ border-color: var(--button);
153
+ background: var(--button);
154
+ color: var(--button-ink);
155
+ }
156
+ .ballot-cards {
157
+ display: grid;
158
+ grid-template-columns: minmax(0, 1fr);
159
+ gap: clamp(1rem, 2vw, 1.5rem);
160
+ margin: 0;
161
+ padding: 0;
162
+ list-style: none;
163
+ }
164
+ .ballot-card {
165
+ position: relative;
166
+ display: flex;
167
+ flex-direction: column;
168
+ gap: 0.75rem;
169
+ padding: 1.25rem;
170
+ border: 1px solid var(--line);
171
+ border-radius: var(--radius);
172
+ background: var(--surface);
173
+ }
174
+ .ballot-card > * {
175
+ margin: 0;
176
+ }
177
+ .ballot-card:focus-within {
178
+ outline: 3px solid var(--ink);
179
+ outline-offset: 3px;
180
+ }
181
+ .ballot-card-top {
182
+ display: grid;
183
+ grid-template-columns: 4.5rem minmax(0, 1fr);
184
+ gap: 1rem;
185
+ align-items: center;
186
+ }
187
+ .ballot-card-photo {
188
+ display: block;
189
+ width: 100%;
190
+ aspect-ratio: 1;
191
+ object-fit: cover;
192
+ border-radius: calc(var(--radius) * 0.8);
193
+ }
194
+ .ballot-card-initials {
195
+ display: grid;
196
+ place-items: center;
197
+ background: color-mix(in srgb, var(--ink) 8%, transparent);
198
+ color: var(--muted);
199
+ font-family: var(--font-display);
200
+ font-size: var(--h3);
201
+ font-weight: 700;
202
+ }
203
+ .ballot-card-who > * {
204
+ margin: 0;
205
+ }
206
+ .ballot-card-office {
207
+ color: var(--muted);
208
+ font-size: var(--text-xs);
209
+ font-weight: 700;
210
+ letter-spacing: 0.12em;
211
+ line-height: 1.4;
212
+ text-transform: uppercase;
213
+ }
214
+ .ballot-card-name {
215
+ margin-top: 0.25rem;
216
+ font-size: var(--h3);
217
+ }
218
+ .ballot-card-name a {
219
+ color: var(--ink);
220
+ text-decoration: none;
221
+ }
222
+ /* The name's link covers the card. */
223
+ .ballot-card-name a::after {
224
+ content: '';
225
+ position: absolute;
226
+ inset: 0;
227
+ border-radius: var(--radius);
228
+ }
229
+ .ballot-card-name a:focus-visible {
230
+ outline: none;
231
+ }
232
+ .ballot-card:hover .ballot-card-name a {
233
+ text-decoration: underline;
234
+ }
235
+ .ballot-card-meta {
236
+ margin-top: 0.25rem;
237
+ color: var(--muted);
238
+ font-size: var(--text-sm);
239
+ }
240
+ .ballot-card-summary {
241
+ color: var(--muted);
242
+ }
243
+ .ballot-card > .ballot-card-chip {
244
+ margin-top: auto;
245
+ }
246
+ .ballot-showing {
247
+ margin: 1rem 0 0;
248
+ color: var(--muted);
249
+ font-size: var(--text-sm);
250
+ }
251
+ .ballot-showing:empty {
252
+ display: none;
253
+ }
254
+ .ballot-measures {
255
+ margin-top: clamp(2rem, 1.5rem + 1.5vw, 2.75rem);
256
+ }
257
+ .ballot-measures-heading {
258
+ margin: 0 0 0.75rem;
259
+ font-size: var(--h3);
260
+ }
261
+ .ballot-measure-list {
262
+ margin: 0;
263
+ padding: 0;
264
+ list-style: none;
265
+ border-top: 2px solid var(--ink);
266
+ }
267
+ .ballot-measure {
268
+ display: grid;
269
+ grid-template-columns: minmax(0, 1fr) auto;
270
+ gap: 0.25rem 1rem;
271
+ align-items: center;
272
+ padding: 0.875rem 0;
273
+ border-bottom: 1px solid var(--line);
274
+ }
275
+ .ballot-measure-title {
276
+ margin: 0;
277
+ font-weight: 700;
278
+ line-height: 1.35;
279
+ }
280
+ .ballot-measure-title a {
281
+ color: var(--ink);
282
+ }
283
+ .ballot-measure-summary {
284
+ grid-column: 1 / -1;
285
+ margin: 0;
286
+ color: var(--muted);
287
+ font-size: var(--text-sm);
288
+ }
289
+ @media (min-width: 40rem) {
290
+ .ballot-cards {
291
+ grid-template-columns: repeat(2, minmax(0, 1fr));
292
+ }
293
+ }
294
+ @media (min-width: 56rem) {
295
+ .ballot-cards {
296
+ grid-template-columns: repeat(3, minmax(0, 1fr));
297
+ }
298
+ }
299
+ </style>
@@ -0,0 +1,326 @@
1
+ ---
2
+ // SampleBallot · Slate (mock 03, "Printable slate"; the default): the slate
3
+ // as one card to take to the polls. The kicker over the heading is the
4
+ // slate's title, the body under it, and a key to the mark ("● Endorsed")
5
+ // when a race carries one. The races follow in the organization's order,
6
+ // grouped by office as the candidate roster's Ballot groups them: the office
7
+ // in small capitals, each name with the party in parentheses, and at the
8
+ // right a filled circle for an endorsed race (the endorsed label is its
9
+ // text for a screen reader) or an empty ring. Under a rule the ballot
10
+ // measures (`measuresHeading`), each its title over "Vote YES" or "Vote NO"
11
+ // (or "No position"), then the closing note, small.
12
+ //
13
+ // "Print this slate", at the title's right (under the body on a phone),
14
+ // prints the card through the browser. It is drawn
15
+ // hidden and shown by the section's script, so with scripts off nothing is
16
+ // offered that cannot work. The page's print style holds whenever a slate
17
+ // is on the page, however printing starts: `body:has(.slate-sheet)` hides
18
+ // every element that neither holds a slate nor sits inside one, keeping the
19
+ // footer's legal line ("Paid for by …") under the card, and the card prints
20
+ // in black ink on white. With no races, no measures and no heading it draws
21
+ // nothing.
22
+ import type { Section } from '@backgold/content'
23
+ import Band from '../Band.astro'
24
+ import Prose from '../../Prose.astro'
25
+ import Position from './Position.astro'
26
+ import { text } from '../../../lib/format'
27
+ import { ballotOf, idFor, nameWithParty, officesOf } from './ballot'
28
+
29
+ interface Props {
30
+ section: Section
31
+ variant?: string
32
+ }
33
+
34
+ const { section } = Astro.props
35
+ const kicker = text(section.copy.kicker)
36
+ const heading = text(section.copy.heading)
37
+ const note = text(section.copy.note)
38
+ const printLabel = text(section.copy.printLabel) ?? 'Print this slate'
39
+ const endorsedLabel = text(section.copy.endorsedLabel) ?? 'Endorsed'
40
+ const measuresHeading = text(section.copy.measuresHeading) ?? 'Ballot measures'
41
+ const { races, measures } = ballotOf(section)
42
+ const offices = officesOf(races)
43
+ const titleId = idFor(section, 'slate-title')
44
+ const hasRows = races.length > 0 || measures.length > 0
45
+ ---
46
+ {(hasRows || heading) && (
47
+ <Band section={section} class="sample-ballot sample-ballot-slate">
48
+ <article class="slate-sheet" aria-labelledby={heading ? titleId : undefined} data-slate>
49
+ <header class="slate-head">
50
+ <div class="slate-title">
51
+ {kicker && <p class="kicker">{kicker}</p>}
52
+ {heading && <h2 id={titleId}>{heading}</h2>}
53
+ </div>
54
+ {hasRows && (
55
+ <button type="button" class="button button-quiet button-small slate-print" data-slate-print hidden>
56
+ <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true" focusable="false">
57
+ <path d="M7 9V3h10v6M7 17H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2M7 14h10v7H7z" fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" />
58
+ </svg>
59
+ {printLabel}
60
+ </button>
61
+ )}
62
+ <Prose value={section.copy.body} class="slate-body" />
63
+ </header>
64
+ {races.some((race) => race.endorsed) && (
65
+ <p class="slate-key" aria-hidden="true"><span class="slate-mark slate-mark-on"></span>{endorsedLabel}</p>
66
+ )}
67
+ {races.length > 0 && (
68
+ <ol class="slate-races" role="list">
69
+ {offices.map((group) => (
70
+ <li class="slate-office">
71
+ {group.office && <h3 class="slate-label">{group.office}</h3>}
72
+ <ul class="slate-names" role="list">
73
+ {group.races.map((race) => (
74
+ <li class="slate-race">
75
+ <span class="slate-name">{nameWithParty(race)}</span>
76
+ <span class:list={['slate-mark', race.endorsed && 'slate-mark-on']}>
77
+ {race.endorsed && <span class="visually-hidden">{endorsedLabel}</span>}
78
+ </span>
79
+ </li>
80
+ ))}
81
+ </ul>
82
+ </li>
83
+ ))}
84
+ </ol>
85
+ )}
86
+ {measures.length > 0 && (
87
+ <div class="slate-measures">
88
+ <h3 class="slate-measures-heading">{measuresHeading}</h3>
89
+ <ul class="slate-measure-list" role="list">
90
+ {measures.map((measure) => (
91
+ <li class="slate-measure">
92
+ <h4 class="slate-label">{measure.title}</h4>
93
+ {measure.position && (
94
+ <p class="slate-vote">
95
+ {measure.position !== 'neutral' && <span>Vote</span>}
96
+ <Position position={measure.position} />
97
+ </p>
98
+ )}
99
+ </li>
100
+ ))}
101
+ </ul>
102
+ </div>
103
+ )}
104
+ {note && <p class="slate-note">{note}</p>}
105
+ {hasRows && (
106
+ <script is:inline>
107
+ ;(function (sheet) {
108
+ var button = sheet && sheet.querySelector('[data-slate-print]')
109
+ if (!button || typeof window.print !== 'function') return
110
+ button.addEventListener('click', function () {
111
+ window.print()
112
+ })
113
+ button.hidden = false
114
+ })(document.currentScript.closest('[data-slate]'))
115
+ </script>
116
+ )}
117
+ </article>
118
+ </Band>
119
+ )}
120
+
121
+ <style>
122
+ .slate-sheet {
123
+ max-width: 46rem;
124
+ margin-inline: auto;
125
+ padding: clamp(1.25rem, 0.75rem + 2vw, 2.25rem);
126
+ border: 2px solid var(--line-strong);
127
+ border-radius: var(--radius-card);
128
+ background: var(--surface);
129
+ color: var(--ink);
130
+ }
131
+ /* The title, the print button at its right (under the body on a phone), the body. */
132
+ .slate-head {
133
+ display: grid;
134
+ grid-template-columns: minmax(0, 1fr);
135
+ grid-template-areas: 'title' 'body' 'print';
136
+ column-gap: 1.5rem;
137
+ }
138
+ .slate-title {
139
+ grid-area: title;
140
+ }
141
+ .slate-title h2 {
142
+ margin: 0;
143
+ font-size: clamp(1.625rem, 1.25rem + 1.2vw, 2.125rem);
144
+ }
145
+ .slate-print {
146
+ grid-area: print;
147
+ justify-self: start;
148
+ margin-top: 1rem;
149
+ }
150
+ .slate-print[hidden] {
151
+ display: none;
152
+ }
153
+ .slate-head :global(.slate-body) {
154
+ grid-area: body;
155
+ margin-top: 0.75rem;
156
+ color: var(--muted);
157
+ }
158
+ .slate-head :global(.slate-body p) {
159
+ margin: 0 0 0.5rem;
160
+ }
161
+ .slate-head :global(.slate-body p:last-child) {
162
+ margin-bottom: 0;
163
+ }
164
+ @media (min-width: 40rem) {
165
+ .slate-head {
166
+ grid-template-columns: minmax(0, 1fr) auto;
167
+ grid-template-areas: 'title print' 'body body';
168
+ }
169
+ .slate-print {
170
+ align-self: start;
171
+ margin-top: 0;
172
+ }
173
+ }
174
+ .slate-key {
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: flex-end;
178
+ gap: 0.5rem;
179
+ margin: 1rem 0 0.5rem;
180
+ color: var(--muted);
181
+ font-size: var(--text-xs);
182
+ font-weight: 700;
183
+ letter-spacing: 0.08em;
184
+ text-transform: uppercase;
185
+ }
186
+ .slate-key .slate-mark {
187
+ width: 0.875rem;
188
+ height: 0.875rem;
189
+ border-width: 0.4375rem;
190
+ }
191
+ .slate-races,
192
+ .slate-names,
193
+ .slate-measure-list {
194
+ margin: 0;
195
+ padding: 0;
196
+ list-style: none;
197
+ }
198
+ .slate-races {
199
+ margin-top: 1rem;
200
+ }
201
+ .slate-key + .slate-races {
202
+ margin-top: 0;
203
+ }
204
+ .slate-office,
205
+ .slate-measure {
206
+ padding: 0.875rem 0;
207
+ border-top: 1px solid var(--line);
208
+ }
209
+ .slate-label {
210
+ margin: 0 0 0.25rem;
211
+ color: var(--muted);
212
+ font-family: var(--font);
213
+ font-size: var(--text-xs);
214
+ font-weight: 700;
215
+ letter-spacing: 0.12em;
216
+ line-height: 1.4;
217
+ text-transform: uppercase;
218
+ }
219
+ .slate-names {
220
+ display: grid;
221
+ gap: 0.5rem;
222
+ }
223
+ .slate-race {
224
+ display: flex;
225
+ align-items: center;
226
+ justify-content: space-between;
227
+ gap: 1rem;
228
+ }
229
+ .slate-name {
230
+ min-width: 0;
231
+ font-size: var(--text-lg);
232
+ font-weight: 700;
233
+ line-height: 1.3;
234
+ }
235
+ /* The mark is drawn with its border, so it prints without the browser's background graphics. */
236
+ .slate-mark {
237
+ flex: none;
238
+ width: 1.5rem;
239
+ height: 1.5rem;
240
+ border: 2px solid var(--line-strong);
241
+ border-radius: 50%;
242
+ }
243
+ .slate-mark-on {
244
+ border-width: 0.75rem;
245
+ border-color: var(--ink);
246
+ }
247
+ .slate-measures {
248
+ margin-top: 1.25rem;
249
+ padding-top: 1rem;
250
+ border-top: 2px solid var(--ink);
251
+ }
252
+ .slate-races + .slate-measures {
253
+ margin-top: 0.25rem;
254
+ }
255
+ .slate-measures-heading {
256
+ margin: 0 0 0.25rem;
257
+ font-size: var(--text-lg);
258
+ font-weight: 700;
259
+ }
260
+ .slate-measure:first-child {
261
+ border-top: 0;
262
+ }
263
+ .slate-vote {
264
+ display: flex;
265
+ align-items: center;
266
+ gap: 0.5rem;
267
+ margin: 0;
268
+ font-size: var(--text-lg);
269
+ font-weight: 700;
270
+ }
271
+ .slate-note {
272
+ margin: 0.25rem 0 0;
273
+ padding-top: 0.875rem;
274
+ border-top: 1px solid var(--line);
275
+ color: var(--muted);
276
+ font-size: var(--text-sm);
277
+ }
278
+ .slate-races + .slate-note {
279
+ margin-top: 0;
280
+ }
281
+
282
+ @media print {
283
+ /* Only the slate and the legal line: every element that holds neither, and is in neither, is left off the page. */
284
+ :global(body:has(.slate-sheet) :not(:has(.slate-sheet, .disclaimer)):not(.slate-sheet, .slate-sheet *, .disclaimer, .disclaimer *)) {
285
+ display: none !important;
286
+ }
287
+ :global(html:has(.slate-sheet)) {
288
+ background: white;
289
+ }
290
+ :global(body:has(.slate-sheet)) {
291
+ display: block;
292
+ min-height: 0;
293
+ padding: 0;
294
+ background: none;
295
+ }
296
+ :global(body:has(.slate-sheet) .bg-section:has(.slate-sheet)),
297
+ :global(body:has(.slate-sheet) .site-footer),
298
+ :global(body:has(.slate-sheet) .site-footer-inner) {
299
+ margin: 0;
300
+ padding: 0;
301
+ background: none;
302
+ }
303
+ :global(body:has(.slate-sheet) .disclaimer) {
304
+ margin: 1rem 0 0;
305
+ }
306
+ :global(body:has(.slate-sheet) .disclaimer p) {
307
+ border-color: black;
308
+ color: black;
309
+ }
310
+ .slate-sheet {
311
+ --ink: black;
312
+ --muted: black;
313
+ --accent: black;
314
+ --line: black;
315
+ --line-strong: black;
316
+ max-width: none;
317
+ border-color: black;
318
+ background: white;
319
+ color: black;
320
+ break-inside: avoid;
321
+ }
322
+ .slate-print {
323
+ display: none;
324
+ }
325
+ }
326
+ </style>