@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,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Faq · Accordion, the default (board 07, A): the kicker and heading, the
|
|
3
|
+
// line of copy, then every question in one reading column, each a <details>
|
|
4
|
+
// the visitor opens (the first open when `firstOpen` is on), and under them
|
|
5
|
+
// the contact heading with its button in a slim row when the section has
|
|
6
|
+
// the contact link. Every Faq layout writes the questions and answers as
|
|
7
|
+
// FAQPage JSON-LD for search. With no questions and no heading it draws
|
|
8
|
+
// nothing.
|
|
9
|
+
import type { Section } from '@backgold/content'
|
|
10
|
+
import Band from '../Band.astro'
|
|
11
|
+
import SectionHead from '../SectionHead.astro'
|
|
12
|
+
import Prose from '../../Prose.astro'
|
|
13
|
+
import Contact from './Contact.astro'
|
|
14
|
+
import Questions from './Questions.astro'
|
|
15
|
+
import { contactOf, faqSchema, questionsOf } from './faq'
|
|
16
|
+
import { text } from '../../../lib/format'
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
section: Section
|
|
20
|
+
variant?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { section } = Astro.props
|
|
24
|
+
const kicker = text(section.copy.kicker)
|
|
25
|
+
const heading = text(section.copy.heading)
|
|
26
|
+
const questions = questionsOf(section)
|
|
27
|
+
const schema = faqSchema(questions)
|
|
28
|
+
---
|
|
29
|
+
{(questions.length > 0 || heading) && (
|
|
30
|
+
<Band section={section} class="faq faq-accordion">
|
|
31
|
+
<div class="faq-column">
|
|
32
|
+
<SectionHead kicker={kicker} heading={heading} more={[]} />
|
|
33
|
+
<Prose value={section.copy.body} class="lede" />
|
|
34
|
+
{questions.length > 0 && <Questions questions={questions} firstOpen={section.options?.firstOpen === true} />}
|
|
35
|
+
<Contact contact={contactOf(section)} look="row" />
|
|
36
|
+
</div>
|
|
37
|
+
{schema && <script is:inline type="application/ld+json" set:html={schema} />}
|
|
38
|
+
</Band>
|
|
39
|
+
)}
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.faq-column {
|
|
43
|
+
max-width: calc(var(--measure) + 4rem);
|
|
44
|
+
margin-inline: auto;
|
|
45
|
+
}
|
|
46
|
+
.faq-column > :global(.lede) {
|
|
47
|
+
margin: -0.5rem 0 1.75rem;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Faq · Topics (board 07, B): the kicker, heading and line of copy, then the
|
|
3
|
+
// topics at the left and the accordion at the right. The topics are buttons,
|
|
4
|
+
// "All" first and then each row's `topic` in the order it first appears (the
|
|
5
|
+
// questions with none last, under "Other"); picking one shows only its
|
|
6
|
+
// questions, and its heading is then left to screen readers. The buttons are
|
|
7
|
+
// drawn hidden and shown by the section's script, so with scripts off every
|
|
8
|
+
// question shows in one column, grouped under its topic's heading. Under
|
|
9
|
+
// 48rem the topics are a wrapped row of chips above the questions. The
|
|
10
|
+
// contact row closes it, and
|
|
11
|
+
// the FAQPage JSON-LD goes with it as on every Faq layout. When no question
|
|
12
|
+
// has a topic it is the Accordion; with no questions and no heading it draws
|
|
13
|
+
// nothing.
|
|
14
|
+
import type { ComponentProps } from 'astro/types'
|
|
15
|
+
import Band from '../Band.astro'
|
|
16
|
+
import SectionHead from '../SectionHead.astro'
|
|
17
|
+
import Prose from '../../Prose.astro'
|
|
18
|
+
import Accordion from './index.astro'
|
|
19
|
+
import Contact from './Contact.astro'
|
|
20
|
+
import Questions from './Questions.astro'
|
|
21
|
+
import { contactOf, faqSchema, questionsOf, topicsOf } from './faq'
|
|
22
|
+
import { text } from '../../../lib/format'
|
|
23
|
+
|
|
24
|
+
type Props = ComponentProps<typeof Accordion>
|
|
25
|
+
|
|
26
|
+
const { section } = Astro.props
|
|
27
|
+
const kicker = text(section.copy.kicker)
|
|
28
|
+
const heading = text(section.copy.heading)
|
|
29
|
+
const questions = questionsOf(section)
|
|
30
|
+
const topics = topicsOf(questions)
|
|
31
|
+
const schema = faqSchema(questions)
|
|
32
|
+
const firstOpen = section.options?.firstOpen === true
|
|
33
|
+
const groupsId = `${section.id}-faq-topics`.replace(/[^A-Za-z0-9_-]/g, '-')
|
|
34
|
+
---
|
|
35
|
+
{topics.length === 0 ? (
|
|
36
|
+
<Accordion {...Astro.props} />
|
|
37
|
+
) : (
|
|
38
|
+
<Band section={section} class="faq faq-topics">
|
|
39
|
+
<div class="faq-intro">
|
|
40
|
+
<SectionHead kicker={kicker} heading={heading} more={[]} />
|
|
41
|
+
<Prose value={section.copy.body} class="lede" />
|
|
42
|
+
</div>
|
|
43
|
+
<div class="faq-split" data-faq-topics>
|
|
44
|
+
<div class="faq-nav" role="group" aria-label={heading ? `${heading}: topics` : 'Topics'} data-faq-nav hidden>
|
|
45
|
+
<button type="button" aria-pressed="true" aria-controls={groupsId} data-faq-topic="">All</button>
|
|
46
|
+
{topics.map((t) => (
|
|
47
|
+
<button type="button" aria-pressed="false" aria-controls={groupsId} data-faq-topic={t.key}>{t.label}</button>
|
|
48
|
+
))}
|
|
49
|
+
</div>
|
|
50
|
+
<div class="faq-groups" id={groupsId}>
|
|
51
|
+
{topics.map((t, i) => (
|
|
52
|
+
<div class="faq-group" data-faq-group={t.key}>
|
|
53
|
+
<h3 class="faq-group-name">{t.label}</h3>
|
|
54
|
+
<Questions questions={t.questions} firstOpen={firstOpen && i === 0} />
|
|
55
|
+
</div>
|
|
56
|
+
))}
|
|
57
|
+
<Contact contact={contactOf(section)} look="row" />
|
|
58
|
+
</div>
|
|
59
|
+
<script is:inline>
|
|
60
|
+
(function (root) {
|
|
61
|
+
if (!root) return
|
|
62
|
+
var nav = root.querySelector('[data-faq-nav]')
|
|
63
|
+
var buttons = nav.querySelectorAll('[data-faq-topic]')
|
|
64
|
+
var groups = root.querySelectorAll('[data-faq-group]')
|
|
65
|
+
var pick = function (topic) {
|
|
66
|
+
for (var b = 0; b < buttons.length; b++) buttons[b].setAttribute('aria-pressed', buttons[b].getAttribute('data-faq-topic') === topic ? 'true' : 'false')
|
|
67
|
+
for (var g = 0; g < groups.length; g++) groups[g].hidden = topic !== '' && groups[g].getAttribute('data-faq-group') !== topic
|
|
68
|
+
if (topic) root.setAttribute('data-faq-picked', '')
|
|
69
|
+
else root.removeAttribute('data-faq-picked')
|
|
70
|
+
}
|
|
71
|
+
for (var b = 0; b < buttons.length; b++) {
|
|
72
|
+
buttons[b].addEventListener('click', function (event) {
|
|
73
|
+
pick(event.currentTarget.getAttribute('data-faq-topic'))
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
nav.hidden = false
|
|
77
|
+
root.setAttribute('data-faq-live', '')
|
|
78
|
+
})(document.currentScript.closest('[data-faq-topics]'))
|
|
79
|
+
</script>
|
|
80
|
+
</div>
|
|
81
|
+
{schema && <script is:inline type="application/ld+json" set:html={schema} />}
|
|
82
|
+
</Band>
|
|
83
|
+
)}
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.faq-intro > :global(.lede) {
|
|
87
|
+
margin: -0.5rem 0 1.75rem;
|
|
88
|
+
}
|
|
89
|
+
.faq-nav[hidden],
|
|
90
|
+
.faq-group[hidden] {
|
|
91
|
+
display: none;
|
|
92
|
+
}
|
|
93
|
+
.faq-nav {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-wrap: wrap;
|
|
96
|
+
gap: 0.5rem;
|
|
97
|
+
margin-bottom: 1.5rem;
|
|
98
|
+
}
|
|
99
|
+
.faq-nav button {
|
|
100
|
+
min-height: 2.75rem;
|
|
101
|
+
padding: 0.375rem 1rem;
|
|
102
|
+
border: 1.5px solid color-mix(in srgb, var(--ink) 25%, transparent);
|
|
103
|
+
border-radius: var(--pill);
|
|
104
|
+
background: transparent;
|
|
105
|
+
color: var(--ink);
|
|
106
|
+
font: inherit;
|
|
107
|
+
font-size: var(--text-sm);
|
|
108
|
+
font-weight: 600;
|
|
109
|
+
text-align: left;
|
|
110
|
+
cursor: pointer;
|
|
111
|
+
}
|
|
112
|
+
.faq-nav button:hover {
|
|
113
|
+
border-color: var(--ink);
|
|
114
|
+
}
|
|
115
|
+
.faq-nav button[aria-pressed='true'] {
|
|
116
|
+
border-color: var(--button-2);
|
|
117
|
+
background: var(--button-2);
|
|
118
|
+
color: var(--button-2-ink);
|
|
119
|
+
}
|
|
120
|
+
.faq-groups {
|
|
121
|
+
display: grid;
|
|
122
|
+
gap: 2rem;
|
|
123
|
+
max-width: calc(var(--measure) + 4rem);
|
|
124
|
+
min-width: 0;
|
|
125
|
+
}
|
|
126
|
+
.faq-group-name {
|
|
127
|
+
margin: 0 0 0.875rem;
|
|
128
|
+
font-size: var(--text-lg);
|
|
129
|
+
font-weight: 700;
|
|
130
|
+
line-height: 1.25;
|
|
131
|
+
}
|
|
132
|
+
/* One topic picked: its button already names it, so its heading is left to screen readers. */
|
|
133
|
+
[data-faq-picked] .faq-group-name {
|
|
134
|
+
position: absolute;
|
|
135
|
+
width: 1px;
|
|
136
|
+
height: 1px;
|
|
137
|
+
margin: -1px;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
clip: rect(0 0 0 0);
|
|
140
|
+
white-space: nowrap;
|
|
141
|
+
}
|
|
142
|
+
.faq-groups > :global(.faq-contact) {
|
|
143
|
+
margin-top: 0;
|
|
144
|
+
}
|
|
145
|
+
@media (min-width: 48rem) {
|
|
146
|
+
[data-faq-live].faq-split {
|
|
147
|
+
display: grid;
|
|
148
|
+
grid-template-columns: 14rem minmax(0, 1fr);
|
|
149
|
+
gap: 2.5rem;
|
|
150
|
+
align-items: start;
|
|
151
|
+
}
|
|
152
|
+
[data-faq-live] .faq-groups {
|
|
153
|
+
max-width: none;
|
|
154
|
+
}
|
|
155
|
+
.faq-nav {
|
|
156
|
+
position: sticky;
|
|
157
|
+
top: 1.5rem;
|
|
158
|
+
display: grid;
|
|
159
|
+
gap: 0.375rem;
|
|
160
|
+
margin: 0;
|
|
161
|
+
}
|
|
162
|
+
.faq-nav button {
|
|
163
|
+
padding: 0.625rem 1rem;
|
|
164
|
+
border: 1px solid var(--line);
|
|
165
|
+
border-radius: var(--radius);
|
|
166
|
+
background: var(--surface);
|
|
167
|
+
font-size: var(--text);
|
|
168
|
+
}
|
|
169
|
+
.faq-nav button:hover {
|
|
170
|
+
border-color: var(--line-strong);
|
|
171
|
+
}
|
|
172
|
+
.faq-nav button[aria-pressed='true'] {
|
|
173
|
+
border-color: var(--button-2);
|
|
174
|
+
background: var(--button-2);
|
|
175
|
+
color: var(--button-2-ink);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
</style>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
// The foot every Financials layout closes with: `sourceNote` as a fine line
|
|
3
|
+
// saying where the figures come from, then the report link (`reportLabel` to
|
|
4
|
+
// `reportHref`, the filing or annual report) as the section's one button.
|
|
5
|
+
// No button without the link; nothing drawn with neither.
|
|
6
|
+
import type { Section } from '@backgold/content'
|
|
7
|
+
import { links } from '../../../lib/section'
|
|
8
|
+
import { text } from '../../../lib/format'
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
section: Section
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { section } = Astro.props
|
|
15
|
+
const sourceNote = text(section.copy.sourceNote)
|
|
16
|
+
const [report] = links(section)
|
|
17
|
+
---
|
|
18
|
+
{(sourceNote || report) && (
|
|
19
|
+
<div class="financials-foot">
|
|
20
|
+
{sourceNote && <p class="fine financials-source">{sourceNote}</p>}
|
|
21
|
+
{report && <a class="button" href={report.href} rel={report.rel}>{report.label}</a>}
|
|
22
|
+
</div>
|
|
23
|
+
)}
|
|
24
|
+
|
|
25
|
+
<style>
|
|
26
|
+
.financials-foot {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-wrap: wrap;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
gap: 1rem 1.5rem;
|
|
32
|
+
margin-top: clamp(1.25rem, 1rem + 1vw, 1.75rem);
|
|
33
|
+
}
|
|
34
|
+
.financials-source {
|
|
35
|
+
margin: 0;
|
|
36
|
+
max-width: 48ch;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
// The head every Financials layout opens with: the kicker over the heading,
|
|
3
|
+
// the `year` the figures are for as a chip beside the heading (under it when
|
|
4
|
+
// the line runs out), then the body. Draws nothing it has no words for.
|
|
5
|
+
import type { Section } from '@backgold/content'
|
|
6
|
+
import Prose from '../../Prose.astro'
|
|
7
|
+
import { text } from '../../../lib/format'
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
section: Section
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { section } = Astro.props
|
|
14
|
+
const kicker = text(section.copy.kicker)
|
|
15
|
+
const heading = text(section.copy.heading)
|
|
16
|
+
const year = text(section.copy.year)
|
|
17
|
+
---
|
|
18
|
+
{(kicker || heading || year) && (
|
|
19
|
+
<div class="section-head">
|
|
20
|
+
<div>
|
|
21
|
+
{kicker && <p class="kicker">{kicker}</p>}
|
|
22
|
+
{(heading || year) && (
|
|
23
|
+
<div class="financials-title">
|
|
24
|
+
{heading && <h2>{heading}</h2>}
|
|
25
|
+
{year && <span class="chip chip-accent financials-year">{year}</span>}
|
|
26
|
+
</div>
|
|
27
|
+
)}
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
)}
|
|
31
|
+
<Prose value={section.copy.body} class="lede financials-body" />
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
.financials-title {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-wrap: wrap;
|
|
37
|
+
align-items: baseline;
|
|
38
|
+
gap: 0.5rem 0.875rem;
|
|
39
|
+
}
|
|
40
|
+
.financials-year {
|
|
41
|
+
font-size: var(--text-sm);
|
|
42
|
+
font-variant-numeric: tabular-nums;
|
|
43
|
+
}
|
|
44
|
+
.financials-body {
|
|
45
|
+
margin-bottom: clamp(1.5rem, 1rem + 1.5vw, 2.25rem);
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
// Financials, 'donut' layout (REPORT §2 G15, "where the money goes"): the
|
|
3
|
+
// head (the kicker, the heading with the year as a chip, the body), then a
|
|
4
|
+
// donut beside its legend, then `sourceNote` as a fine line and the report
|
|
5
|
+
// link as the one button. On a phone the legend follows under the donut.
|
|
6
|
+
//
|
|
7
|
+
// The donut is a CSS conic-gradient drawn from the shares in row order: a
|
|
8
|
+
// figure's slice runs from the sum of the shares drawn before it to that sum
|
|
9
|
+
// plus its own share, each slice in the next colour of the sequence below,
|
|
10
|
+
// with a hairline of the band's ground after it so neighbours read apart.
|
|
11
|
+
// The shares are drawn as the organization published them, never scaled to
|
|
12
|
+
// fill the ring: when they come to less than 100 the rest of the ring is
|
|
13
|
+
// left open in the track colour, and when they come to more the ring draws
|
|
14
|
+
// what fits and stops, with nothing said about it. The hole is the band's
|
|
15
|
+
// ground. The donut is a picture (aria-hidden); the legend carries every
|
|
16
|
+
// number: a swatch in the slice's colour, the category, the share ("62%"),
|
|
17
|
+
// the amount and the note. A figure with no share, or whose slice did not
|
|
18
|
+
// fit, has no swatch. Nothing is drawn with neither a heading nor a figure.
|
|
19
|
+
import type { ComponentProps } from 'astro/types'
|
|
20
|
+
import type Default from './index.astro'
|
|
21
|
+
import Band from '../Band.astro'
|
|
22
|
+
import { text } from '../../../lib/format'
|
|
23
|
+
import Head from './Head.astro'
|
|
24
|
+
import Foot from './Foot.astro'
|
|
25
|
+
import { rowsOf, shareLabel } from './financials'
|
|
26
|
+
|
|
27
|
+
type Props = ComponentProps<typeof Default>
|
|
28
|
+
|
|
29
|
+
/** The colours in the sequence (--financials-1 … --financials-8 below), reused in order past the eighth slice. */
|
|
30
|
+
const COLOURS = 8
|
|
31
|
+
/** The hairline after each slice, in points of the ring, taken from slices wide enough to spare it. */
|
|
32
|
+
const GAP = 0.4
|
|
33
|
+
|
|
34
|
+
const { section } = Astro.props
|
|
35
|
+
const heading = text(section.copy.heading)
|
|
36
|
+
const figures = rowsOf(section)
|
|
37
|
+
|
|
38
|
+
const stop = (at: number) => `${Number(at.toFixed(3))}%`
|
|
39
|
+
let drawn = 0
|
|
40
|
+
let colour = 0
|
|
41
|
+
const stops: string[] = []
|
|
42
|
+
const legend = figures.map((figure) => {
|
|
43
|
+
if (figure.share === null || figure.share <= 0 || drawn >= 100) return { figure, swatch: null }
|
|
44
|
+
const from = drawn
|
|
45
|
+
const to = Math.min(drawn + figure.share, 100)
|
|
46
|
+
const fill = `var(--financials-${(colour % COLOURS) + 1})`
|
|
47
|
+
const gap = to - from > GAP * 3 ? GAP : 0
|
|
48
|
+
stops.push(`${fill} ${stop(from)} ${stop(to - gap)}`)
|
|
49
|
+
if (gap > 0) stops.push(`var(--bg-band-background) ${stop(to - gap)} ${stop(to)}`)
|
|
50
|
+
drawn = to
|
|
51
|
+
colour += 1
|
|
52
|
+
return { figure, swatch: fill }
|
|
53
|
+
})
|
|
54
|
+
if (stops.length > 0 && drawn < 100) stops.push(`var(--financials-open) ${stop(drawn)} 100%`)
|
|
55
|
+
const ring = stops.length > 0 ? `--ring: conic-gradient(${stops.join(', ')})` : null
|
|
56
|
+
---
|
|
57
|
+
{(heading || figures.length > 0) && (
|
|
58
|
+
<Band section={section} class="financials financials-donut">
|
|
59
|
+
<Head section={section} />
|
|
60
|
+
{figures.length > 0 && (
|
|
61
|
+
<div class:list={['donut-figures', ring && 'donut-figures-ring']}>
|
|
62
|
+
{ring && <div class="donut" style={ring} aria-hidden="true"></div>}
|
|
63
|
+
<ul class="legend" role="list">
|
|
64
|
+
{legend.map(({ figure, swatch }) => (
|
|
65
|
+
<li class="legend-item">
|
|
66
|
+
<span class="legend-swatch" style={swatch ? `background: ${swatch}` : undefined} aria-hidden="true"></span>
|
|
67
|
+
<div class="legend-words">
|
|
68
|
+
{figure.category && <p class="legend-category">{figure.category}</p>}
|
|
69
|
+
{figure.note && <p class="legend-note">{figure.note}</p>}
|
|
70
|
+
</div>
|
|
71
|
+
{(figure.share !== null || figure.amount) && (
|
|
72
|
+
<p class="legend-numbers">
|
|
73
|
+
{figure.share !== null && <strong class="legend-share">{shareLabel(figure.share)}</strong>}
|
|
74
|
+
{figure.amount && <span class="legend-amount">{figure.amount}</span>}
|
|
75
|
+
</p>
|
|
76
|
+
)}
|
|
77
|
+
</li>
|
|
78
|
+
))}
|
|
79
|
+
</ul>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
<Foot section={section} />
|
|
83
|
+
</Band>
|
|
84
|
+
)}
|
|
85
|
+
|
|
86
|
+
<style>
|
|
87
|
+
/*
|
|
88
|
+
The slice colours, from the band's own. Each is the button colour or the
|
|
89
|
+
accent at its own depth: full, or mixed toward the ink (deeper in light
|
|
90
|
+
mode, paler in dark) or toward the surface (paler in light mode, deeper in
|
|
91
|
+
dark), and neighbours sit far apart in depth, so the slices read apart
|
|
92
|
+
even where the brand's accent and button are the same colour. No mix
|
|
93
|
+
keeps less than a third of its colour, so none fades into a dark band's
|
|
94
|
+
ground. The open part of the ring is the ink at a tenth, the track the
|
|
95
|
+
bars layout draws.
|
|
96
|
+
*/
|
|
97
|
+
.donut-figures {
|
|
98
|
+
--financials-1: var(--button);
|
|
99
|
+
--financials-2: color-mix(in srgb, var(--button) 55%, var(--ink));
|
|
100
|
+
--financials-3: color-mix(in srgb, var(--button) 55%, var(--surface));
|
|
101
|
+
--financials-4: color-mix(in srgb, var(--accent) 34%, var(--ink));
|
|
102
|
+
--financials-5: color-mix(in srgb, var(--button) 36%, var(--surface));
|
|
103
|
+
--financials-6: color-mix(in srgb, var(--accent) 78%, var(--ink));
|
|
104
|
+
--financials-7: color-mix(in srgb, var(--accent) 78%, var(--surface));
|
|
105
|
+
--financials-8: color-mix(in srgb, var(--button) 42%, var(--ink));
|
|
106
|
+
--financials-open: color-mix(in srgb, var(--ink) 10%, transparent);
|
|
107
|
+
}
|
|
108
|
+
.donut-figures-ring {
|
|
109
|
+
display: grid;
|
|
110
|
+
grid-template-columns: clamp(13rem, 26vw, 19rem) minmax(0, 1fr);
|
|
111
|
+
align-items: center;
|
|
112
|
+
gap: clamp(1.5rem, 1rem + 3vw, 4rem);
|
|
113
|
+
}
|
|
114
|
+
.donut {
|
|
115
|
+
position: relative;
|
|
116
|
+
aspect-ratio: 1;
|
|
117
|
+
border-radius: 50%;
|
|
118
|
+
background: var(--ring);
|
|
119
|
+
}
|
|
120
|
+
.donut::after {
|
|
121
|
+
content: '';
|
|
122
|
+
position: absolute;
|
|
123
|
+
inset: 21%;
|
|
124
|
+
border-radius: 50%;
|
|
125
|
+
background: var(--bg-band-background);
|
|
126
|
+
}
|
|
127
|
+
.legend {
|
|
128
|
+
margin: 0;
|
|
129
|
+
padding: 0;
|
|
130
|
+
list-style: none;
|
|
131
|
+
}
|
|
132
|
+
.legend-item {
|
|
133
|
+
display: grid;
|
|
134
|
+
grid-template-columns: 1rem minmax(0, 1fr) auto;
|
|
135
|
+
align-items: start;
|
|
136
|
+
gap: 0.25rem 0.875rem;
|
|
137
|
+
padding: 0.875rem 0;
|
|
138
|
+
border-bottom: 1px solid var(--line);
|
|
139
|
+
}
|
|
140
|
+
.legend-item:first-child {
|
|
141
|
+
padding-top: 0;
|
|
142
|
+
}
|
|
143
|
+
.legend-item:last-child {
|
|
144
|
+
padding-bottom: 0;
|
|
145
|
+
border-bottom: 0;
|
|
146
|
+
}
|
|
147
|
+
.legend-swatch {
|
|
148
|
+
width: 1rem;
|
|
149
|
+
height: 1rem;
|
|
150
|
+
margin-top: 0.1875rem;
|
|
151
|
+
border-radius: 0.25rem;
|
|
152
|
+
}
|
|
153
|
+
.legend-swatch[style] {
|
|
154
|
+
box-shadow: inset 0 0 0 1px var(--line);
|
|
155
|
+
}
|
|
156
|
+
.legend-category {
|
|
157
|
+
margin: 0;
|
|
158
|
+
font-weight: 700;
|
|
159
|
+
line-height: 1.3;
|
|
160
|
+
}
|
|
161
|
+
.legend-note {
|
|
162
|
+
margin: 0.25rem 0 0;
|
|
163
|
+
color: var(--muted);
|
|
164
|
+
font-size: var(--text-sm);
|
|
165
|
+
line-height: 1.4;
|
|
166
|
+
}
|
|
167
|
+
.legend-numbers {
|
|
168
|
+
display: flex;
|
|
169
|
+
flex-direction: column;
|
|
170
|
+
align-items: flex-end;
|
|
171
|
+
gap: 0.125rem;
|
|
172
|
+
margin: 0;
|
|
173
|
+
text-align: right;
|
|
174
|
+
font-variant-numeric: tabular-nums;
|
|
175
|
+
}
|
|
176
|
+
.legend-share {
|
|
177
|
+
font-family: var(--font-display);
|
|
178
|
+
font-size: var(--text-lg);
|
|
179
|
+
font-weight: 700;
|
|
180
|
+
line-height: 1.15;
|
|
181
|
+
}
|
|
182
|
+
.legend-amount {
|
|
183
|
+
color: var(--muted);
|
|
184
|
+
font-size: var(--text-sm);
|
|
185
|
+
font-weight: 600;
|
|
186
|
+
}
|
|
187
|
+
/* A phone: the donut centred, the legend under it. */
|
|
188
|
+
@media (max-width: 39.99rem) {
|
|
189
|
+
.donut-figures-ring {
|
|
190
|
+
grid-template-columns: minmax(0, 1fr);
|
|
191
|
+
}
|
|
192
|
+
.donut {
|
|
193
|
+
width: min(100%, 15rem);
|
|
194
|
+
justify-self: center;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// A Financials section's figures as its layouts draw them (REPORT §2 G15,
|
|
2
|
+
// "where the money goes"). The figures are the organization's own published
|
|
3
|
+
// ones, drawn verbatim: nothing here sums, normalises, derives a total or
|
|
4
|
+
// computes a percentage. A row is a figure:
|
|
5
|
+
//
|
|
6
|
+
// - `category`, what the money went to, in the operator's words;
|
|
7
|
+
// - `share`, its part of the whole as the organization published it, a number
|
|
8
|
+
// from 0 to 100 (anything else is left out, and the figure is drawn without
|
|
9
|
+
// a bar, a slice or a share);
|
|
10
|
+
// - `amount`, the operator's words for the money ("$412,000"), never parsed;
|
|
11
|
+
// - `note`, a line under it.
|
|
12
|
+
//
|
|
13
|
+
// A row with neither a category nor an amount is not drawn, and at most
|
|
14
|
+
// twelve figures are.
|
|
15
|
+
|
|
16
|
+
import type { Section } from '@backgold/content'
|
|
17
|
+
import { rows } from '../../../lib/section'
|
|
18
|
+
import { text } from '../../../lib/format'
|
|
19
|
+
|
|
20
|
+
export interface Figure {
|
|
21
|
+
category: string | null
|
|
22
|
+
/** The published share, 0 to 100, as given. */
|
|
23
|
+
share: number | null
|
|
24
|
+
/** The operator's words for the money. */
|
|
25
|
+
amount: string | null
|
|
26
|
+
note: string | null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const MAX = 12
|
|
30
|
+
|
|
31
|
+
function shareOf(value: unknown): number | null {
|
|
32
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 100 ? value : null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The section's figures in row order. */
|
|
36
|
+
export function rowsOf(section: Section): Figure[] {
|
|
37
|
+
return rows(section)
|
|
38
|
+
.flatMap((row) => {
|
|
39
|
+
const category = text(row.category)
|
|
40
|
+
const amount = text(row.amount)
|
|
41
|
+
if (!category && !amount) return []
|
|
42
|
+
return [{ category, share: shareOf(row.share), amount, note: text(row.note) }]
|
|
43
|
+
})
|
|
44
|
+
.slice(0, MAX)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const PERCENT = new Intl.NumberFormat('en-US', { maximumFractionDigits: 2 })
|
|
48
|
+
|
|
49
|
+
/** A share as it is shown: "62%", "12.5%". */
|
|
50
|
+
export function shareLabel(share: number): string {
|
|
51
|
+
return `${PERCENT.format(share)}%`
|
|
52
|
+
}
|