@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.
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/chunk-KOB36GSF.js +62 -0
- package/dist/constants-DvTNj4JI.d-Batjcj3Z.d.ts +38 -0
- package/dist/content-api-CYeY0vU8.d.ts +849 -0
- package/dist/contract/content-api-examples.d.ts +58 -0
- package/dist/contract/content-api-examples.js +783 -0
- package/dist/contract/content-api.d.ts +2 -0
- package/dist/contract/content-api.js +1 -0
- package/dist/contract/site-templates.d.ts +252 -0
- package/dist/contract/site-templates.js +185 -0
- package/package.json +70 -3
- package/src/components/EntryCard.astro +35 -0
- package/src/components/EventMap.astro +118 -0
- package/src/components/EventPage.astro +194 -0
- package/src/components/FieldValue.astro +41 -0
- package/src/components/LeadingHero.astro +21 -0
- package/src/components/NotFound.astro +20 -0
- package/src/components/PageSections.astro +47 -0
- package/src/components/Prose.astro +18 -0
- package/src/components/chrome/Brand.astro +54 -0
- package/src/components/chrome/ClosingCall.astro +94 -0
- package/src/components/chrome/DonateStrip.astro +61 -0
- package/src/components/chrome/FooterColumns.astro +32 -0
- package/src/components/chrome/FooterContact.astro +28 -0
- package/src/components/chrome/MenuList.astro +45 -0
- package/src/components/chrome/ModeToggle.astro +125 -0
- package/src/components/chrome/SignedInNotice.astro +53 -0
- package/src/components/chrome/SignupBand.astro +12 -0
- package/src/components/chrome/TakeoverBanner.astro +56 -0
- package/src/components/chrome/VisitorAccount.astro +82 -0
- package/src/components/entries/AuthorBox.astro +47 -0
- package/src/components/entries/EntryFields.astro +29 -0
- package/src/components/entries/EntryHeader.astro +77 -0
- package/src/components/entries/ListFrame.astro +126 -0
- package/src/components/entries/ListSearch.astro +24 -0
- package/src/components/entries/Share.astro +24 -0
- package/src/components/entries/course/classroom.astro +26 -0
- package/src/components/entries/course/lesson.astro +18 -0
- package/src/components/entries/course/section.ts +20 -0
- package/src/components/entries/course/syllabus.astro +15 -0
- package/src/components/entries/index.ts +77 -0
- package/src/components/entries/newsletter/issue.astro +41 -0
- package/src/components/entries/newsletter/list.astro +26 -0
- package/src/components/entries/podcast/episode.astro +42 -0
- package/src/components/entries/podcast/list.astro +36 -0
- package/src/components/entries/post/article.astro +31 -0
- package/src/components/entries/post/list.astro +85 -0
- package/src/components/entries/props.ts +61 -0
- package/src/components/entries/video/cards.astro +39 -0
- package/src/components/entries/video/grid.astro +15 -0
- package/src/components/entries/video/watch.astro +41 -0
- package/src/components/live/LivePage.astro +215 -0
- package/src/components/live/LocalTime.astro +29 -0
- package/src/components/sections/About/books.astro +188 -0
- package/src/components/sections/About/credentials.ts +90 -0
- package/src/components/sections/About/index.astro +57 -0
- package/src/components/sections/About/left.astro +54 -0
- package/src/components/sections/About/letter.astro +108 -0
- package/src/components/sections/About/portrait.astro +308 -0
- package/src/components/sections/Advocacy/compact.astro +14 -0
- package/src/components/sections/Advocacy/index.astro +14 -0
- package/src/components/sections/Band.astro +39 -0
- package/src/components/sections/Blog/feature.astro +176 -0
- package/src/components/sections/Blog/index.astro +37 -0
- package/src/components/sections/Blog/latest.ts +80 -0
- package/src/components/sections/Blog/list.astro +186 -0
- package/src/components/sections/Booking/index.astro +139 -0
- package/src/components/sections/Booking/list.astro +144 -0
- package/src/components/sections/Booking/types.ts +60 -0
- package/src/components/sections/Calendar/agenda.astro +14 -0
- package/src/components/sections/Calendar/index.astro +14 -0
- package/src/components/sections/CandidateRoster/ballot.astro +394 -0
- package/src/components/sections/CandidateRoster/candidates.ts +69 -0
- package/src/components/sections/CandidateRoster/compact.astro +115 -0
- package/src/components/sections/CandidateRoster/index.astro +57 -0
- package/src/components/sections/CaseStudies/beforeafter.astro +222 -0
- package/src/components/sections/CaseStudies/cases.ts +111 -0
- package/src/components/sections/CaseStudies/grid.astro +261 -0
- package/src/components/sections/CaseStudies/index.astro +333 -0
- package/src/components/sections/Classroom/CourseCard.astro +181 -0
- package/src/components/sections/Classroom/Courses.astro +88 -0
- package/src/components/sections/Classroom/classroom.ts +141 -0
- package/src/components/sections/Classroom/index.astro +20 -0
- package/src/components/sections/Classroom/list.astro +15 -0
- package/src/components/sections/Collection/compact.astro +7 -0
- package/src/components/sections/Collection/entries.ts +62 -0
- package/src/components/sections/Collection/feature.astro +180 -0
- package/src/components/sections/Collection/index.astro +46 -0
- package/src/components/sections/Collection/library.astro +271 -0
- package/src/components/sections/Collection/list.astro +7 -0
- package/src/components/sections/Collection/outline.astro +134 -0
- package/src/components/sections/Collection/shelves.astro +191 -0
- package/src/components/sections/Comparison/Unlisted.astro +6 -0
- package/src/components/sections/Comparison/cards.astro +171 -0
- package/src/components/sections/Comparison/index.astro +191 -0
- package/src/components/sections/Comparison/sides.ts +98 -0
- package/src/components/sections/Comparison/spectrum.astro +261 -0
- package/src/components/sections/ContentPost/banner.astro +152 -0
- package/src/components/sections/ContentPost/index.astro +35 -0
- package/src/components/sections/ContentPost/lesson.ts +119 -0
- package/src/components/sections/ContentPost/player.astro +254 -0
- package/src/components/sections/ContentPost/theater.astro +329 -0
- package/src/components/sections/Countdown/index.astro +53 -0
- package/src/components/sections/Course/Bar.astro +46 -0
- package/src/components/sections/Course/CourseHead.astro +123 -0
- package/src/components/sections/Course/Crumbs.astro +44 -0
- package/src/components/sections/Course/Icon.astro +29 -0
- package/src/components/sections/Course/Ring.astro +62 -0
- package/src/components/sections/Course/Syllabus.astro +146 -0
- package/src/components/sections/Course/course.ts +146 -0
- package/src/components/sections/Course/index.astro +143 -0
- package/src/components/sections/Course/outline.astro +39 -0
- package/src/components/sections/Cta/banner.astro +64 -0
- package/src/components/sections/Cta/card.astro +88 -0
- package/src/components/sections/Cta/index.astro +31 -0
- package/src/components/sections/Cta/photo.astro +114 -0
- package/src/components/sections/Cta/strip.astro +91 -0
- package/src/components/sections/Donate/index.astro +136 -0
- package/src/components/sections/Donate/story.astro +7 -0
- package/src/components/sections/Event/card.astro +14 -0
- package/src/components/sections/Event/index.astro +14 -0
- package/src/components/sections/EventsList/AgendaMonths.astro +105 -0
- package/src/components/sections/EventsList/CalendarLine.astro +23 -0
- package/src/components/sections/EventsList/EventRows.astro +196 -0
- package/src/components/sections/EventsList/LiveCounts.astro +75 -0
- package/src/components/sections/EventsList/TypeTabs.astro +53 -0
- package/src/components/sections/EventsList/agenda.astro +55 -0
- package/src/components/sections/EventsList/calendar.astro +392 -0
- package/src/components/sections/EventsList/cards.astro +186 -0
- package/src/components/sections/EventsList/cohorts.astro +205 -0
- package/src/components/sections/EventsList/compact.astro +163 -0
- package/src/components/sections/EventsList/events.ts +168 -0
- package/src/components/sections/EventsList/index.astro +46 -0
- package/src/components/sections/EventsList/map.astro +436 -0
- package/src/components/sections/EventsList/shifts.astro +355 -0
- package/src/components/sections/EventsList/week.astro +361 -0
- package/src/components/sections/Faq/Contact.astro +63 -0
- package/src/components/sections/Faq/Questions.astro +98 -0
- package/src/components/sections/Faq/cards.astro +74 -0
- package/src/components/sections/Faq/faq.ts +101 -0
- package/src/components/sections/Faq/index.astro +49 -0
- package/src/components/sections/Faq/topics.astro +178 -0
- package/src/components/sections/Financials/Foot.astro +38 -0
- package/src/components/sections/Financials/Head.astro +47 -0
- package/src/components/sections/Financials/donut.astro +197 -0
- package/src/components/sections/Financials/financials.ts +52 -0
- package/src/components/sections/Financials/index.astro +148 -0
- package/src/components/sections/Financials/table.astro +157 -0
- package/src/components/sections/FormBlock/index.astro +33 -0
- package/src/components/sections/FormBlock/wide.astro +7 -0
- package/src/components/sections/Hero/cover.astro +170 -0
- package/src/components/sections/Hero/donate.astro +209 -0
- package/src/components/sections/Hero/field.astro +390 -0
- package/src/components/sections/Hero/index.astro +52 -0
- package/src/components/sections/Hero/overlap.astro +151 -0
- package/src/components/sections/Hero/rotating.astro +30 -0
- package/src/components/sections/Hero/split.astro +96 -0
- package/src/components/sections/Hero/statement.astro +55 -0
- package/src/components/sections/Hero/video.astro +399 -0
- package/src/components/sections/Issues/checklist.astro +204 -0
- package/src/components/sections/Issues/drawer.astro +237 -0
- package/src/components/sections/Issues/index.astro +115 -0
- package/src/components/sections/Issues/issues.ts +37 -0
- package/src/components/sections/Issues/numbered.astro +79 -0
- package/src/components/sections/Issues/rows.astro +137 -0
- package/src/components/sections/Issues/steps.astro +81 -0
- package/src/components/sections/Issues/tabs.astro +322 -0
- package/src/components/sections/Leaderboard/index.astro +29 -0
- package/src/components/sections/Lesson/Door.astro +121 -0
- package/src/components/sections/Lesson/LessonBody.astro +416 -0
- package/src/components/sections/Lesson/Rail.astro +182 -0
- package/src/components/sections/Lesson/Tracker.astro +137 -0
- package/src/components/sections/Lesson/index.astro +27 -0
- package/src/components/sections/Lesson/lesson.ts +233 -0
- package/src/components/sections/Lesson/reading.astro +21 -0
- package/src/components/sections/Map/CoverageLine.astro +19 -0
- package/src/components/sections/Map/RegionMap.astro +109 -0
- package/src/components/sections/Map/bar.astro +160 -0
- package/src/components/sections/Map/index.astro +192 -0
- package/src/components/sections/Map/map.astro +275 -0
- package/src/components/sections/MediaKit/BioCard.astro +108 -0
- package/src/components/sections/MediaKit/Downloads.astro +88 -0
- package/src/components/sections/MediaKit/index.astro +183 -0
- package/src/components/sections/MediaKit/kit.ts +140 -0
- package/src/components/sections/MediaKit/press.astro +189 -0
- package/src/components/sections/MediaKit/speaker.astro +205 -0
- package/src/components/sections/Membership/Benefits.astro +42 -0
- package/src/components/sections/Membership/Check.astro +12 -0
- package/src/components/sections/Membership/Price.astro +61 -0
- package/src/components/sections/Membership/compare.astro +312 -0
- package/src/components/sections/Membership/index.astro +281 -0
- package/src/components/sections/Membership/offers.ts +169 -0
- package/src/components/sections/Membership/tiers.astro +217 -0
- package/src/components/sections/MovementMap/index.astro +50 -0
- package/src/components/sections/MovementTicker/index.astro +43 -0
- package/src/components/sections/Pathways/Doors.astro +147 -0
- package/src/components/sections/Pathways/Head.astro +37 -0
- package/src/components/sections/Pathways/index.astro +27 -0
- package/src/components/sections/Pathways/pathways.ts +100 -0
- package/src/components/sections/Pathways/quiz.astro +286 -0
- package/src/components/sections/Pathways/tabs.astro +271 -0
- package/src/components/sections/PdfEmbed/card.astro +99 -0
- package/src/components/sections/PdfEmbed/index.astro +26 -0
- package/src/components/sections/PdfEmbed/medium.astro +7 -0
- package/src/components/sections/PdfEmbed/tall.astro +7 -0
- package/src/components/sections/Petition/coverage.astro +14 -0
- package/src/components/sections/Petition/image.astro +14 -0
- package/src/components/sections/Petition/index.astro +14 -0
- package/src/components/sections/Petition/map.astro +14 -0
- package/src/components/sections/PlatformPlanks/anchors.ts +66 -0
- package/src/components/sections/PlatformPlanks/columns.astro +171 -0
- package/src/components/sections/PlatformPlanks/index.astro +56 -0
- package/src/components/sections/PlatformPlanks/longread.astro +250 -0
- package/src/components/sections/PollBlock/index.astro +30 -0
- package/src/components/sections/Portfolio/featured.astro +343 -0
- package/src/components/sections/Portfolio/index.astro +571 -0
- package/src/components/sections/Portfolio/strip.astro +173 -0
- package/src/components/sections/Portfolio/work.ts +100 -0
- package/src/components/sections/Progress/MatchClock.astro +166 -0
- package/src/components/sections/Progress/compact.astro +150 -0
- package/src/components/sections/Progress/index.astro +32 -0
- package/src/components/sections/Progress/match.astro +126 -0
- package/src/components/sections/Progress/ring.astro +179 -0
- package/src/components/sections/QuickDonate/DonateCard.astro +149 -0
- package/src/components/sections/QuickDonate/Picker.astro +95 -0
- package/src/components/sections/QuickDonate/band.astro +164 -0
- package/src/components/sections/QuickDonate/bar.astro +208 -0
- package/src/components/sections/QuickDonate/donate.ts +126 -0
- package/src/components/sections/QuickDonate/hero.astro +143 -0
- package/src/components/sections/QuickDonate/index.astro +73 -0
- package/src/components/sections/QuickDonate/jar.astro +225 -0
- package/src/components/sections/QuickDonate/ladder.astro +248 -0
- package/src/components/sections/QuoteStrip/carousel.astro +340 -0
- package/src/components/sections/QuoteStrip/index.astro +58 -0
- package/src/components/sections/QuoteStrip/logos.astro +226 -0
- package/src/components/sections/QuoteStrip/quotes.ts +61 -0
- package/src/components/sections/QuoteStrip/single.astro +92 -0
- package/src/components/sections/QuoteStrip/ticker.astro +319 -0
- package/src/components/sections/QuoteStrip/wall.astro +113 -0
- package/src/components/sections/Resources/band.astro +93 -0
- package/src/components/sections/Resources/featured.astro +239 -0
- package/src/components/sections/Resources/index.astro +225 -0
- package/src/components/sections/Resources/resources.ts +92 -0
- package/src/components/sections/SampleBallot/Position.astro +39 -0
- package/src/components/sections/SampleBallot/ballot.ts +92 -0
- package/src/components/sections/SampleBallot/cards.astro +299 -0
- package/src/components/sections/SampleBallot/index.astro +326 -0
- package/src/components/sections/SampleBallot/measures.astro +172 -0
- package/src/components/sections/Scorecard/grades.astro +141 -0
- package/src/components/sections/Scorecard/index.astro +294 -0
- package/src/components/sections/Scorecard/promise.astro +167 -0
- package/src/components/sections/Scorecard/votes.ts +83 -0
- package/src/components/sections/SectionHead.astro +31 -0
- package/src/components/sections/Services/Button.astro +24 -0
- package/src/components/sections/Services/Check.astro +12 -0
- package/src/components/sections/Services/Includes.astro +42 -0
- package/src/components/sections/Services/compare.astro +328 -0
- package/src/components/sections/Services/index.astro +187 -0
- package/src/components/sections/Services/list.astro +181 -0
- package/src/components/sections/Services/services.ts +80 -0
- package/src/components/sections/ShareKit/Actions.astro +71 -0
- package/src/components/sections/ShareKit/Buttons.astro +62 -0
- package/src/components/sections/ShareKit/compact.astro +123 -0
- package/src/components/sections/ShareKit/index.astro +160 -0
- package/src/components/sections/ShareKit/share.ts +60 -0
- package/src/components/sections/ShareKit/strip.astro +173 -0
- package/src/components/sections/SignupCapture/band.astro +7 -0
- package/src/components/sections/SignupCapture/index.astro +103 -0
- package/src/components/sections/SignupCapture/inline.astro +7 -0
- package/src/components/sections/SocialFeed/index.astro +34 -0
- package/src/components/sections/StatCards/feature.astro +143 -0
- package/src/components/sections/StatCards/index.astro +51 -0
- package/src/components/sections/StatCards/ribbon.astro +113 -0
- package/src/components/sections/StatCards/wall.astro +177 -0
- package/src/components/sections/Store/featured.astro +14 -0
- package/src/components/sections/Store/index.astro +14 -0
- package/src/components/sections/Stories/Status.astro +42 -0
- package/src/components/sections/Stories/StoryCards.astro +171 -0
- package/src/components/sections/Stories/cards.astro +42 -0
- package/src/components/sections/Stories/index.astro +238 -0
- package/src/components/sections/Stories/stories.ts +97 -0
- package/src/components/sections/Stories/timeline.astro +135 -0
- package/src/components/sections/TeamGrid/board.astro +280 -0
- package/src/components/sections/TeamGrid/index.astro +71 -0
- package/src/components/sections/TeamGrid/list.astro +306 -0
- package/src/components/sections/TeamGrid/people.ts +178 -0
- package/src/components/sections/VideoEmbed/index.astro +52 -0
- package/src/components/sections/VideoEmbed/landscape.astro +7 -0
- package/src/components/sections/VideoEmbed/portrait.astro +7 -0
- package/src/components/sections/VideoEmbed/square.astro +7 -0
- package/src/components/sections/VoterTools/DaysLeft.astro +33 -0
- package/src/components/sections/VoterTools/dates.astro +149 -0
- package/src/components/sections/VoterTools/index.astro +228 -0
- package/src/components/sections/VoterTools/polling.astro +141 -0
- package/src/components/sections/VoterTools/voter-tools.ts +70 -0
- package/src/components/sections/index.ts +370 -0
- package/src/components/sections/modules/Headed.astro +39 -0
- package/src/components/sections/modules/ModuleFrame.astro +179 -0
- package/src/components/volunteer/ShiftLive.astro +90 -0
- package/src/components/volunteer/detail.astro +247 -0
- package/src/components/volunteer/list.astro +298 -0
- package/src/components/volunteer/props.ts +21 -0
- package/src/env.d.ts +22 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +64 -0
- package/src/layouts/Site.astro +371 -0
- package/src/lib/academy.ts +146 -0
- package/src/lib/brand.ts +534 -0
- package/src/lib/chrome.ts +119 -0
- package/src/lib/donate-frame.ts +64 -0
- package/src/lib/entries.ts +190 -0
- package/src/lib/env.ts +34 -0
- package/src/lib/event-map-draw.ts +91 -0
- package/src/lib/events.ts +476 -0
- package/src/lib/fonts.ts +116 -0
- package/src/lib/footer.ts +24 -0
- package/src/lib/format.ts +160 -0
- package/src/lib/geo.ts +131 -0
- package/src/lib/live.ts +54 -0
- package/src/lib/menu.ts +48 -0
- package/src/lib/petition-text.ts +29 -0
- package/src/lib/reading.ts +17 -0
- package/src/lib/regions.ts +215 -0
- package/src/lib/section.ts +94 -0
- package/src/lib/shifts.ts +186 -0
- package/src/lib/stream-time.ts +20 -0
- package/src/lib/stream.ts +141 -0
- package/src/lib/visitor.ts +54 -0
- package/src/routes/catch-all.astro +286 -0
- package/src/routes/form.astro +30 -0
- package/src/routes/live.astro +49 -0
- package/src/routes/not-found.astro +18 -0
- package/src/routes/preview.astro +60 -0
- package/src/routes/setup.astro +62 -0
- package/src/routes/volunteer-shift.astro +61 -0
- package/src/routes/volunteer.astro +37 -0
- package/src/styles/entries.css +784 -0
- package/src/styles/site.css +1839 -0
- package/src/template.ts +182 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Resources · Featured (board 09, A, "Lead magnet hero", without its email
|
|
3
|
+
// field): the kicker, heading and line of copy, then the first resource as a
|
|
4
|
+
// panel in the contrast band's colours (on a section already on the contrast
|
|
5
|
+
// band, a tint of its ink). Its picture stands at the left as a cover (when
|
|
6
|
+
// it has none, a panel on the surface with its title large and its detail
|
|
7
|
+
// under); at the right its kind as a chip, its title large in the display
|
|
8
|
+
// face, its summary as a checked list (one line of the summary, one point),
|
|
9
|
+
// the one button, and the detail small under it. The button is the
|
|
10
|
+
// section's link (`buttonLabel` → `buttonHref`, where BackGold's sign-up
|
|
11
|
+
// is), else the resource's own address under the same words. On a phone the
|
|
12
|
+
// cover sits over the words, narrower.
|
|
13
|
+
//
|
|
14
|
+
// The other resources follow as a compact list: the title (linked as the
|
|
15
|
+
// library's cards are: a gated one to `buttonHref`, an open one to its own
|
|
16
|
+
// address), the kind and the detail (the detail alone when it repeats the
|
|
17
|
+
// kind), and the `openLabel` or `gatedLabel` chip at the right. No email field is drawn here. With no resource and no
|
|
18
|
+
// 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 { buttonFor, metaOf, resourcesOf } from './resources'
|
|
25
|
+
|
|
26
|
+
type Props = ComponentProps<typeof Default>
|
|
27
|
+
|
|
28
|
+
const { section } = Astro.props
|
|
29
|
+
const found = resourcesOf(section)
|
|
30
|
+
const [first, ...rest] = found.resources
|
|
31
|
+
const button = buttonFor(found, first)
|
|
32
|
+
const listed = rest.map((r) => ({ ...r, meta: metaOf(r) }))
|
|
33
|
+
---
|
|
34
|
+
{(first || found.heading) && (
|
|
35
|
+
<Band section={section} class="resources resources-featured">
|
|
36
|
+
<div class="res-intro">
|
|
37
|
+
<SectionHead kicker={found.kicker} heading={found.heading} more={[]} />
|
|
38
|
+
<Prose value={section.copy.body} class="lede" />
|
|
39
|
+
</div>
|
|
40
|
+
{first && (
|
|
41
|
+
<article class="res-hero bg-band-contrast">
|
|
42
|
+
<div class="res-cover-frame">
|
|
43
|
+
{first.picture ? (
|
|
44
|
+
<img class="res-cover" src={first.picture} alt="" loading="lazy" decoding="async" />
|
|
45
|
+
) : (
|
|
46
|
+
<div class="res-cover res-cover-words" aria-hidden="true">
|
|
47
|
+
<p class="res-cover-title">{first.title}</p>
|
|
48
|
+
{first.detail && <p class="res-cover-detail">{first.detail}</p>}
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
<div class="res-hero-words">
|
|
53
|
+
{first.kind && <p class="res-hero-kind"><span class="chip">{first.kind}</span></p>}
|
|
54
|
+
<h3 class="res-hero-title">{first.title}</h3>
|
|
55
|
+
{first.points.length > 0 && (
|
|
56
|
+
<ul class="res-points" role="list">
|
|
57
|
+
{first.points.map((point) => (
|
|
58
|
+
<li>
|
|
59
|
+
<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" stroke-linecap="round" stroke-linejoin="round" /></svg>
|
|
60
|
+
<span>{point}</span>
|
|
61
|
+
</li>
|
|
62
|
+
))}
|
|
63
|
+
</ul>
|
|
64
|
+
)}
|
|
65
|
+
{button && <p class="res-hero-action"><a class="button" href={button.href} rel={button.rel}>{button.label}</a></p>}
|
|
66
|
+
{first.detail && <p class="res-hero-detail">{first.detail}</p>}
|
|
67
|
+
</div>
|
|
68
|
+
</article>
|
|
69
|
+
)}
|
|
70
|
+
{listed.length > 0 && (
|
|
71
|
+
<ul class="res-list" role="list">
|
|
72
|
+
{listed.map((r) => (
|
|
73
|
+
<li class="res-row">
|
|
74
|
+
<div class="res-row-words">
|
|
75
|
+
<p class="res-row-title">{r.link ? <a href={r.link.href} rel={r.link.rel}>{r.title}</a> : r.title}</p>
|
|
76
|
+
{r.meta && <p class="res-row-meta">{r.meta}</p>}
|
|
77
|
+
</div>
|
|
78
|
+
<span class:list={['chip', r.gated && 'chip-accent']}>{r.gated ? found.gatedLabel : found.openLabel}</span>
|
|
79
|
+
</li>
|
|
80
|
+
))}
|
|
81
|
+
</ul>
|
|
82
|
+
)}
|
|
83
|
+
</Band>
|
|
84
|
+
)}
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
.res-intro > :global(.lede) {
|
|
88
|
+
margin: -0.5rem 0 1.75rem;
|
|
89
|
+
}
|
|
90
|
+
.res-intro:last-child > :global(.lede) {
|
|
91
|
+
margin-bottom: 0;
|
|
92
|
+
}
|
|
93
|
+
.res-hero {
|
|
94
|
+
display: grid;
|
|
95
|
+
grid-template-columns: minmax(0, 1fr);
|
|
96
|
+
gap: 1.5rem;
|
|
97
|
+
padding: 1.5rem;
|
|
98
|
+
border-radius: var(--radius-card);
|
|
99
|
+
background: var(--bg-band-background);
|
|
100
|
+
color: var(--bg-band-color);
|
|
101
|
+
}
|
|
102
|
+
:global(.bg-band-contrast) .res-hero {
|
|
103
|
+
border: 1px solid var(--line);
|
|
104
|
+
background: color-mix(in srgb, var(--ink) 7%, transparent);
|
|
105
|
+
}
|
|
106
|
+
.res-cover-frame {
|
|
107
|
+
width: min(100%, 11rem);
|
|
108
|
+
}
|
|
109
|
+
.res-cover {
|
|
110
|
+
display: block;
|
|
111
|
+
width: 100%;
|
|
112
|
+
aspect-ratio: 3 / 4;
|
|
113
|
+
object-fit: cover;
|
|
114
|
+
border-radius: var(--radius);
|
|
115
|
+
}
|
|
116
|
+
.res-cover-words {
|
|
117
|
+
display: flex;
|
|
118
|
+
flex-direction: column;
|
|
119
|
+
justify-content: flex-end;
|
|
120
|
+
gap: 0.5rem;
|
|
121
|
+
padding: 1rem;
|
|
122
|
+
border: 1px solid var(--line);
|
|
123
|
+
background: var(--surface);
|
|
124
|
+
box-shadow: inset 0 -4px 0 var(--accent);
|
|
125
|
+
color: var(--ink);
|
|
126
|
+
}
|
|
127
|
+
.res-cover-words > * {
|
|
128
|
+
margin: 0;
|
|
129
|
+
}
|
|
130
|
+
.res-cover-title {
|
|
131
|
+
font-family: var(--font-display);
|
|
132
|
+
font-size: 1.125rem;
|
|
133
|
+
font-weight: 800;
|
|
134
|
+
letter-spacing: -0.01em;
|
|
135
|
+
line-height: 1.15;
|
|
136
|
+
overflow-wrap: anywhere;
|
|
137
|
+
}
|
|
138
|
+
.res-cover-detail {
|
|
139
|
+
color: var(--muted);
|
|
140
|
+
font-size: var(--text-xs);
|
|
141
|
+
font-weight: 600;
|
|
142
|
+
}
|
|
143
|
+
.res-hero-words {
|
|
144
|
+
min-width: 0;
|
|
145
|
+
}
|
|
146
|
+
.res-hero-words > * {
|
|
147
|
+
margin: 0;
|
|
148
|
+
}
|
|
149
|
+
.res-hero-kind {
|
|
150
|
+
margin-bottom: 0.75rem;
|
|
151
|
+
}
|
|
152
|
+
.res-hero-words .res-hero-title {
|
|
153
|
+
font-size: calc(var(--h2) * 0.8);
|
|
154
|
+
font-weight: 800;
|
|
155
|
+
line-height: 1.1;
|
|
156
|
+
max-width: 22ch;
|
|
157
|
+
}
|
|
158
|
+
.res-hero-words > .res-points {
|
|
159
|
+
margin-top: 1.25rem;
|
|
160
|
+
}
|
|
161
|
+
.res-points {
|
|
162
|
+
display: grid;
|
|
163
|
+
gap: 0.5rem;
|
|
164
|
+
padding: 0;
|
|
165
|
+
list-style: none;
|
|
166
|
+
}
|
|
167
|
+
.res-points li {
|
|
168
|
+
display: grid;
|
|
169
|
+
grid-template-columns: 1rem minmax(0, 1fr);
|
|
170
|
+
gap: 0.625rem;
|
|
171
|
+
align-items: start;
|
|
172
|
+
line-height: 1.45;
|
|
173
|
+
}
|
|
174
|
+
.res-points svg {
|
|
175
|
+
margin-top: 0.2em;
|
|
176
|
+
color: var(--accent);
|
|
177
|
+
}
|
|
178
|
+
.res-hero-words > .res-hero-action {
|
|
179
|
+
margin-top: 1.5rem;
|
|
180
|
+
}
|
|
181
|
+
.res-hero-words > .res-hero-detail {
|
|
182
|
+
margin-top: 0.75rem;
|
|
183
|
+
color: var(--muted);
|
|
184
|
+
font-size: var(--text-sm);
|
|
185
|
+
}
|
|
186
|
+
.res-list {
|
|
187
|
+
margin: 1.75rem 0 0;
|
|
188
|
+
padding: 0;
|
|
189
|
+
list-style: none;
|
|
190
|
+
border-top: 2px solid var(--ink);
|
|
191
|
+
}
|
|
192
|
+
.res-row {
|
|
193
|
+
display: grid;
|
|
194
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
195
|
+
gap: 0.5rem 1rem;
|
|
196
|
+
align-items: center;
|
|
197
|
+
padding: 0.875rem 0;
|
|
198
|
+
border-bottom: 1px solid var(--line);
|
|
199
|
+
}
|
|
200
|
+
.res-row-words > * {
|
|
201
|
+
margin: 0;
|
|
202
|
+
}
|
|
203
|
+
.res-row-title {
|
|
204
|
+
font-weight: 700;
|
|
205
|
+
line-height: 1.35;
|
|
206
|
+
}
|
|
207
|
+
.res-row-title a {
|
|
208
|
+
color: var(--ink);
|
|
209
|
+
}
|
|
210
|
+
.res-row-meta {
|
|
211
|
+
margin-top: 0.125rem;
|
|
212
|
+
color: var(--muted);
|
|
213
|
+
font-size: var(--text-sm);
|
|
214
|
+
}
|
|
215
|
+
@media (min-width: 40rem) {
|
|
216
|
+
.res-hero {
|
|
217
|
+
grid-template-columns: 12rem minmax(0, 1fr);
|
|
218
|
+
gap: 2rem;
|
|
219
|
+
align-items: center;
|
|
220
|
+
padding: 2rem;
|
|
221
|
+
}
|
|
222
|
+
.res-cover-frame {
|
|
223
|
+
width: 100%;
|
|
224
|
+
}
|
|
225
|
+
.res-cover-title {
|
|
226
|
+
font-size: 1.375rem;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
@media (min-width: 56rem) {
|
|
230
|
+
.res-hero {
|
|
231
|
+
grid-template-columns: 15rem minmax(0, 1fr);
|
|
232
|
+
gap: 2.5rem;
|
|
233
|
+
padding: 2.25rem 2.5rem;
|
|
234
|
+
}
|
|
235
|
+
.res-cover-words {
|
|
236
|
+
padding: 1.25rem;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
</style>
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Resources, 'library' layout, the default (board 09, B, "Resource
|
|
3
|
+
// library"): the kicker and heading, the line of copy, then a card per guide
|
|
4
|
+
// or download on the band's surface, four across on a wide screen, three on
|
|
5
|
+
// a tablet and two on a phone. Each card opens with the resource's kind in
|
|
6
|
+
// small capitals, then its title, the detail ("PDF · 18 pp") in the muted
|
|
7
|
+
// ink and, at the foot, a chip: `openLabel` ("Free") on an open resource,
|
|
8
|
+
// `gatedLabel` ("Email to unlock") in the accent on a gated one. The whole
|
|
9
|
+
// card is the resource's link: an open one goes to its own address, a gated
|
|
10
|
+
// one to the section's `buttonHref`, where BackGold's sign-up is, and to its
|
|
11
|
+
// own address when the section has none. No email field is drawn here.
|
|
12
|
+
//
|
|
13
|
+
// When the resources name more than one kind, a chip per kind ("All" first,
|
|
14
|
+
// then each kind in row order) narrows the cards to that kind, with
|
|
15
|
+
// "Showing N of M." for a screen reader. The chips are drawn hidden and shown
|
|
16
|
+
// by the section's script, so with scripts off every card shows and nothing
|
|
17
|
+
// is offered that cannot work. With no resource and no heading it draws
|
|
18
|
+
// nothing.
|
|
19
|
+
import type { Section } from '@backgold/content'
|
|
20
|
+
import Band from '../Band.astro'
|
|
21
|
+
import SectionHead from '../SectionHead.astro'
|
|
22
|
+
import Prose from '../../Prose.astro'
|
|
23
|
+
import { idFor } from '../SampleBallot/ballot'
|
|
24
|
+
import { kindsOf, resourcesOf } from './resources'
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
section: Section
|
|
28
|
+
variant?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { section } = Astro.props
|
|
32
|
+
const found = resourcesOf(section)
|
|
33
|
+
const { resources } = found
|
|
34
|
+
const kinds = kindsOf(resources)
|
|
35
|
+
const filter = kinds.length > 1
|
|
36
|
+
const cardsId = idFor(section, 'resources')
|
|
37
|
+
---
|
|
38
|
+
{(resources.length > 0 || found.heading) && (
|
|
39
|
+
<Band section={section} class="resources resources-library">
|
|
40
|
+
<div class="res-intro">
|
|
41
|
+
<SectionHead kicker={found.kicker} heading={found.heading} more={[]} />
|
|
42
|
+
<Prose value={section.copy.body} class="lede" />
|
|
43
|
+
</div>
|
|
44
|
+
{resources.length > 0 && (
|
|
45
|
+
<div class="res-library" data-resources>
|
|
46
|
+
{filter && (
|
|
47
|
+
<div class="res-kinds" role="group" aria-label="Filter by kind" data-resource-kinds hidden>
|
|
48
|
+
<button type="button" aria-pressed="true" aria-controls={cardsId} data-kind="">All</button>
|
|
49
|
+
{kinds.map((kind) => (
|
|
50
|
+
<button type="button" aria-pressed="false" aria-controls={cardsId} data-kind={kind}>{kind}</button>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
<ul class="res-cards" id={cardsId} role="list">
|
|
55
|
+
{resources.map((r) => (
|
|
56
|
+
<li class:list={['res-card', r.link && 'res-card-linked']} data-kind={r.kind ?? ''}>
|
|
57
|
+
{r.kind && <p class="res-card-kind">{r.kind}</p>}
|
|
58
|
+
<h3 class="res-card-title">{r.link ? <a href={r.link.href} rel={r.link.rel}>{r.title}</a> : r.title}</h3>
|
|
59
|
+
{r.detail && <p class="res-card-detail">{r.detail}</p>}
|
|
60
|
+
<p class="res-card-chip">
|
|
61
|
+
<span class:list={['chip', r.gated && 'chip-accent']}>{r.gated ? found.gatedLabel : found.openLabel}</span>
|
|
62
|
+
</p>
|
|
63
|
+
</li>
|
|
64
|
+
))}
|
|
65
|
+
</ul>
|
|
66
|
+
{filter && <p class="visually-hidden" role="status" data-resource-showing></p>}
|
|
67
|
+
{filter && (
|
|
68
|
+
<script is:inline>
|
|
69
|
+
;(function (root) {
|
|
70
|
+
if (!root) return
|
|
71
|
+
var group = root.querySelector('[data-resource-kinds]')
|
|
72
|
+
var chips = group.querySelectorAll('[data-kind]')
|
|
73
|
+
var cards = root.querySelectorAll('.res-cards > [data-kind]')
|
|
74
|
+
var showing = root.querySelector('[data-resource-showing]')
|
|
75
|
+
var choose = function (chip) {
|
|
76
|
+
var kind = chip.getAttribute('data-kind')
|
|
77
|
+
var shown = 0
|
|
78
|
+
for (var c = 0; c < chips.length; c++) chips[c].setAttribute('aria-pressed', chips[c] === chip ? 'true' : 'false')
|
|
79
|
+
for (var i = 0; i < cards.length; i++) {
|
|
80
|
+
var match = !kind || cards[i].getAttribute('data-kind') === kind
|
|
81
|
+
cards[i].hidden = !match
|
|
82
|
+
if (match) shown++
|
|
83
|
+
}
|
|
84
|
+
showing.textContent = shown === cards.length ? 'Showing all ' + cards.length + '.' : 'Showing ' + shown + ' of ' + cards.length + '.'
|
|
85
|
+
}
|
|
86
|
+
for (var c = 0; c < chips.length; c++) {
|
|
87
|
+
chips[c].addEventListener('click', function (event) {
|
|
88
|
+
choose(event.currentTarget)
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
group.hidden = false
|
|
92
|
+
})(document.currentScript.closest('[data-resources]'))
|
|
93
|
+
</script>
|
|
94
|
+
)}
|
|
95
|
+
</div>
|
|
96
|
+
)}
|
|
97
|
+
</Band>
|
|
98
|
+
)}
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
.res-intro > :global(.lede) {
|
|
102
|
+
margin: -0.5rem 0 1.75rem;
|
|
103
|
+
}
|
|
104
|
+
.res-intro:last-child > :global(.lede) {
|
|
105
|
+
margin-bottom: 0;
|
|
106
|
+
}
|
|
107
|
+
.res-kinds {
|
|
108
|
+
display: flex;
|
|
109
|
+
flex-wrap: wrap;
|
|
110
|
+
gap: 0.5rem;
|
|
111
|
+
margin-bottom: 1.25rem;
|
|
112
|
+
}
|
|
113
|
+
.res-kinds[hidden],
|
|
114
|
+
.res-card[hidden] {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
.res-kinds button {
|
|
118
|
+
min-height: 2.75rem;
|
|
119
|
+
padding: 0.375rem 0.875rem;
|
|
120
|
+
border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent);
|
|
121
|
+
border-radius: var(--pill);
|
|
122
|
+
background: transparent;
|
|
123
|
+
color: var(--ink);
|
|
124
|
+
font: inherit;
|
|
125
|
+
font-size: var(--text-sm);
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
cursor: pointer;
|
|
128
|
+
}
|
|
129
|
+
.res-kinds button:hover {
|
|
130
|
+
border-color: var(--ink);
|
|
131
|
+
}
|
|
132
|
+
.res-kinds button[aria-pressed='true'] {
|
|
133
|
+
border-color: var(--button);
|
|
134
|
+
background: var(--button);
|
|
135
|
+
color: var(--button-ink);
|
|
136
|
+
}
|
|
137
|
+
.res-cards {
|
|
138
|
+
display: grid;
|
|
139
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
140
|
+
gap: 0.75rem;
|
|
141
|
+
margin: 0;
|
|
142
|
+
padding: 0;
|
|
143
|
+
list-style: none;
|
|
144
|
+
}
|
|
145
|
+
.res-card {
|
|
146
|
+
position: relative;
|
|
147
|
+
display: flex;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
align-items: flex-start;
|
|
150
|
+
gap: 0.375rem;
|
|
151
|
+
min-width: 0;
|
|
152
|
+
padding: 1rem;
|
|
153
|
+
border: 1px solid var(--line);
|
|
154
|
+
border-radius: var(--radius);
|
|
155
|
+
background: var(--surface);
|
|
156
|
+
}
|
|
157
|
+
.res-card > * {
|
|
158
|
+
margin: 0;
|
|
159
|
+
}
|
|
160
|
+
.res-card-kind {
|
|
161
|
+
color: var(--muted);
|
|
162
|
+
font-size: var(--text-xs);
|
|
163
|
+
font-weight: 700;
|
|
164
|
+
letter-spacing: 0.12em;
|
|
165
|
+
line-height: 1.4;
|
|
166
|
+
text-transform: uppercase;
|
|
167
|
+
overflow-wrap: anywhere;
|
|
168
|
+
}
|
|
169
|
+
.res-card .res-card-title {
|
|
170
|
+
font-size: var(--text);
|
|
171
|
+
font-weight: 700;
|
|
172
|
+
line-height: 1.3;
|
|
173
|
+
}
|
|
174
|
+
.res-card-title a {
|
|
175
|
+
color: var(--ink);
|
|
176
|
+
text-decoration: none;
|
|
177
|
+
}
|
|
178
|
+
/* The title's link covers the card. */
|
|
179
|
+
.res-card-title a::after {
|
|
180
|
+
content: '';
|
|
181
|
+
position: absolute;
|
|
182
|
+
inset: 0;
|
|
183
|
+
border-radius: var(--radius);
|
|
184
|
+
}
|
|
185
|
+
.res-card-title a:focus-visible {
|
|
186
|
+
outline: none;
|
|
187
|
+
}
|
|
188
|
+
.res-card-linked:hover .res-card-title a {
|
|
189
|
+
text-decoration: underline;
|
|
190
|
+
}
|
|
191
|
+
.res-card-linked:focus-within {
|
|
192
|
+
outline: 3px solid var(--ink);
|
|
193
|
+
outline-offset: 3px;
|
|
194
|
+
}
|
|
195
|
+
.res-card-detail {
|
|
196
|
+
color: var(--muted);
|
|
197
|
+
font-size: var(--text-sm);
|
|
198
|
+
line-height: 1.4;
|
|
199
|
+
}
|
|
200
|
+
.res-card > .res-card-chip {
|
|
201
|
+
margin-top: auto;
|
|
202
|
+
padding-top: 0.5rem;
|
|
203
|
+
}
|
|
204
|
+
.res-card-chip .chip {
|
|
205
|
+
white-space: normal;
|
|
206
|
+
}
|
|
207
|
+
@media (min-width: 40rem) {
|
|
208
|
+
.res-cards {
|
|
209
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
210
|
+
gap: 1rem;
|
|
211
|
+
}
|
|
212
|
+
.res-card {
|
|
213
|
+
padding: 1.25rem;
|
|
214
|
+
}
|
|
215
|
+
.res-card .res-card-title {
|
|
216
|
+
font-size: 1.0625rem;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
@media (min-width: 60rem) {
|
|
220
|
+
.res-cards {
|
|
221
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
222
|
+
gap: 1.25rem;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// A Resources section as its layouts draw it: the guides and downloads in
|
|
2
|
+
// the authored list (`resources`), in row order, each with its `title`,
|
|
3
|
+
// `kind` ("Guide", "Template"), `detail` ("PDF · 18 pp"), `summary`, `href`,
|
|
4
|
+
// picture (`imageUrl`) and whether it is `gated` behind an email. A row
|
|
5
|
+
// without a title is not a resource.
|
|
6
|
+
//
|
|
7
|
+
// The email capture is BackGold's, never drawn here: the section's one link
|
|
8
|
+
// (`buttonLabel` → `buttonHref`) is where a gated resource sends people (a
|
|
9
|
+
// page with the sign-up on it). So a gated resource links to that address
|
|
10
|
+
// and, failing it, to its own; an open one links to its own. The featured
|
|
11
|
+
// and band layouts' button is that link, else the first resource's own
|
|
12
|
+
// address under the same words.
|
|
13
|
+
|
|
14
|
+
import type { Section } from '@backgold/content'
|
|
15
|
+
import { safeSrc } from '@backgold/astro/server'
|
|
16
|
+
import { linkOf, links, rows, type Link } from '../../../lib/section'
|
|
17
|
+
import { text } from '../../../lib/format'
|
|
18
|
+
|
|
19
|
+
export interface Resource {
|
|
20
|
+
title: string
|
|
21
|
+
kind: string | null
|
|
22
|
+
detail: string | null
|
|
23
|
+
/** The summary's lines, blank ones dropped: the featured layout's points, the band's first line. */
|
|
24
|
+
points: string[]
|
|
25
|
+
/** Where the resource's card goes: the section's link for a gated one, else its own address. */
|
|
26
|
+
link: Link | null
|
|
27
|
+
picture: string | null
|
|
28
|
+
gated: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Resources {
|
|
32
|
+
kicker: string | null
|
|
33
|
+
heading: string | null
|
|
34
|
+
/** The chip on an open resource ("Free"). */
|
|
35
|
+
openLabel: string
|
|
36
|
+
/** The chip on a gated resource ("Email to unlock"). */
|
|
37
|
+
gatedLabel: string
|
|
38
|
+
/** The words on the featured and band layouts' button ("Get the playbook"). */
|
|
39
|
+
buttonLabel: string
|
|
40
|
+
/** The section's link: where a gated resource sends people. */
|
|
41
|
+
signup: Link | null
|
|
42
|
+
resources: Resource[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function resourcesOf(section: Section): Resources {
|
|
46
|
+
const signup = links(section)[0] ?? null
|
|
47
|
+
const resources = rows(section).flatMap((row) => {
|
|
48
|
+
const title = text(row.title)?.trim()
|
|
49
|
+
if (!title) return []
|
|
50
|
+
const gated = row.gated === true
|
|
51
|
+
const own = linkOf(title, row.href)
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
title,
|
|
55
|
+
kind: text(row.kind)?.trim() ?? null,
|
|
56
|
+
detail: text(row.detail)?.trim() ?? null,
|
|
57
|
+
points: (text(row.summary) ?? '').split('\n').map((line) => line.trim()).filter(Boolean),
|
|
58
|
+
link: gated && signup ? { ...signup, label: title } : own,
|
|
59
|
+
picture: safeSrc(row.imageUrl),
|
|
60
|
+
gated,
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
})
|
|
64
|
+
return {
|
|
65
|
+
kicker: text(section.copy.kicker),
|
|
66
|
+
heading: text(section.copy.heading),
|
|
67
|
+
openLabel: text(section.copy.openLabel)?.trim() ?? 'Free',
|
|
68
|
+
gatedLabel: text(section.copy.gatedLabel)?.trim() ?? 'Email to unlock',
|
|
69
|
+
buttonLabel: text(section.copy.buttonLabel)?.trim() ?? 'Get it',
|
|
70
|
+
signup,
|
|
71
|
+
resources,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The featured and band layouts' one button: the section's link, else the resource's own address under the button's words. */
|
|
76
|
+
export function buttonFor(found: Resources, resource: Resource | undefined): Link | null {
|
|
77
|
+
if (found.signup) return found.signup
|
|
78
|
+
if (!resource?.link) return null
|
|
79
|
+
return { ...resource.link, label: found.buttonLabel }
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** "Guide · PDF · 18 pp": the kind and the detail, the detail alone when it repeats the kind ("Spreadsheet"). */
|
|
83
|
+
export function metaOf(resource: Resource): string | null {
|
|
84
|
+
const { kind, detail } = resource
|
|
85
|
+
if (kind && detail && kind.toLowerCase() === detail.toLowerCase()) return detail
|
|
86
|
+
return [kind, detail].filter(Boolean).join(' · ') || null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The distinct kinds in row order: the library's filter chips. */
|
|
90
|
+
export function kindsOf(resources: Resource[]): string[] {
|
|
91
|
+
return [...new Set(resources.map((r) => r.kind).filter((kind): kind is string => kind !== null))]
|
|
92
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
// A ballot measure's position as every SampleBallot layout shows it: a chip
|
|
3
|
+
// reading YES, NO or No position. Yes wears the band's accent; no and no
|
|
4
|
+
// position are outlines, no in the text colour and no position muted, so a
|
|
5
|
+
// position never reads as a party's red or blue. On paper each is an outline
|
|
6
|
+
// in black ink.
|
|
7
|
+
import { positionLabel, type Position } from './ballot'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
position: Position
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { position } = Astro.props
|
|
14
|
+
---
|
|
15
|
+
<span class:list={['chip', 'position', `position-${position}`, position === 'yes' && 'chip-accent']}>{positionLabel(position)}</span>
|
|
16
|
+
|
|
17
|
+
<style>
|
|
18
|
+
.position {
|
|
19
|
+
border: 1.5px solid transparent;
|
|
20
|
+
letter-spacing: 0.06em;
|
|
21
|
+
}
|
|
22
|
+
.position-no,
|
|
23
|
+
.position-neutral {
|
|
24
|
+
background: transparent;
|
|
25
|
+
border-color: var(--line-strong);
|
|
26
|
+
color: var(--ink);
|
|
27
|
+
}
|
|
28
|
+
.position-neutral {
|
|
29
|
+
color: var(--muted);
|
|
30
|
+
letter-spacing: 0.02em;
|
|
31
|
+
}
|
|
32
|
+
@media print {
|
|
33
|
+
.position {
|
|
34
|
+
border-color: black;
|
|
35
|
+
background: none;
|
|
36
|
+
color: black;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// A SampleBallot's rows as its layouts draw them: the races (a candidate for
|
|
2
|
+
// an office, with the party, the place on the ballot, a line about them, a
|
|
3
|
+
// link to their page, the headshot, and whether the organization endorses
|
|
4
|
+
// them) and the measures (a title in `office`, the organization's position,
|
|
5
|
+
// the line on it and a link to its analysis), each in the order the
|
|
6
|
+
// organization wrote them. A race needs a name and a measure a title; any
|
|
7
|
+
// other row is left out. A row whose kind is not `measure` is a race.
|
|
8
|
+
|
|
9
|
+
import type { Section } from '@backgold/content'
|
|
10
|
+
import { safeSrc } from '@backgold/astro/server'
|
|
11
|
+
import { linkOf, rows, type Link } from '../../../lib/section'
|
|
12
|
+
import { text } from '../../../lib/format'
|
|
13
|
+
|
|
14
|
+
export interface Race {
|
|
15
|
+
office: string | null
|
|
16
|
+
name: string
|
|
17
|
+
party: string | null
|
|
18
|
+
region: string | null
|
|
19
|
+
summary: string | null
|
|
20
|
+
link: Link | null
|
|
21
|
+
photo: string | null
|
|
22
|
+
endorsed: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type Position = 'yes' | 'no' | 'neutral'
|
|
26
|
+
|
|
27
|
+
export interface Measure {
|
|
28
|
+
title: string
|
|
29
|
+
position: Position | null
|
|
30
|
+
summary: string | null
|
|
31
|
+
link: Link | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Ballot {
|
|
35
|
+
races: Race[]
|
|
36
|
+
measures: Measure[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const POSITIONS: readonly string[] = ['yes', 'no', 'neutral']
|
|
40
|
+
|
|
41
|
+
export function ballotOf(section: Section): Ballot {
|
|
42
|
+
const races: Race[] = []
|
|
43
|
+
const measures: Measure[] = []
|
|
44
|
+
for (const row of rows(section)) {
|
|
45
|
+
if (row.kind === 'measure') {
|
|
46
|
+
const title = text(row.office)
|
|
47
|
+
if (!title) continue
|
|
48
|
+
const position = typeof row.position === 'string' && POSITIONS.includes(row.position) ? (row.position as Position) : null
|
|
49
|
+
measures.push({ title, position, summary: text(row.summary), link: linkOf(title, row.href) })
|
|
50
|
+
continue
|
|
51
|
+
}
|
|
52
|
+
const name = text(row.name)
|
|
53
|
+
if (!name) continue
|
|
54
|
+
races.push({
|
|
55
|
+
office: text(row.office),
|
|
56
|
+
name,
|
|
57
|
+
party: text(row.party),
|
|
58
|
+
region: text(row.region),
|
|
59
|
+
summary: text(row.summary),
|
|
60
|
+
link: linkOf(name, row.href),
|
|
61
|
+
photo: safeSrc(row.imageUrl),
|
|
62
|
+
endorsed: row.endorsed === true,
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
return { races, measures }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The races grouped by office, each office where its first race comes, its races in row order. */
|
|
69
|
+
export function officesOf(races: Race[]): { office: string | null; races: Race[] }[] {
|
|
70
|
+
const offices: { office: string | null; races: Race[] }[] = []
|
|
71
|
+
for (const race of races) {
|
|
72
|
+
const group = offices.find((o) => o.office === race.office)
|
|
73
|
+
if (group) group.races.push(race)
|
|
74
|
+
else offices.push({ office: race.office, races: [race] })
|
|
75
|
+
}
|
|
76
|
+
return offices
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** "Dana Whitfield (Liberty)", or the name alone with no party. */
|
|
80
|
+
export function nameWithParty(race: Race): string {
|
|
81
|
+
return race.party ? `${race.name} (${race.party})` : race.name
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A measure's position as the chip says it: "YES", "NO", "No position". */
|
|
85
|
+
export function positionLabel(position: Position): string {
|
|
86
|
+
return position === 'neutral' ? 'No position' : position.toUpperCase()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** An id for the section's own elements, from its id. */
|
|
90
|
+
export function idFor(section: Section, suffix: string): string {
|
|
91
|
+
return `${section.id}-${suffix}`.replace(/[^A-Za-z0-9_-]/g, '-')
|
|
92
|
+
}
|