@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,171 @@
1
+ ---
2
+ // Comparison, 'cards' layout (board 08, "Head-to-head cards"): the section
3
+ // head and the body, then two panels side by side (ours over theirs on a
4
+ // phone). Ours, filled in the band's second button colour, is headed with
5
+ // our label and lists each of our positions after a check mark; theirs, on
6
+ // the band's surface, is headed with the first opponent's label and lists
7
+ // their positions after a cross. Each line carries its issue small above it,
8
+ // and on a wide screen the two panels share their rows, so an issue's two
9
+ // lines sit level. Only us and the first opponent are drawn here: the second
10
+ // opponent belongs to the table and the spectrum. An issue neither side
11
+ // fills is not drawn; one only a side fills keeps its line in the other
12
+ // panel, the issue over a dash ("No position listed" to a screen reader),
13
+ // so the lines still pair. A panel with no label or no position is left out
14
+ // and the other spans the row. Nothing is drawn with neither a heading nor
15
+ // an issue.
16
+ import type { ComponentProps } from 'astro/types'
17
+ import type Default from './index.astro'
18
+ import Band from '../Band.astro'
19
+ import SectionHead from '../SectionHead.astro'
20
+ import Prose from '../../Prose.astro'
21
+ import { text } from '../../../lib/format'
22
+ import Unlisted from './Unlisted.astro'
23
+ import { linesOf, sidesOf } from './sides'
24
+
25
+ type Props = ComponentProps<typeof Default>
26
+
27
+ const { section } = Astro.props
28
+ const kicker = text(section.copy.kicker)
29
+ const heading = text(section.copy.heading)
30
+ const all = linesOf(section)
31
+ const panels = sidesOf(section).filter((side) => side.key !== 'them2' && all.some((line) => line.says[side.key]))
32
+ const lines = all.filter((line) => panels.some((side) => line.says[side.key]))
33
+ ---
34
+ {(heading || lines.length > 0) && (
35
+ <Band section={section} class="comparison comparison-cards">
36
+ <SectionHead kicker={kicker} heading={heading} more={[]} />
37
+ <Prose value={section.copy.body} class="lede" />
38
+ {lines.length > 0 && (
39
+ <div class="duel" style={`--duel-rows: ${lines.length}`}>
40
+ {panels.map((side) => (
41
+ <div class:list={['duel-panel', side.key === 'us' ? 'duel-ours' : 'duel-theirs']}>
42
+ <h3 class="duel-label">{side.label}</h3>
43
+ <ul class="duel-lines" role="list">
44
+ {lines.map((line) => {
45
+ const says = line.says[side.key]
46
+ return says ? (
47
+ <li class="duel-line">
48
+ <span class="duel-issue">{line.issue}</span>
49
+ <span class="duel-says">
50
+ {side.key === 'us' ? (
51
+ <svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="M3 8.5l3.2 3.2L13 4.8" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" /></svg>
52
+ ) : (
53
+ <svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="M4.5 4.5l7 7M11.5 4.5l-7 7" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>
54
+ )}
55
+ <span>{says}</span>
56
+ </span>
57
+ </li>
58
+ ) : (
59
+ <li class="duel-line">
60
+ <span class="duel-issue">{line.issue}</span>
61
+ <span class="duel-says duel-none"><Unlisted /></span>
62
+ </li>
63
+ )
64
+ })}
65
+ </ul>
66
+ </div>
67
+ ))}
68
+ </div>
69
+ )}
70
+ </Band>
71
+ )}
72
+
73
+ <style>
74
+ .duel {
75
+ display: grid;
76
+ gap: 1rem;
77
+ }
78
+ .duel-panel {
79
+ min-width: 0;
80
+ padding: clamp(1.375rem, 1rem + 1.5vw, 2.25rem);
81
+ border-radius: var(--radius-card);
82
+ }
83
+ .duel-ours {
84
+ border: 1px solid var(--button-2);
85
+ background: var(--button-2);
86
+ color: var(--button-2-ink);
87
+ }
88
+ .duel-theirs {
89
+ border: 1px solid var(--line);
90
+ background: var(--surface);
91
+ }
92
+ .duel-panel .duel-label {
93
+ margin: 0 0 1rem;
94
+ font-size: var(--h3);
95
+ }
96
+ .duel-lines {
97
+ margin: 0;
98
+ padding: 0;
99
+ list-style: none;
100
+ }
101
+ .duel-line {
102
+ display: grid;
103
+ align-content: start;
104
+ gap: 0.25rem;
105
+ padding: 0.875rem 0;
106
+ border-top: 1px solid var(--line);
107
+ }
108
+ .duel-ours .duel-line {
109
+ border-top-color: color-mix(in srgb, var(--button-2-ink) 22%, transparent);
110
+ }
111
+ .duel-none {
112
+ color: var(--muted);
113
+ }
114
+ .duel-ours .duel-none {
115
+ color: color-mix(in srgb, var(--button-2-ink) 70%, transparent);
116
+ }
117
+ .duel-line:last-child {
118
+ padding-bottom: 0;
119
+ }
120
+ .duel-issue {
121
+ color: var(--muted);
122
+ font-size: var(--text-xs);
123
+ font-weight: 700;
124
+ letter-spacing: 0.12em;
125
+ line-height: 1.4;
126
+ text-transform: uppercase;
127
+ }
128
+ .duel-ours .duel-issue {
129
+ color: color-mix(in srgb, var(--button-2-ink) 78%, transparent);
130
+ }
131
+ .duel-says {
132
+ display: flex;
133
+ align-items: flex-start;
134
+ gap: 0.5rem;
135
+ font-size: var(--text-lg);
136
+ font-weight: 600;
137
+ line-height: 1.35;
138
+ }
139
+ .duel-says svg {
140
+ flex: 0 0 auto;
141
+ width: 1.125rem;
142
+ height: 1.125rem;
143
+ margin-top: 0.125rem;
144
+ }
145
+ .duel-theirs .duel-says {
146
+ font-weight: 500;
147
+ }
148
+ .duel-theirs .duel-says svg {
149
+ color: var(--muted);
150
+ }
151
+ /* A wide screen: the panels side by side, every line on a row both panels share. */
152
+ @media (min-width: 48rem) {
153
+ .duel {
154
+ grid-auto-flow: column;
155
+ grid-auto-columns: minmax(0, 1fr);
156
+ grid-template-rows: auto repeat(var(--duel-rows), auto);
157
+ column-gap: 1.25rem;
158
+ row-gap: 0;
159
+ }
160
+ .duel-panel {
161
+ display: grid;
162
+ grid-row: 1 / -1;
163
+ grid-template-rows: subgrid;
164
+ }
165
+ .duel-lines {
166
+ display: grid;
167
+ grid-row: 2 / -1;
168
+ grid-template-rows: subgrid;
169
+ }
170
+ }
171
+ </style>
@@ -0,0 +1,191 @@
1
+ ---
2
+ // Comparison, 'table' layout, the default (board 08, "Three-way table"): the
3
+ // section head (the kicker and the heading), the body, then the issues as a
4
+ // table on the band's surface: the issue, then a column for each labelled
5
+ // side, ours first. Our column is the one that stands out: its header filled
6
+ // in the band's button colour, its cells on a tint of the surface, each of
7
+ // our positions in bold after a check mark. The others are plain. A side no
8
+ // row fills is left out, a row that names no position is not drawn, and a
9
+ // side with nothing on an issue it shares shows a dash. The heading is the
10
+ // table's caption, for a screen reader.
11
+ //
12
+ // On a phone each issue is a block of its own: the issue as its heading,
13
+ // then each side's label over its position, ours on the tint. Nothing is
14
+ // drawn with neither a heading nor an issue.
15
+ import type { Section } from '@backgold/content'
16
+ import Band from '../Band.astro'
17
+ import SectionHead from '../SectionHead.astro'
18
+ import Prose from '../../Prose.astro'
19
+ import { text } from '../../../lib/format'
20
+ import Unlisted from './Unlisted.astro'
21
+ import { linesOf, sidesOf } from './sides'
22
+
23
+ interface Props {
24
+ section: Section
25
+ variant?: string
26
+ }
27
+
28
+ const { section } = Astro.props
29
+ const kicker = text(section.copy.kicker)
30
+ const heading = text(section.copy.heading)
31
+ const all = linesOf(section)
32
+ const sides = sidesOf(section).filter((side) => all.some((line) => line.says[side.key]))
33
+ const lines = all.filter((line) => sides.some((side) => line.says[side.key]))
34
+ ---
35
+ {(heading || lines.length > 0) && (
36
+ <Band section={section} class="comparison comparison-table">
37
+ <SectionHead kicker={kicker} heading={heading} more={[]} />
38
+ <Prose value={section.copy.body} class="lede" />
39
+ {lines.length > 0 && (
40
+ <div class="versus-frame">
41
+ <table class="versus">
42
+ {heading && <caption class="visually-hidden">{heading}</caption>}
43
+ <thead>
44
+ <tr>
45
+ <th scope="col">Issue</th>
46
+ {sides.map((side) => (
47
+ <th scope="col" class:list={[side.key === 'us' && 'versus-us']}>{side.label}</th>
48
+ ))}
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ {lines.map((line) => (
53
+ <tr class="versus-row">
54
+ <th scope="row" class="versus-issue">{line.issue}</th>
55
+ {sides.map((side) =>
56
+ side.key === 'us' ? (
57
+ <td class="versus-us" data-label={side.label}>
58
+ {line.says.us ? (
59
+ <span class="versus-ours">
60
+ <svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="M3 8.5l3.2 3.2L13 4.8" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" /></svg>
61
+ <span>{line.says.us}</span>
62
+ </span>
63
+ ) : (
64
+ <span class="versus-none"><Unlisted /></span>
65
+ )}
66
+ </td>
67
+ ) : (
68
+ <td data-label={side.label}>{line.says[side.key] ?? <span class="versus-none"><Unlisted /></span>}</td>
69
+ ),
70
+ )}
71
+ </tr>
72
+ ))}
73
+ </tbody>
74
+ </table>
75
+ </div>
76
+ )}
77
+ </Band>
78
+ )}
79
+
80
+ <style>
81
+ .versus-frame {
82
+ border: 1px solid var(--line);
83
+ border-radius: var(--radius-card);
84
+ background: var(--surface);
85
+ overflow: hidden;
86
+ }
87
+ .versus {
88
+ width: 100%;
89
+ border-collapse: collapse;
90
+ font-size: 0.9375rem;
91
+ }
92
+ .versus thead th {
93
+ padding: 0.875rem 1.125rem;
94
+ border-bottom: 1px solid var(--line-strong);
95
+ background: color-mix(in srgb, var(--ink) 5%, transparent);
96
+ color: var(--muted);
97
+ font-size: var(--text-xs);
98
+ font-weight: 700;
99
+ letter-spacing: 0.12em;
100
+ line-height: 1.35;
101
+ text-align: left;
102
+ text-transform: uppercase;
103
+ vertical-align: bottom;
104
+ }
105
+ .versus thead th:first-child {
106
+ width: 28%;
107
+ }
108
+ .versus thead th.versus-us {
109
+ border-bottom-color: var(--button);
110
+ background: var(--button);
111
+ color: var(--button-ink);
112
+ }
113
+ .versus td,
114
+ .versus .versus-issue {
115
+ padding: 0.9375rem 1.125rem;
116
+ border-bottom: 1px solid var(--line);
117
+ text-align: left;
118
+ vertical-align: top;
119
+ }
120
+ .versus-row:last-child > * {
121
+ border-bottom: 0;
122
+ }
123
+ .versus .versus-issue {
124
+ font-weight: 700;
125
+ }
126
+ .versus td.versus-us {
127
+ background: color-mix(in srgb, var(--button) 9%, var(--surface));
128
+ }
129
+ .versus-ours {
130
+ display: inline-flex;
131
+ align-items: flex-start;
132
+ gap: 0.4375rem;
133
+ font-weight: 700;
134
+ }
135
+ .versus-none {
136
+ color: var(--muted);
137
+ }
138
+ .versus-ours svg {
139
+ flex: 0 0 auto;
140
+ margin-top: 0.1875rem;
141
+ color: var(--accent);
142
+ }
143
+ /* A phone: each issue a block, the issue over its sides, each side's label over its position. */
144
+ @media (max-width: 39.99rem) {
145
+ .versus thead {
146
+ position: absolute;
147
+ width: 1px;
148
+ height: 1px;
149
+ overflow: hidden;
150
+ clip: rect(0 0 0 0);
151
+ white-space: nowrap;
152
+ }
153
+ .versus,
154
+ .versus tbody {
155
+ display: block;
156
+ }
157
+ .versus-row {
158
+ display: grid;
159
+ gap: 0.625rem;
160
+ padding: 1.125rem;
161
+ border-bottom: 1px solid var(--line);
162
+ }
163
+ .versus-row:last-child {
164
+ border-bottom: 0;
165
+ }
166
+ .versus td,
167
+ .versus .versus-issue {
168
+ display: grid;
169
+ gap: 0.25rem;
170
+ padding: 0;
171
+ border: 0;
172
+ }
173
+ .versus .versus-issue {
174
+ font-family: var(--font-display);
175
+ font-size: var(--text-lg);
176
+ line-height: 1.25;
177
+ }
178
+ .versus td::before {
179
+ content: attr(data-label);
180
+ color: var(--muted);
181
+ font-size: var(--text-xs);
182
+ font-weight: 700;
183
+ letter-spacing: 0.12em;
184
+ text-transform: uppercase;
185
+ }
186
+ .versus td.versus-us {
187
+ padding: 0.625rem 0.75rem;
188
+ border-radius: var(--radius);
189
+ }
190
+ }
191
+ </style>
@@ -0,0 +1,98 @@
1
+ // A Comparison's sides and rows as its layouts draw them.
2
+ //
3
+ // - A side is one of three, always in this order: `us` (labelled `usLabel`),
4
+ // `them` (`themLabel`) and `them2` (`them2Label`). Only a side with a label
5
+ // is drawn anywhere; each layout then leaves out a side no row fills.
6
+ // - A row is an issue: `issue`, each side's position in words (`us`, `them`,
7
+ // `them2`) and its place on the spectrum (`usAt`, `themAt`, `them2At`, from
8
+ // 0 at `leftLabel` to 100 at `rightLabel`). A row without an issue is not
9
+ // drawn; a place that is not a number from 0 to 100 is left out.
10
+ //
11
+ // Each side carries the short forms the Spectrum layout marks its rail with:
12
+ // ours a pill with `short` (the label when it is 14 characters or fewer, else
13
+ // its leading capitalised words, at most two: "Pine Valley" for "Pine Valley
14
+ // for Liberty"), the others a circle with `initial` (the first letter of the
15
+ // label's first word after a leading "The", "A" or "An"; two letters for
16
+ // both when the two others would share one).
17
+
18
+ import type { Section } from '@backgold/content'
19
+ import { rows } from '../../../lib/section'
20
+ import { text } from '../../../lib/format'
21
+
22
+ export const SIDES = ['us', 'them', 'them2'] as const
23
+ export type SideKey = (typeof SIDES)[number]
24
+
25
+ export interface Side {
26
+ key: SideKey
27
+ label: string
28
+ /** Ours: the label, or its leading words when it is long. */
29
+ short: string
30
+ /** The others: one or two letters for the label. */
31
+ initial: string
32
+ }
33
+
34
+ export interface Line {
35
+ issue: string
36
+ /** Each side's position, in words. */
37
+ says: Record<SideKey, string | null>
38
+ /** Each side's place from 0 (left) to 100 (right). */
39
+ at: Record<SideKey, number | null>
40
+ }
41
+
42
+ const SHORT = 14
43
+ const ARTICLE = /^(the|a|an)$/i
44
+
45
+ function words(label: string): string[] {
46
+ const all = label.trim().split(/\s+/)
47
+ return all.length > 1 && ARTICLE.test(all[0]!) ? all.slice(1) : all
48
+ }
49
+
50
+ function shortOf(label: string): string {
51
+ const trimmed = label.trim()
52
+ if (trimmed.length <= SHORT) return trimmed
53
+ const all = trimmed.split(/\s+/)
54
+ const lead: string[] = []
55
+ for (const word of all) {
56
+ if (lead.length === 2 || !/^\p{Lu}/u.test(word)) break
57
+ lead.push(word)
58
+ }
59
+ return lead.length > 0 ? lead.join(' ') : all[0]!
60
+ }
61
+
62
+ function letters(label: string, count: 1 | 2): string {
63
+ const [first = '', second] = words(label)
64
+ const picked = count === 1 ? first.slice(0, 1) : second ? first.slice(0, 1) + second.slice(0, 1) : first.slice(0, 2)
65
+ return picked.toUpperCase()
66
+ }
67
+
68
+ /** The sides with a label, ours first. */
69
+ export function sidesOf(section: Section): Side[] {
70
+ const labelled = SIDES.flatMap((key) => {
71
+ const label = text(section.copy[`${key}Label`])?.trim()
72
+ return label ? [{ key, label, short: shortOf(label), initial: letters(label, 1) }] : []
73
+ })
74
+ const others = labelled.filter((s) => s.key !== 'us')
75
+ if (others.length === 2 && others[0]!.initial === others[1]!.initial) {
76
+ for (const side of others) side.initial = letters(side.label, 2)
77
+ }
78
+ return labelled
79
+ }
80
+
81
+ function place(value: unknown): number | null {
82
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 100 ? value : null
83
+ }
84
+
85
+ /** The section's issues in row order: the rows that name one. */
86
+ export function linesOf(section: Section): Line[] {
87
+ return rows(section).flatMap((row) => {
88
+ const issue = text(row.issue)
89
+ if (!issue) return []
90
+ return [
91
+ {
92
+ issue,
93
+ says: { us: text(row.us), them: text(row.them), them2: text(row.them2) },
94
+ at: { us: place(row.usAt), them: place(row.themAt), them2: place(row.them2At) },
95
+ },
96
+ ]
97
+ })
98
+ }