@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,394 @@
|
|
|
1
|
+
---
|
|
2
|
+
// CandidateRoster · Ballot (board A3, "Candidate roster · Ballot"; A12 shows it
|
|
3
|
+
// beside Cards and Compact): the candidates grouped by office in ballot order
|
|
4
|
+
// (by the office's level: Federal, State, County, Local, Municipal, Judicial,
|
|
5
|
+
// School board, then any other), each office under a rule with its level, each
|
|
6
|
+
// candidate with the headshot (initials when there is none), the place and
|
|
7
|
+
// status, an "Endorsed" chip on a candidate the party endorsed, their issues
|
|
8
|
+
// as chips, and the buttons to their donate address
|
|
9
|
+
// (only when the record has one) and their own site.
|
|
10
|
+
//
|
|
11
|
+
// Once there are more than ten candidates (DS §24.7) the board's controls
|
|
12
|
+
// come first: a search box ("Find a candidate or county", matching the name,
|
|
13
|
+
// the office and the place) and, when the candidates span more than one
|
|
14
|
+
// level, a tab per level with its count ("All 23", "State 5"). Both filter the
|
|
15
|
+
// roster in the browser, since it is already on the page and small; while
|
|
16
|
+
// they narrow it, "Showing N of M." says how far, with "Show all candidates"
|
|
17
|
+
// to undo both. The controls are drawn hidden and shown by the section's
|
|
18
|
+
// script, so with scripts off the whole roster shows and nothing is offered
|
|
19
|
+
// that cannot work. With no candidates it draws nothing.
|
|
20
|
+
import type { ComponentProps } from 'astro/types'
|
|
21
|
+
import type Default from './index.astro'
|
|
22
|
+
import Band from '../Band.astro'
|
|
23
|
+
import { text } from '../../../lib/format'
|
|
24
|
+
import { candidatesOf, initials, levelRank, type Candidate } from './candidates'
|
|
25
|
+
|
|
26
|
+
type Props = ComponentProps<typeof Default>
|
|
27
|
+
|
|
28
|
+
const CONTROLS_AFTER = 10
|
|
29
|
+
|
|
30
|
+
const { section } = Astro.props
|
|
31
|
+
const heading = text(section.copy.heading)
|
|
32
|
+
const candidates = candidatesOf(section)
|
|
33
|
+
const rosterId = `${section.id}-ballot`.replace(/[^A-Za-z0-9_-]/g, '-')
|
|
34
|
+
|
|
35
|
+
interface Office {
|
|
36
|
+
name: string
|
|
37
|
+
level: string | null
|
|
38
|
+
candidates: Candidate[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Offices in the order their first candidate arrives, then sorted by level;
|
|
42
|
+
// within an office, by place ("District 4" before "District 12").
|
|
43
|
+
const offices: Office[] = []
|
|
44
|
+
for (const c of candidates) {
|
|
45
|
+
const name = c.office ?? 'Also on the ballot'
|
|
46
|
+
let office = offices.find((o) => o.name === name)
|
|
47
|
+
if (!office) {
|
|
48
|
+
office = { name, level: c.level, candidates: [] }
|
|
49
|
+
offices.push(office)
|
|
50
|
+
}
|
|
51
|
+
office.candidates.push(c)
|
|
52
|
+
}
|
|
53
|
+
offices.sort((a, b) => levelRank(a.level) - levelRank(b.level))
|
|
54
|
+
for (const office of offices) office.candidates.sort((a, b) => (a.region ?? '').localeCompare(b.region ?? '', 'en', { numeric: true }))
|
|
55
|
+
|
|
56
|
+
const controls = candidates.length > CONTROLS_AFTER
|
|
57
|
+
const levels = [...new Set(candidates.map((c) => c.level).filter((l): l is string => l !== null))]
|
|
58
|
+
.sort((a, b) => levelRank(a) - levelRank(b))
|
|
59
|
+
.map((level) => ({ level, count: candidates.filter((c) => c.level === level).length }))
|
|
60
|
+
const tabs = controls && levels.length > 1 ? levels : []
|
|
61
|
+
const findText = (c: Candidate) => [c.name, c.office, c.region].filter(Boolean).join(' ').toLowerCase()
|
|
62
|
+
---
|
|
63
|
+
{candidates.length > 0 && (
|
|
64
|
+
<Band section={section} class="roster roster-ballot">
|
|
65
|
+
{heading && <h2>{heading}</h2>}
|
|
66
|
+
<div class="ballot-roster" data-ballot>
|
|
67
|
+
{controls && (
|
|
68
|
+
<div class="ballot-controls" data-ballot-controls hidden>
|
|
69
|
+
<input
|
|
70
|
+
class="ballot-search"
|
|
71
|
+
type="search"
|
|
72
|
+
aria-label="Find a candidate or county"
|
|
73
|
+
placeholder="Find a candidate or county"
|
|
74
|
+
aria-controls={rosterId}
|
|
75
|
+
data-ballot-search
|
|
76
|
+
/>
|
|
77
|
+
{tabs.length > 0 && (
|
|
78
|
+
<div class="ballot-tabs" role="group" aria-label="Levels">
|
|
79
|
+
<button type="button" aria-pressed="true" aria-controls={rosterId} data-ballot-level="">
|
|
80
|
+
All <span class="ballot-tab-count">{candidates.length}</span>
|
|
81
|
+
</button>
|
|
82
|
+
{tabs.map((t) => (
|
|
83
|
+
<button type="button" aria-pressed="false" aria-controls={rosterId} data-ballot-level={t.level}>
|
|
84
|
+
{t.level} <span class="ballot-tab-count">{t.count}</span>
|
|
85
|
+
</button>
|
|
86
|
+
))}
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
<div class="ballot" id={rosterId}>
|
|
92
|
+
{offices.map((office) => (
|
|
93
|
+
<div class="ballot-office" data-ballot-office>
|
|
94
|
+
<h3 class="ballot-office-name">
|
|
95
|
+
{office.name}
|
|
96
|
+
{office.level && <small>{office.level}</small>}
|
|
97
|
+
</h3>
|
|
98
|
+
<ul class="ballot-cands" role="list">
|
|
99
|
+
{office.candidates.map((c) => (
|
|
100
|
+
<li class="ballot-cand" data-level={c.level ?? ''} data-find={findText(c)}>
|
|
101
|
+
{c.photo ? (
|
|
102
|
+
<img class="ballot-photo" src={c.photo} alt="" loading="lazy" decoding="async" />
|
|
103
|
+
) : (
|
|
104
|
+
<span class="ballot-photo ballot-initials" aria-hidden="true">{initials(c.name)}</span>
|
|
105
|
+
)}
|
|
106
|
+
<div class="ballot-who">
|
|
107
|
+
<h4 class="ballot-name">{c.name}</h4>
|
|
108
|
+
{(c.region || c.status) && <p class="ballot-place">{[c.region, c.status].filter(Boolean).join(' · ')}</p>}
|
|
109
|
+
{c.endorsed && <p class="ballot-endorsed"><span class="chip chip-accent">Endorsed</span></p>}
|
|
110
|
+
{c.issues.length > 0 && (
|
|
111
|
+
<ul class="ballot-issues" role="list">
|
|
112
|
+
{c.issues.map((issue) => <li>{issue}</li>)}
|
|
113
|
+
</ul>
|
|
114
|
+
)}
|
|
115
|
+
</div>
|
|
116
|
+
{(c.donate || c.site) && (
|
|
117
|
+
<p class="ballot-acts">
|
|
118
|
+
{c.donate && (
|
|
119
|
+
<a class="button" href={c.donate.href} rel={c.donate.rel}>
|
|
120
|
+
{c.donate.label}<span class="visually-hidden"> to {c.name}</span>
|
|
121
|
+
</a>
|
|
122
|
+
)}
|
|
123
|
+
{c.site && (
|
|
124
|
+
<a class="button button-quiet" href={c.site.href} rel={c.site.rel}>
|
|
125
|
+
{c.site.label}<span class="visually-hidden">: {c.name}</span>
|
|
126
|
+
</a>
|
|
127
|
+
)}
|
|
128
|
+
</p>
|
|
129
|
+
)}
|
|
130
|
+
</li>
|
|
131
|
+
))}
|
|
132
|
+
</ul>
|
|
133
|
+
</div>
|
|
134
|
+
))}
|
|
135
|
+
</div>
|
|
136
|
+
{controls && (
|
|
137
|
+
<p class="ballot-showing" role="status" data-ballot-showing hidden>
|
|
138
|
+
<span data-ballot-count></span>
|
|
139
|
+
<button type="button" class="ballot-reset" data-ballot-reset>Show all candidates</button>
|
|
140
|
+
</p>
|
|
141
|
+
)}
|
|
142
|
+
{controls && (
|
|
143
|
+
<script is:inline>
|
|
144
|
+
(function (root) {
|
|
145
|
+
if (!root) return
|
|
146
|
+
var controls = root.querySelector('[data-ballot-controls]')
|
|
147
|
+
var search = root.querySelector('[data-ballot-search]')
|
|
148
|
+
var tabs = root.querySelectorAll('[data-ballot-level]')
|
|
149
|
+
var cands = root.querySelectorAll('[data-find]')
|
|
150
|
+
var offices = root.querySelectorAll('[data-ballot-office]')
|
|
151
|
+
var showing = root.querySelector('[data-ballot-showing]')
|
|
152
|
+
var count = root.querySelector('[data-ballot-count]')
|
|
153
|
+
var level = ''
|
|
154
|
+
var apply = function () {
|
|
155
|
+
var words = search.value.trim().toLowerCase()
|
|
156
|
+
var shown = 0
|
|
157
|
+
for (var i = 0; i < cands.length; i++) {
|
|
158
|
+
var match = (!level || cands[i].getAttribute('data-level') === level) && (!words || cands[i].getAttribute('data-find').indexOf(words) >= 0)
|
|
159
|
+
cands[i].hidden = !match
|
|
160
|
+
if (match) shown++
|
|
161
|
+
}
|
|
162
|
+
for (var o = 0; o < offices.length; o++) offices[o].hidden = !offices[o].querySelector('[data-find]:not([hidden])')
|
|
163
|
+
showing.hidden = shown === cands.length
|
|
164
|
+
count.textContent = shown === cands.length ? '' : 'Showing ' + shown + ' of ' + cands.length + '.'
|
|
165
|
+
}
|
|
166
|
+
var choose = function (tab) {
|
|
167
|
+
level = tab ? tab.getAttribute('data-ballot-level') : ''
|
|
168
|
+
for (var t = 0; t < tabs.length; t++) tabs[t].setAttribute('aria-pressed', tabs[t].getAttribute('data-ballot-level') === level ? 'true' : 'false')
|
|
169
|
+
}
|
|
170
|
+
for (var t = 0; t < tabs.length; t++) {
|
|
171
|
+
tabs[t].addEventListener('click', function (event) {
|
|
172
|
+
choose(event.currentTarget)
|
|
173
|
+
apply()
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
search.addEventListener('input', apply)
|
|
177
|
+
root.querySelector('[data-ballot-reset]').addEventListener('click', function () {
|
|
178
|
+
search.value = ''
|
|
179
|
+
choose(null)
|
|
180
|
+
apply()
|
|
181
|
+
search.focus()
|
|
182
|
+
})
|
|
183
|
+
controls.hidden = false
|
|
184
|
+
})(document.currentScript.closest('[data-ballot]'))
|
|
185
|
+
</script>
|
|
186
|
+
)}
|
|
187
|
+
</div>
|
|
188
|
+
</Band>
|
|
189
|
+
)}
|
|
190
|
+
|
|
191
|
+
<style>
|
|
192
|
+
.ballot-controls {
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-wrap: wrap;
|
|
195
|
+
align-items: center;
|
|
196
|
+
gap: 0.75rem 1rem;
|
|
197
|
+
margin-top: 1.25rem;
|
|
198
|
+
}
|
|
199
|
+
.ballot-controls[hidden],
|
|
200
|
+
.ballot-showing[hidden],
|
|
201
|
+
.ballot-office[hidden],
|
|
202
|
+
.ballot-cand[hidden] {
|
|
203
|
+
display: none;
|
|
204
|
+
}
|
|
205
|
+
.ballot-search {
|
|
206
|
+
flex: 1 1 16rem;
|
|
207
|
+
max-width: 24rem;
|
|
208
|
+
min-width: 0;
|
|
209
|
+
min-height: 2.75rem;
|
|
210
|
+
padding: 0.5rem 1.125rem;
|
|
211
|
+
border: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
|
|
212
|
+
border-radius: var(--pill);
|
|
213
|
+
background: color-mix(in srgb, var(--page) 70%, transparent);
|
|
214
|
+
color: var(--ink);
|
|
215
|
+
font: inherit;
|
|
216
|
+
font-size: var(--text-sm);
|
|
217
|
+
}
|
|
218
|
+
.ballot-search::placeholder {
|
|
219
|
+
color: var(--muted);
|
|
220
|
+
opacity: 1;
|
|
221
|
+
}
|
|
222
|
+
.ballot-search:focus-visible {
|
|
223
|
+
outline: 3px solid var(--ink);
|
|
224
|
+
outline-offset: 2px;
|
|
225
|
+
}
|
|
226
|
+
.ballot-tabs {
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-wrap: wrap;
|
|
229
|
+
gap: 0.5rem;
|
|
230
|
+
}
|
|
231
|
+
.ballot-tabs button {
|
|
232
|
+
min-height: 2.75rem;
|
|
233
|
+
padding: 0.375rem 0.875rem;
|
|
234
|
+
border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent);
|
|
235
|
+
border-radius: var(--pill);
|
|
236
|
+
background: transparent;
|
|
237
|
+
color: var(--ink);
|
|
238
|
+
font: inherit;
|
|
239
|
+
font-size: var(--text-sm);
|
|
240
|
+
font-weight: 600;
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
}
|
|
243
|
+
.ballot-tabs button:hover {
|
|
244
|
+
border-color: var(--ink);
|
|
245
|
+
}
|
|
246
|
+
.ballot-tabs button[aria-pressed='true'] {
|
|
247
|
+
border-color: var(--button);
|
|
248
|
+
background: var(--button);
|
|
249
|
+
color: var(--button-ink);
|
|
250
|
+
}
|
|
251
|
+
.ballot-tab-count {
|
|
252
|
+
opacity: 0.75;
|
|
253
|
+
}
|
|
254
|
+
.ballot {
|
|
255
|
+
display: grid;
|
|
256
|
+
gap: 1.5rem;
|
|
257
|
+
margin-top: 1.5rem;
|
|
258
|
+
}
|
|
259
|
+
.ballot-office {
|
|
260
|
+
display: grid;
|
|
261
|
+
gap: 0.875rem;
|
|
262
|
+
padding-top: 0.875rem;
|
|
263
|
+
border-top: 2px solid var(--ink);
|
|
264
|
+
}
|
|
265
|
+
.ballot-office-name {
|
|
266
|
+
margin: 0;
|
|
267
|
+
font-size: var(--text-lg);
|
|
268
|
+
font-weight: 700;
|
|
269
|
+
line-height: 1.2;
|
|
270
|
+
}
|
|
271
|
+
.ballot-office-name small {
|
|
272
|
+
display: block;
|
|
273
|
+
margin-top: 0.125rem;
|
|
274
|
+
color: var(--muted);
|
|
275
|
+
font-family: var(--font);
|
|
276
|
+
font-size: var(--text-sm);
|
|
277
|
+
font-weight: 400;
|
|
278
|
+
letter-spacing: 0;
|
|
279
|
+
}
|
|
280
|
+
.ballot-cands {
|
|
281
|
+
display: grid;
|
|
282
|
+
grid-template-columns: repeat(auto-fill, minmax(min(100%, 18.75rem), 1fr));
|
|
283
|
+
gap: 0.75rem;
|
|
284
|
+
margin: 0;
|
|
285
|
+
padding: 0;
|
|
286
|
+
list-style: none;
|
|
287
|
+
}
|
|
288
|
+
.ballot-cand {
|
|
289
|
+
display: grid;
|
|
290
|
+
grid-template-columns: 3.25rem minmax(0, 1fr);
|
|
291
|
+
gap: 0.75rem 0.875rem;
|
|
292
|
+
align-items: center;
|
|
293
|
+
padding: 0.75rem 0.875rem;
|
|
294
|
+
border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
|
|
295
|
+
border-radius: var(--radius);
|
|
296
|
+
background: color-mix(in srgb, var(--page) 70%, transparent);
|
|
297
|
+
}
|
|
298
|
+
:global(.bg-band-contrast) .ballot-cand {
|
|
299
|
+
background: color-mix(in srgb, var(--ink) 7%, transparent);
|
|
300
|
+
}
|
|
301
|
+
.ballot-photo {
|
|
302
|
+
display: block;
|
|
303
|
+
width: 100%;
|
|
304
|
+
aspect-ratio: 1;
|
|
305
|
+
object-fit: cover;
|
|
306
|
+
border-radius: calc(var(--radius) * 0.8);
|
|
307
|
+
}
|
|
308
|
+
.ballot-initials {
|
|
309
|
+
display: grid;
|
|
310
|
+
place-items: center;
|
|
311
|
+
background: color-mix(in srgb, var(--ink) 8%, transparent);
|
|
312
|
+
color: var(--muted);
|
|
313
|
+
font-family: var(--font-display);
|
|
314
|
+
font-size: var(--text-lg);
|
|
315
|
+
font-weight: 700;
|
|
316
|
+
}
|
|
317
|
+
.ballot-who > * {
|
|
318
|
+
margin: 0;
|
|
319
|
+
}
|
|
320
|
+
.ballot-name {
|
|
321
|
+
font-family: var(--font);
|
|
322
|
+
font-size: var(--text);
|
|
323
|
+
font-weight: 700;
|
|
324
|
+
letter-spacing: 0;
|
|
325
|
+
line-height: 1.3;
|
|
326
|
+
}
|
|
327
|
+
.ballot-place {
|
|
328
|
+
color: var(--muted);
|
|
329
|
+
font-size: var(--text-sm);
|
|
330
|
+
}
|
|
331
|
+
.ballot-who .ballot-endorsed {
|
|
332
|
+
margin-top: 0.375rem;
|
|
333
|
+
}
|
|
334
|
+
.ballot-who .ballot-issues {
|
|
335
|
+
display: flex;
|
|
336
|
+
flex-wrap: wrap;
|
|
337
|
+
gap: 0.375rem;
|
|
338
|
+
margin-top: 0.375rem;
|
|
339
|
+
padding: 0;
|
|
340
|
+
list-style: none;
|
|
341
|
+
}
|
|
342
|
+
.ballot-issues li {
|
|
343
|
+
padding: 0.0625rem 0.5rem;
|
|
344
|
+
border-radius: var(--pill);
|
|
345
|
+
background: color-mix(in srgb, var(--link) 12%, transparent);
|
|
346
|
+
color: var(--ink);
|
|
347
|
+
font-size: var(--text-xs);
|
|
348
|
+
font-weight: 700;
|
|
349
|
+
}
|
|
350
|
+
.ballot-acts {
|
|
351
|
+
grid-column: 1 / -1;
|
|
352
|
+
display: flex;
|
|
353
|
+
flex-wrap: wrap;
|
|
354
|
+
gap: 0.5rem;
|
|
355
|
+
margin: 0;
|
|
356
|
+
}
|
|
357
|
+
.ballot-acts .button {
|
|
358
|
+
padding: 0.4375rem 1rem;
|
|
359
|
+
font-size: var(--text-sm);
|
|
360
|
+
}
|
|
361
|
+
.ballot-showing {
|
|
362
|
+
display: flex;
|
|
363
|
+
flex-wrap: wrap;
|
|
364
|
+
align-items: baseline;
|
|
365
|
+
gap: 0.25rem 0.75rem;
|
|
366
|
+
margin: 1.125rem 0 0;
|
|
367
|
+
color: var(--muted);
|
|
368
|
+
font-size: var(--text-sm);
|
|
369
|
+
}
|
|
370
|
+
.ballot-reset {
|
|
371
|
+
padding: 0;
|
|
372
|
+
border: 0;
|
|
373
|
+
background: none;
|
|
374
|
+
color: var(--link);
|
|
375
|
+
font: inherit;
|
|
376
|
+
font-weight: 600;
|
|
377
|
+
text-decoration: underline;
|
|
378
|
+
cursor: pointer;
|
|
379
|
+
}
|
|
380
|
+
@media (min-width: 40rem) {
|
|
381
|
+
.ballot-cand {
|
|
382
|
+
grid-template-columns: 4rem minmax(0, 1fr);
|
|
383
|
+
}
|
|
384
|
+
.ballot-acts {
|
|
385
|
+
grid-column: 2;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
@media (min-width: 56rem) {
|
|
389
|
+
.ballot-office {
|
|
390
|
+
grid-template-columns: 13.75rem minmax(0, 1fr);
|
|
391
|
+
gap: 1.375rem;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
</style>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// A CandidateRoster's rows as its layouts draw them: each approved candidate
|
|
2
|
+
// with the office, its level (the label BackGold sends: Federal, State,
|
|
3
|
+
// County, …), the place, the issues, the headshot, and links to their site
|
|
4
|
+
// and, when the record has one, their donate address (followed as given; a
|
|
5
|
+
// donation never happens here). A row carries `endorsed` when the party has
|
|
6
|
+
// endorsed the candidate: the bake writes the flag from the record's
|
|
7
|
+
// endorsement once one exists, and every layout draws an "Endorsed" chip on a
|
|
8
|
+
// row that has it and nothing on a row that does not.
|
|
9
|
+
|
|
10
|
+
import type { Section } from '@backgold/content'
|
|
11
|
+
import { safeSrc } from '@backgold/astro/server'
|
|
12
|
+
import { linkOf, rows, type Link } from '../../../lib/section'
|
|
13
|
+
import { text } from '../../../lib/format'
|
|
14
|
+
|
|
15
|
+
export interface Candidate {
|
|
16
|
+
name: string
|
|
17
|
+
office: string | null
|
|
18
|
+
/** The office's level as a voter reads it ("State", "County"), or null. */
|
|
19
|
+
level: string | null
|
|
20
|
+
region: string | null
|
|
21
|
+
status: string | null
|
|
22
|
+
issues: string[]
|
|
23
|
+
photo: string | null
|
|
24
|
+
site: Link | null
|
|
25
|
+
donate: Link | null
|
|
26
|
+
/** The party endorses this candidate; false unless the row says so. */
|
|
27
|
+
endorsed: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function candidatesOf(section: Section): Candidate[] {
|
|
31
|
+
return rows(section).flatMap((row) => {
|
|
32
|
+
const name = text(row.name)
|
|
33
|
+
if (!name) return []
|
|
34
|
+
const issues = Array.isArray(row.issues) ? row.issues.filter((i): i is string => typeof i === 'string' && i.trim() !== '') : []
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
name,
|
|
38
|
+
office: text(row.office),
|
|
39
|
+
level: text(row.level),
|
|
40
|
+
region: text(row.region),
|
|
41
|
+
status: text(row.status),
|
|
42
|
+
issues,
|
|
43
|
+
photo: safeSrc(row.image_url),
|
|
44
|
+
site: linkOf('Website', row.web_url),
|
|
45
|
+
donate: linkOf('Donate', row.donate_url),
|
|
46
|
+
endorsed: row.endorsed === true,
|
|
47
|
+
},
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The levels BackGold sends, in ballot order; any other level comes after them. */
|
|
53
|
+
export const BALLOT_ORDER = ['Federal', 'State', 'County', 'Local', 'Municipal', 'Judicial', 'School board', 'Other']
|
|
54
|
+
|
|
55
|
+
/** A level's place in BALLOT_ORDER (an unknown or missing level last). */
|
|
56
|
+
export function levelRank(level: string | null): number {
|
|
57
|
+
const i = level ? BALLOT_ORDER.indexOf(level) : -1
|
|
58
|
+
return i < 0 ? BALLOT_ORDER.length : i
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** "RA" for a headshot that has not been uploaded. */
|
|
62
|
+
export function initials(name: string): string {
|
|
63
|
+
return name
|
|
64
|
+
.split(/\s+/)
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.slice(0, 2)
|
|
67
|
+
.map((part) => part[0]!.toUpperCase())
|
|
68
|
+
.join('')
|
|
69
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
// CandidateRoster · Compact (board A1, "Candidate roster · Compact"; A12
|
|
3
|
+
// shows it beside Cards and Ballot): the section head (the kicker, the
|
|
4
|
+
// heading and its "All N candidates" link), then one row of four candidates
|
|
5
|
+
// from the top of the ballot (by level, BackGold's order within a level),
|
|
6
|
+
// each with a square headshot (their initials on the brand's gradient when
|
|
7
|
+
// there is none), the name, the office and the place as a chip, with an
|
|
8
|
+
// "Endorsed" chip under the office when the candidate is endorsed. The name
|
|
9
|
+
// links to the candidate's own site when the record has one. Two across on
|
|
10
|
+
// a phone. With no candidates it draws nothing.
|
|
11
|
+
import type { ComponentProps } from 'astro/types'
|
|
12
|
+
import type Default from './index.astro'
|
|
13
|
+
import Band from '../Band.astro'
|
|
14
|
+
import SectionHead from '../SectionHead.astro'
|
|
15
|
+
import { links } from '../../../lib/section'
|
|
16
|
+
import { text } from '../../../lib/format'
|
|
17
|
+
import { candidatesOf, initials, levelRank } from './candidates'
|
|
18
|
+
|
|
19
|
+
type Props = ComponentProps<typeof Default>
|
|
20
|
+
|
|
21
|
+
/** A1 draws one row; the section's link goes to the rest. */
|
|
22
|
+
const SHOWN = 4
|
|
23
|
+
|
|
24
|
+
const { section } = Astro.props
|
|
25
|
+
const candidates = candidatesOf(section)
|
|
26
|
+
.map((c, i) => ({ c, i }))
|
|
27
|
+
.sort((a, b) => levelRank(a.c.level) - levelRank(b.c.level) || a.i - b.i)
|
|
28
|
+
.slice(0, SHOWN)
|
|
29
|
+
.map(({ c }) => c)
|
|
30
|
+
---
|
|
31
|
+
{candidates.length > 0 && (
|
|
32
|
+
<Band section={section} class="roster roster-compact">
|
|
33
|
+
<SectionHead kicker={text(section.copy.kicker)} heading={text(section.copy.heading)} more={links(section)} />
|
|
34
|
+
<ul class="compact" role="list">
|
|
35
|
+
{candidates.map((c) => (
|
|
36
|
+
<li class="compact-item">
|
|
37
|
+
{c.photo ? (
|
|
38
|
+
<img class="compact-photo" src={c.photo} alt="" loading="lazy" decoding="async" />
|
|
39
|
+
) : (
|
|
40
|
+
<span class="compact-photo compact-initials" aria-hidden="true">{initials(c.name)}</span>
|
|
41
|
+
)}
|
|
42
|
+
<h3 class="compact-name">{c.site ? <a href={c.site.href} rel={c.site.rel}>{c.name}</a> : c.name}</h3>
|
|
43
|
+
{c.office && <p class="compact-office">{c.office}</p>}
|
|
44
|
+
{c.endorsed && <p class="compact-endorsed"><span class="chip chip-accent">Endorsed</span></p>}
|
|
45
|
+
{c.region && <p class="compact-region"><span class="chip chip-wash">{c.region}</span></p>}
|
|
46
|
+
</li>
|
|
47
|
+
))}
|
|
48
|
+
</ul>
|
|
49
|
+
</Band>
|
|
50
|
+
)}
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.compact {
|
|
54
|
+
display: grid;
|
|
55
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
56
|
+
gap: 1.5rem 0.875rem;
|
|
57
|
+
margin: 0;
|
|
58
|
+
padding: 0;
|
|
59
|
+
list-style: none;
|
|
60
|
+
}
|
|
61
|
+
.compact-item {
|
|
62
|
+
min-width: 0;
|
|
63
|
+
}
|
|
64
|
+
.compact-item > * {
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
.compact-photo {
|
|
68
|
+
display: block;
|
|
69
|
+
width: 100%;
|
|
70
|
+
aspect-ratio: 1;
|
|
71
|
+
object-fit: cover;
|
|
72
|
+
border-radius: 1rem;
|
|
73
|
+
}
|
|
74
|
+
.compact-initials {
|
|
75
|
+
display: grid;
|
|
76
|
+
place-items: center;
|
|
77
|
+
background: linear-gradient(150deg, var(--bg-brand-primary), var(--bg-brand-accent));
|
|
78
|
+
color: var(--band-photo-ink);
|
|
79
|
+
font-family: var(--font-display);
|
|
80
|
+
font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
}
|
|
83
|
+
.compact-item .compact-name {
|
|
84
|
+
margin-top: 0.75rem;
|
|
85
|
+
font-size: 1.125rem;
|
|
86
|
+
font-weight: 600;
|
|
87
|
+
line-height: 1.25;
|
|
88
|
+
}
|
|
89
|
+
.compact-name a {
|
|
90
|
+
color: var(--ink);
|
|
91
|
+
text-decoration: none;
|
|
92
|
+
}
|
|
93
|
+
.compact-name a:hover {
|
|
94
|
+
text-decoration: underline;
|
|
95
|
+
}
|
|
96
|
+
.compact-item .compact-office {
|
|
97
|
+
color: var(--muted);
|
|
98
|
+
font-size: var(--text-sm);
|
|
99
|
+
}
|
|
100
|
+
.compact-item .compact-endorsed,
|
|
101
|
+
.compact-item .compact-region {
|
|
102
|
+
margin-top: 0.5rem;
|
|
103
|
+
}
|
|
104
|
+
/* A1 draws the place as a chip as wide as the card. */
|
|
105
|
+
.compact-region .chip {
|
|
106
|
+
display: flex;
|
|
107
|
+
white-space: normal;
|
|
108
|
+
}
|
|
109
|
+
@media (min-width: 48rem) {
|
|
110
|
+
.compact {
|
|
111
|
+
grid-template-columns: repeat(4, minmax(0, 1fr));
|
|
112
|
+
gap: 1.125rem;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
// CandidateRoster: the candidates the organization backs, each with the
|
|
3
|
+
// office, the place, the issues, and links to their site and their donate
|
|
4
|
+
// page in BackGold (follow it as given; never take a donation here). An
|
|
5
|
+
// endorsed candidate carries an "Endorsed" chip beside the status badge (alone
|
|
6
|
+
// when there is no status).
|
|
7
|
+
import type { Section } from '@backgold/content'
|
|
8
|
+
import Band from '../Band.astro'
|
|
9
|
+
import { text } from '../../../lib/format'
|
|
10
|
+
import { candidatesOf } from './candidates'
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
section: Section
|
|
14
|
+
variant?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { section } = Astro.props
|
|
18
|
+
const heading = text(section.copy.heading)
|
|
19
|
+
const candidates = candidatesOf(section).map((c) => ({ ...c, office: [c.office, c.region].filter(Boolean).join(' · ') }))
|
|
20
|
+
---
|
|
21
|
+
<Band section={section} class="roster">
|
|
22
|
+
{heading && <h2>{heading}</h2>}
|
|
23
|
+
{candidates.length > 0 ? (
|
|
24
|
+
<ul class="grid grid-3" role="list">
|
|
25
|
+
{candidates.map((c) => (
|
|
26
|
+
<li class="tile">
|
|
27
|
+
{(c.status || c.endorsed) && (
|
|
28
|
+
<p class="roster-tags">
|
|
29
|
+
{c.status && <span class="badge">{c.status}</span>}
|
|
30
|
+
{c.endorsed && <span class="chip chip-accent">Endorsed</span>}
|
|
31
|
+
</p>
|
|
32
|
+
)}
|
|
33
|
+
<h3>{c.name}</h3>
|
|
34
|
+
{c.office && <p class="muted">{c.office}</p>}
|
|
35
|
+
{c.issues.length > 0 && <p class="fine">{c.issues.join(' · ')}</p>}
|
|
36
|
+
{(c.site || c.donate) && (
|
|
37
|
+
<p class="tile-links">
|
|
38
|
+
{c.site && <a href={c.site.href} rel={c.site.rel}>{c.site.label}<span class="visually-hidden">: {c.name}</span></a>}
|
|
39
|
+
{c.donate && <a href={c.donate.href} rel={c.donate.rel}>{c.donate.label}<span class="visually-hidden"> to {c.name}</span></a>}
|
|
40
|
+
</p>
|
|
41
|
+
)}
|
|
42
|
+
</li>
|
|
43
|
+
))}
|
|
44
|
+
</ul>
|
|
45
|
+
) : (
|
|
46
|
+
<p class="empty">No candidates listed yet.</p>
|
|
47
|
+
)}
|
|
48
|
+
</Band>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.roster-tags {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-wrap: wrap;
|
|
54
|
+
align-items: center;
|
|
55
|
+
gap: 0.5rem;
|
|
56
|
+
}
|
|
57
|
+
</style>
|