@backgold/template-kit 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/{chunk-KOB36GSF.js → chunk-RJAVFRC6.js} +9 -4
  2. package/dist/{constants-DvTNj4JI.d-Batjcj3Z.d.ts → constants-BAIo_Q5U.d-lQbj1e1-.d.ts} +11 -1
  3. package/dist/{content-api-CYeY0vU8.d.ts → content-api-Cox1-wz5.d.ts} +250 -3
  4. package/dist/contract/content-api-examples.d.ts +17 -3
  5. package/dist/contract/content-api-examples.js +146 -3
  6. package/dist/contract/content-api.d.ts +2 -2
  7. package/dist/contract/content-api.js +1 -1
  8. package/dist/contract/site-templates.d.ts +4 -3
  9. package/dist/contract/site-templates.js +1 -1
  10. package/package.json +5 -5
  11. package/src/components/chrome/Brand.astro +23 -16
  12. package/src/components/sections/About/credentials.ts +0 -10
  13. package/src/components/sections/About/index.astro +6 -3
  14. package/src/components/sections/About/left.astro +6 -3
  15. package/src/components/sections/About/letter.astro +6 -3
  16. package/src/components/sections/About/portrait.astro +2 -2
  17. package/src/components/sections/ContentPost/lesson.ts +14 -7
  18. package/src/components/sections/ContentPost/prose.astro +80 -0
  19. package/src/components/sections/Hero/cover.astro +9 -3
  20. package/src/components/sections/Hero/donate.astro +3 -3
  21. package/src/components/sections/Hero/index.astro +2 -2
  22. package/src/components/sections/Hero/overlap.astro +3 -3
  23. package/src/components/sections/Hero/split.astro +9 -6
  24. package/src/components/sections/Hero/statement.astro +3 -3
  25. package/src/components/sections/Hero/video.astro +3 -3
  26. package/src/components/sections/VoterTools/Lookup.astro +43 -0
  27. package/src/components/sections/VoterTools/dates.astro +9 -5
  28. package/src/components/sections/VoterTools/index.astro +12 -9
  29. package/src/components/sections/VoterTools/polling.astro +9 -6
  30. package/src/components/sections/VoterTools/voter-tools.ts +5 -4
  31. package/src/components/sections/index.ts +3 -0
  32. package/src/components/sections/modules/ModuleFrame.astro +4 -2
  33. package/src/components/store/CollectionPage.astro +40 -0
  34. package/src/components/store/ProductCard.astro +32 -0
  35. package/src/components/store/ProductGrid.astro +16 -0
  36. package/src/components/store/ProductPage.astro +146 -0
  37. package/src/components/store/StorePage.astro +137 -0
  38. package/src/components/store/StoreScript.astro +572 -0
  39. package/src/components/volunteer/props.ts +1 -1
  40. package/src/index.js +0 -1
  41. package/src/layouts/Site.astro +19 -3
  42. package/src/lib/chrome.ts +6 -4
  43. package/src/lib/donate-frame.ts +44 -4
  44. package/src/lib/live.ts +6 -5
  45. package/src/lib/section.ts +11 -0
  46. package/src/lib/shifts.ts +2 -1
  47. package/src/lib/store.ts +521 -0
  48. package/src/routes/catch-all.astro +168 -19
  49. package/src/styles/site.css +71 -0
  50. package/src/styles/store.css +634 -0
  51. package/src/template.ts +1 -1
  52. package/src/routes/volunteer.astro +0 -37
@@ -4,36 +4,43 @@
4
4
  // template's mark (a sun over mountains in a ring, in the brand's primary,
5
5
  // secondary and accent colours) beside a two-line wordmark: the name's first
6
6
  // word large, the rest of it in small capitals under it ("Westmark" /
7
- // "Liberty Party"). A one-word name is one line.
7
+ // "Liberty Party"). A one-word name is one line. With `showName` (the header,
8
+ // when the operator asks for it: `/site` chrome.header.show_name) the logo
9
+ // keeps its size and the same wordmark follows it, so a logo that is only a
10
+ // picture still reads as the organization; the wordmark gives way first when
11
+ // the bar is short of room, its lines cut with an ellipsis. The logo's alt
12
+ // text is then empty: the link reads as the name once.
8
13
  import { safeSrc } from '@backgold/astro/server'
9
14
 
10
15
  interface Props {
11
16
  name: string
12
17
  logoUrl: string | null
18
+ showName?: boolean
13
19
  class?: string
14
20
  }
15
21
 
16
- const { name, logoUrl, class: className } = Astro.props
22
+ const { name, logoUrl, showName = false, class: className } = Astro.props
17
23
  const logo = safeSrc(logoUrl)
18
24
  const [first = name, ...rest] = name.trim().split(/\s+/)
19
25
  const second = rest.join(' ')
26
+ const named = !!logo && showName
20
27
  ---
21
- <a class:list={['brand', className]} href="/">
28
+ <a class:list={['brand', named && 'brand-named', className]} href="/">
22
29
  {logo ? (
23
- <img src={logo} alt={name} class="brand-logo" />
30
+ <img src={logo} alt={named ? '' : name} class="brand-logo" />
24
31
  ) : (
25
- <>
26
- <svg class="brand-mark" viewBox="0 0 48 48" aria-hidden="true">
27
- <circle class="brand-mark-ring" cx="24" cy="24" r="23" stroke-width="2" />
28
- <circle class="brand-mark-sun" cx="31" cy="20" r="7" />
29
- <path class="brand-mark-land" d="M5 33l10-11 6 6 8-10 14 15v2a23 23 0 01-38 0z" />
30
- <path class="brand-mark-snow" d="M15 22l3 3.4M29 18l3.6 4" stroke-width="1.6" fill="none" />
31
- </svg>
32
- <span class="brand-words">
33
- <span class="brand-name">{first}</span>
34
- {second && <span class="brand-rest">{second}</span>}
35
- </span>
36
- </>
32
+ <svg class="brand-mark" viewBox="0 0 48 48" aria-hidden="true">
33
+ <circle class="brand-mark-ring" cx="24" cy="24" r="23" stroke-width="2" />
34
+ <circle class="brand-mark-sun" cx="31" cy="20" r="7" />
35
+ <path class="brand-mark-land" d="M5 33l10-11 6 6 8-10 14 15v2a23 23 0 01-38 0z" />
36
+ <path class="brand-mark-snow" d="M15 22l3 3.4M29 18l3.6 4" stroke-width="1.6" fill="none" />
37
+ </svg>
38
+ )}
39
+ {(!logo || named) && (
40
+ <span class="brand-words">
41
+ <span class="brand-name">{first}</span>
42
+ {second && <span class="brand-rest">{second}</span>}
43
+ </span>
37
44
  )}
38
45
  </a>
39
46
 
@@ -78,13 +78,3 @@ export function quoteOf(section: Section): { quote: string; source: string | nul
78
78
  export function buttonOf(section: Section): Link | null {
79
79
  return links(section)[0] ?? null
80
80
  }
81
-
82
- /**
83
- * The photo's treatment (`options.photoStyle`), as BackGold's own About
84
- * block reads it: 'photo' (the default) crops to fill; 'badge' and 'plain'
85
- * show the whole picture (a logo), on the band's surface or on nothing.
86
- */
87
- export function photoStyleOf(section: Section): 'photo' | 'badge' | 'plain' {
88
- const style = section.options?.photoStyle
89
- return style === 'badge' || style === 'plain' ? style : 'photo'
90
- }
@@ -2,11 +2,13 @@
2
2
  // About, 'right' layout, the default (Photo right; board A10-petition,
3
3
  // section 2): the heading and the story on the left, the photo on the right;
4
4
  // on a phone the photo follows the words. Without a photo the words take
5
- // the column alone. 'left' and 'letter' are their own files beside this one.
5
+ // the column alone. A photo crops to fill its frame; with the photo
6
+ // treatment 'badge' or 'plain' (a logo) it shows whole in it (lib/section.ts
7
+ // photoStyleOf, styles/site.css). 'left' and 'letter' are their own files beside this one.
6
8
  import type { Section } from '@backgold/content'
7
9
  import Band from '../Band.astro'
8
10
  import Prose from '../../Prose.astro'
9
- import { media } from '../../../lib/section'
11
+ import { media, photoStyleOf } from '../../../lib/section'
10
12
  import { text } from '../../../lib/format'
11
13
 
12
14
  interface Props {
@@ -17,6 +19,7 @@ interface Props {
17
19
  const { section } = Astro.props
18
20
  const heading = text(section.copy.heading)
19
21
  const photo = media(section, 'photoUrl')
22
+ const style = photoStyleOf(section)
20
23
  ---
21
24
  <Band section={section} class="about">
22
25
  <div class:list={['about-right', photo && 'about-right-photo']}>
@@ -24,7 +27,7 @@ const photo = media(section, 'photoUrl')
24
27
  {heading && <h2>{heading}</h2>}
25
28
  <Prose value={section.copy.body} />
26
29
  </div>
27
- {photo && <img class="about-right-image" src={photo.url} alt={photo.alt} loading="lazy" decoding="async" />}
30
+ {photo && <img class:list={['about-right-image', style !== 'photo' && `photo-${style}`]} src={photo.url} alt={photo.alt} loading="lazy" decoding="async" />}
28
31
  </div>
29
32
  </Band>
30
33
 
@@ -1,12 +1,14 @@
1
1
  ---
2
2
  // About, 'left' layout (Photo left; board A11-contact, section 3): a square
3
3
  // photo on the left, the heading and the story on the right; on a phone the
4
- // photo comes first. Without a photo the words take the column alone.
4
+ // photo comes first. Without a photo the words take the column alone. The
5
+ // photo treatment 'badge' or 'plain' shows the whole picture in the square
6
+ // (lib/section.ts photoStyleOf).
5
7
  import type { ComponentProps } from 'astro/types'
6
8
  import Band from '../Band.astro'
7
9
  import Prose from '../../Prose.astro'
8
10
  import type Default from './index.astro'
9
- import { media } from '../../../lib/section'
11
+ import { media, photoStyleOf } from '../../../lib/section'
10
12
  import { text } from '../../../lib/format'
11
13
 
12
14
  type Props = ComponentProps<typeof Default>
@@ -14,10 +16,11 @@ type Props = ComponentProps<typeof Default>
14
16
  const { section } = Astro.props
15
17
  const heading = text(section.copy.heading)
16
18
  const photo = media(section, 'photoUrl')
19
+ const style = photoStyleOf(section)
17
20
  ---
18
21
  <Band section={section} class="about">
19
22
  <div class:list={['about-left', photo && 'about-left-photo']}>
20
- {photo && <img class="about-left-image" src={photo.url} alt={photo.alt} loading="lazy" decoding="async" />}
23
+ {photo && <img class:list={['about-left-image', style !== 'photo' && `photo-${style}`]} src={photo.url} alt={photo.alt} loading="lazy" decoding="async" />}
21
24
  <div class="about-left-words">
22
25
  {heading && <h2>{heading}</h2>}
23
26
  <Prose value={section.copy.body} />
@@ -5,12 +5,14 @@
5
5
  // (their initials on the brand's colours when there is a signature and no
6
6
  // photo) and their signature and role (`copy.signature`, `copy.role`) under
7
7
  // it. On a phone the picture sits above the letter, smaller. With neither a
8
- // photo nor a signature the letter is one centred column.
8
+ // photo nor a signature the letter is one centred column. The photo
9
+ // treatment 'badge' or 'plain' shows the whole picture in the square
10
+ // (lib/section.ts photoStyleOf).
9
11
  import type { ComponentProps } from 'astro/types'
10
12
  import Band from '../Band.astro'
11
13
  import Prose from '../../Prose.astro'
12
14
  import type Default from './index.astro'
13
- import { media } from '../../../lib/section'
15
+ import { media, photoStyleOf } from '../../../lib/section'
14
16
  import { text } from '../../../lib/format'
15
17
  import { initials } from '../../../lib/entries'
16
18
 
@@ -22,11 +24,12 @@ const kicker = text(section.copy.kicker)
22
24
  const signature = text(section.copy.signature)
23
25
  const role = text(section.copy.role)
24
26
  const photo = media(section, 'photoUrl')
27
+ const style = photoStyleOf(section)
25
28
  const tile = !photo && signature ? initials(signature) : null
26
29
  ---
27
30
  <Band section={section} class="about">
28
31
  <div class:list={['letter', (photo || tile) && 'letter-with-photo']}>
29
- {photo && <img class="letter-image" src={photo.url} alt={photo.alt} loading="lazy" decoding="async" />}
32
+ {photo && <img class:list={['letter-image', style !== 'photo' && `photo-${style}`]} src={photo.url} alt={photo.alt} loading="lazy" decoding="async" />}
30
33
  {tile && <div class="letter-image letter-tile" aria-hidden="true">{tile}</div>}
31
34
  <div class="letter-words">
32
35
  {kicker && <p class="kicker">{kicker}</p>}
@@ -20,8 +20,8 @@ import type { ComponentProps } from 'astro/types'
20
20
  import Band from '../Band.astro'
21
21
  import Prose from '../../Prose.astro'
22
22
  import type Default from './index.astro'
23
- import { buttonOf, credentialsOf, photoStyleOf, quoteOf } from './credentials'
24
- import { media } from '../../../lib/section'
23
+ import { buttonOf, credentialsOf, quoteOf } from './credentials'
24
+ import { media, photoStyleOf } from '../../../lib/section'
25
25
  import { prose, text } from '../../../lib/format'
26
26
 
27
27
  type Props = ComponentProps<typeof Default>
@@ -53,15 +53,14 @@ function mediaOf(row: Record<string, unknown>): LessonMedia | null {
53
53
  const escapeText = (value: string) => value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
54
54
 
55
55
  /**
56
- * The notes as HTML a page can emit: the bake's HTML through the allowlist, or
57
- * plain text as paragraphs (a blank line between them). The body's headings
58
- * move down two levels (h2 → h4, h3 → h5) to sit under the section's title
59
- * (h2) and the notes' own heading (h3).
56
+ * The body as HTML a page can emit: the bake's HTML through the allowlist, or
57
+ * plain text as paragraphs (a blank line between them). The Prose layout
58
+ * emits it as it is, under the section's title.
60
59
  */
61
- function notesOf(value: unknown): string {
60
+ export function bodyOf(value: unknown): string {
62
61
  const raw = text(value)?.trim()
63
62
  if (!raw) return ''
64
- const html = raw.startsWith('<')
63
+ return raw.startsWith('<')
65
64
  ? sanitizeRichText(raw)
66
65
  : raw
67
66
  .split(/\n{2,}/)
@@ -69,7 +68,15 @@ function notesOf(value: unknown): string {
69
68
  .filter(Boolean)
70
69
  .map((p) => `<p>${escapeText(p)}</p>`)
71
70
  .join('')
72
- return html.replace(/<(\/?)h([23])>/g, (_, slash: string, level: string) => `<${slash}h${Number(level) + 2}>`)
71
+ }
72
+
73
+ /**
74
+ * The notes: the body (bodyOf) with its headings moved down two levels
75
+ * (h2 → h4, h3 → h5) to sit under the section's title (h2) and the notes'
76
+ * own heading (h3).
77
+ */
78
+ function notesOf(value: unknown): string {
79
+ return bodyOf(value).replace(/<(\/?)h([23])>/g, (_, slash: string, level: string) => `<${slash}h${Number(level) + 2}>`)
73
80
  }
74
81
 
75
82
  /**
@@ -0,0 +1,80 @@
1
+ ---
2
+ // ContentPost · Prose: the whole piece in the page, as BackGold's hosted
3
+ // renderer draws a ContentPost (it draws the piece as prose for every
4
+ // layout). The section's heading as a kicker, the title (linking to the
5
+ // piece's page on this site, as the Card layout links it, and left out when
6
+ // the section's `showTitle` option is off), its date when `showDate` is on,
7
+ // then the body: the bake's render of the entry (headings, lists, links,
8
+ // pictures and paragraphs), reduced to the entry editor's allowlist again
9
+ // before the page emits it (lesson.ts bodyOf), at the site's reading measure.
10
+ // The candidate template draws this by default, so a site that moves to it
11
+ // keeps every article it wrote in place (an about page, a position paper, a
12
+ // survey's answers) instead of a card to a page it never had. With no piece
13
+ // baked, or a piece with no body, the section draws nothing, as the Card
14
+ // layout does.
15
+ import type { ComponentProps } from 'astro/types'
16
+ import type Default from './index.astro'
17
+ import { blogBaseOf } from '@backgold/astro/server'
18
+ import Band from '../Band.astro'
19
+ import { bodyOf } from './lesson'
20
+ import { basePath } from '../../../lib/entries'
21
+ import { rows } from '../../../lib/section'
22
+ import { formatDay, text } from '../../../lib/format'
23
+
24
+ type Props = ComponentProps<typeof Default>
25
+
26
+ const { section } = Astro.props
27
+ const heading = text(section.copy.heading)
28
+ const body = bodyOf(section.copy.postHtml)
29
+ const [row] = rows(section)
30
+ const title = text(row?.title)
31
+ const slug = text(row?.slug)
32
+ const bg = Astro.locals.backgold
33
+ const showTitle = section.options?.showTitle !== false
34
+ const showDate = section.options?.showDate === true
35
+ const base =
36
+ showTitle && slug && /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(slug) && bg.setup === null
37
+ ? blogBaseOf((await bg.client.types()).types)
38
+ : null
39
+ const href = base ? `${basePath(base)}/${slug}` : null
40
+ const date = text(row?.date)
41
+ const day = showDate ? formatDay(date) : null
42
+ ---
43
+ {body && (
44
+ <Band section={section} class="featured featured-prose">
45
+ {heading && <p class="kicker">{heading}</p>}
46
+ {showTitle && title && <h2 class="featured-title">{href ? <a href={href}>{title}</a> : title}</h2>}
47
+ {day && date && <p class="fine"><time datetime={date}>{day}</time></p>}
48
+ <div class="prose cp-body" set:html={body} />
49
+ </Band>
50
+ )}
51
+
52
+ <style>
53
+ /* The body reads under its title at the site's measure; a title-less piece starts at the band's top. */
54
+ .cp-body {
55
+ margin-top: 1.25rem;
56
+ }
57
+ .featured-prose > .kicker + .featured-title {
58
+ margin-top: 0.5rem;
59
+ }
60
+ .featured-prose > .fine {
61
+ margin-top: 0.375rem;
62
+ }
63
+ .cp-body > :global(:first-child) {
64
+ margin-top: 0;
65
+ }
66
+ .cp-body > :global(:last-child) {
67
+ margin-bottom: 0;
68
+ }
69
+ /* The body's own headings sit under the section's title (h2). */
70
+ .cp-body :global(h2) {
71
+ font-size: calc(var(--h2) * 0.7);
72
+ }
73
+ .cp-body :global(h3) {
74
+ font-size: var(--text-lg);
75
+ }
76
+ .cp-body :global(img) {
77
+ max-width: 100%;
78
+ height: auto;
79
+ }
80
+ </style>
@@ -14,7 +14,7 @@
14
14
  // <h2>. A Hero with its signup form on carries an `embed`: BackGold's own
15
15
  // form, framed under the buttons.
16
16
  import type { ComponentProps } from 'astro/types'
17
- import { Embed } from '@backgold/astro/components'
17
+ import ModuleFrame from '../modules/ModuleFrame.astro'
18
18
  import Band from '../Band.astro'
19
19
  import type Default from './index.astro'
20
20
  import { heroPhoto, links } from '../../../lib/section'
@@ -58,7 +58,7 @@ const [lead, last] = split ? [split[1]!, split[2]!] : [headline ?? '', null]
58
58
  {buttons.map((link, i) => <a class:list={['button', i > 0 && 'button-quiet']} href={link.href} rel={link.rel}>{link.label}</a>)}
59
59
  </p>
60
60
  )}
61
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
61
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
62
62
  </div>
63
63
  </Band>
64
64
 
@@ -146,7 +146,7 @@ const [lead, last] = split ? [split[1]!, split[2]!] : [headline ?? '', null]
146
146
  .cover-words .actions {
147
147
  margin-top: 1.875rem;
148
148
  }
149
- .cover-words > :global(.bg-embed) {
149
+ .cover-words > :global(.hero-signup) {
150
150
  margin-top: 1.5rem;
151
151
  }
152
152
  @media (min-width: 48rem) {
@@ -167,4 +167,10 @@ const [lead, last] = split ? [split[1]!, split[2]!] : [headline ?? '', null]
167
167
  transform: translateY(0.75rem);
168
168
  }
169
169
  }
170
+ /* The kicker reads in the photo band's full ink, not the accent: over a bright
171
+ sky the accent (a light blue in both modes) fades where the scrim is still
172
+ thin (A1 note 2: legibility is not a taste). */
173
+ .cover-words.on-photo .kicker {
174
+ color: var(--band-photo-ink);
175
+ }
170
176
  </style>
@@ -20,7 +20,7 @@
20
20
  // other Hero's is an <h2>. A Hero with its signup form on carries an `embed`:
21
21
  // BackGold's own form, framed under the words.
22
22
  import type { ComponentProps } from 'astro/types'
23
- import { Embed } from '@backgold/astro/components'
23
+ import ModuleFrame from '../modules/ModuleFrame.astro'
24
24
  import Band from '../Band.astro'
25
25
  import DonateCard from '../QuickDonate/DonateCard.astro'
26
26
  import { quickDonate } from '../QuickDonate/donate'
@@ -70,7 +70,7 @@ const [lead, last] = split ? [split[1]!, split[2]!] : [headline ?? '', null]
70
70
  <a class="button button-quiet" href={second.href} rel={second.rel}>{second.label}</a>
71
71
  </p>
72
72
  )}
73
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
73
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
74
74
  </div>
75
75
  <DonateCard qd={qd} />
76
76
  </div>
@@ -158,7 +158,7 @@ const [lead, last] = split ? [split[1]!, split[2]!] : [headline ?? '', null]
158
158
  .donate-words .actions {
159
159
  margin-top: 1.75rem;
160
160
  }
161
- .donate-words > :global(.bg-embed) {
161
+ .donate-words > :global(.hero-signup) {
162
162
  margin-top: 1.5rem;
163
163
  }
164
164
  .donate-grid > :global(.qd-card) {
@@ -9,7 +9,7 @@
9
9
  // A Hero with its signup form on carries an `embed`: BackGold's own form,
10
10
  // framed below the words (never rebuild it here; consent stays with BackGold).
11
11
  import type { Section } from '@backgold/content'
12
- import { Embed } from '@backgold/astro/components'
12
+ import ModuleFrame from '../modules/ModuleFrame.astro'
13
13
  import Band from '../Band.astro'
14
14
  import { heroPhoto, links } from '../../../lib/section'
15
15
  import { text } from '../../../lib/format'
@@ -34,7 +34,7 @@ const split = section.variant === 'split' && picture !== null
34
34
  {headline && <Heading class="hero-headline">{headline}</Heading>}
35
35
  {subheadline && <p class="hero-lede">{subheadline}</p>}
36
36
  {cta && <p class="actions"><a class="button" href={cta.href} rel={cta.rel}>{cta.label}</a></p>}
37
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
37
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
38
38
  </div>
39
39
  {picture && (
40
40
  <div class="hero-photo">
@@ -13,7 +13,7 @@
13
13
  // A Hero with its signup form on carries an `embed`: BackGold's own form,
14
14
  // framed under the buttons.
15
15
  import type { ComponentProps } from 'astro/types'
16
- import { Embed } from '@backgold/astro/components'
16
+ import ModuleFrame from '../modules/ModuleFrame.astro'
17
17
  import Band from '../Band.astro'
18
18
  import type Default from './index.astro'
19
19
  import { heroPhoto, links } from '../../../lib/section'
@@ -53,7 +53,7 @@ const buttons = links(section)
53
53
  {buttons.map((link, i) => <a class:list={['button', i > 0 && 'button-quiet']} href={link.href} rel={link.rel}>{link.label}</a>)}
54
54
  </p>
55
55
  )}
56
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
56
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
57
57
  </div>
58
58
  </Band>
59
59
 
@@ -123,7 +123,7 @@ const buttons = links(section)
123
123
  .overlap-panel .actions {
124
124
  margin: 1.625rem 0 0;
125
125
  }
126
- .overlap-panel > :global(.bg-embed) {
126
+ .overlap-panel > :global(.hero-signup) {
127
127
  margin-top: 1.5rem;
128
128
  }
129
129
  .overlap-panel > :last-child {
@@ -5,12 +5,14 @@
5
5
  // its caption (`copy.caption`) a chip at its lower left. Without a photo the
6
6
  // words take the full width, with no caption. The page-opening Hero's headline is the page's <h1>
7
7
  // (`level={1}`); any other Hero's is an <h2>. A Hero with its signup form on
8
- // carries an `embed`: BackGold's own form, framed under the buttons.
8
+ // carries an `embed`: BackGold's own form, framed under the buttons. The
9
+ // photo crops to fill its frame; with the photo treatment 'badge' or 'plain'
10
+ // (a logo, an illustration) it shows whole in it (lib/section.ts photoStyleOf).
9
11
  import type { ComponentProps } from 'astro/types'
10
- import { Embed } from '@backgold/astro/components'
12
+ import ModuleFrame from '../modules/ModuleFrame.astro'
11
13
  import Band from '../Band.astro'
12
14
  import type Default from './index.astro'
13
- import { heroPhoto, links } from '../../../lib/section'
15
+ import { heroPhoto, links, photoStyleOf } from '../../../lib/section'
14
16
  import { text } from '../../../lib/format'
15
17
 
16
18
  type Props = ComponentProps<typeof Default>
@@ -21,6 +23,7 @@ const headline = text(section.copy.headline)
21
23
  const subheadline = text(section.copy.subheadline)
22
24
  const caption = text(section.copy.caption)
23
25
  const picture = heroPhoto(section, 'imageUrl', 'photoUrl', 'videoPosterUrl')
26
+ const style = photoStyleOf(section)
24
27
  const buttons = links(section)
25
28
  ---
26
29
  <Band section={section} class="hero-split-layout">
@@ -33,12 +36,12 @@ const buttons = links(section)
33
36
  {buttons.map((link, i) => <a class:list={['button', i > 0 && 'button-quiet']} href={link.href} rel={link.rel}>{link.label}</a>)}
34
37
  </p>
35
38
  )}
36
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
39
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
37
40
  </div>
38
41
  {picture && (
39
42
  <div class="split-photo">
40
43
  <img
41
- class="split-image"
44
+ class:list={['split-image', style !== 'photo' && `photo-${style}`]}
42
45
  src={picture.url}
43
46
  alt={picture.alt}
44
47
  loading={level === 1 ? 'eager' : 'lazy'}
@@ -72,7 +75,7 @@ const buttons = links(section)
72
75
  .split-words .actions {
73
76
  margin-top: 1.75rem;
74
77
  }
75
- .split-words > :global(.bg-embed) {
78
+ .split-words > :global(.hero-signup) {
76
79
  margin-top: 1.5rem;
77
80
  }
78
81
  .split-photo {
@@ -5,7 +5,7 @@
5
5
  // line. The page-opening Hero's headline is the page's <h1> (`level={1}`);
6
6
  // any other Hero's is an <h2>. The signup form is BackGold's own (`embed`).
7
7
  import type { ComponentProps } from 'astro/types'
8
- import { Embed } from '@backgold/astro/components'
8
+ import ModuleFrame from '../modules/ModuleFrame.astro'
9
9
  import Band from '../Band.astro'
10
10
  import type Default from './index.astro'
11
11
  import { links } from '../../../lib/section'
@@ -30,7 +30,7 @@ const buttons = links(section)
30
30
  {buttons.map((link, i) => <a class:list={['button', i > 0 && 'button-quiet']} href={link.href} rel={link.rel}>{link.label}</a>)}
31
31
  </p>
32
32
  )}
33
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
33
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
34
34
  </div>
35
35
  </Band>
36
36
 
@@ -48,7 +48,7 @@ const buttons = links(section)
48
48
  max-width: 40em;
49
49
  margin: 1.25rem 0 0;
50
50
  }
51
- .statement > :global(.bg-embed) {
51
+ .statement > :global(.hero-signup) {
52
52
  margin-top: 1.5rem;
53
53
  max-width: 40rem;
54
54
  }
@@ -28,7 +28,7 @@
28
28
  // Hero's is an <h2>. A Hero with its signup form on carries an `embed`:
29
29
  // BackGold's own form, framed under the buttons.
30
30
  import type { ComponentProps } from 'astro/types'
31
- import { Embed } from '@backgold/astro/components'
31
+ import ModuleFrame from '../modules/ModuleFrame.astro'
32
32
  import Band from '../Band.astro'
33
33
  import Cover from './cover.astro'
34
34
  import type Default from './index.astro'
@@ -109,7 +109,7 @@ const what = video ? 'background video' : 'changing words'
109
109
  {buttons.map((link, i) => <a class:list={['button', i > 0 && 'button-quiet']} href={link.href} rel={link.rel}>{link.label}</a>)}
110
110
  </p>
111
111
  )}
112
- {section.embed && <Embed embed={section.embed} title="Sign up" />}
112
+ {section.embed && <ModuleFrame embed={section.embed} band={section.band} type="SignupCapture" layout="card" title="Sign up" height="24rem" class="hero-signup" />}
113
113
  </div>
114
114
  {moving && (
115
115
  <>
@@ -361,7 +361,7 @@ const what = video ? 'background video' : 'changing words'
361
361
  .motion-words .actions {
362
362
  margin-top: 1.875rem;
363
363
  }
364
- .motion-words > :global(.bg-embed) {
364
+ .motion-words > :global(.hero-signup) {
365
365
  margin-top: 1.5rem;
366
366
  }
367
367
  @media (min-width: 48rem) {
@@ -0,0 +1,43 @@
1
+ ---
2
+ // The polling-place lookup a Voter tools section carries when its Polling
3
+ // place lookup is on: BackGold's widget, mounted in the container the Content
4
+ // API sends as the section's embed (a script mount, the Advocacy module's
5
+ // shape). The visitor types their address and sees the election on the
6
+ // calendar, their election-day polling place, early voting sites, drop-offs
7
+ // and their election office's links, answered by BackGold; the address goes
8
+ // to that one lookup and nowhere else. The widget draws in its own shadow
9
+ // root and takes the band's colours and type through its `--bg-vt-*`
10
+ // properties, set here from the kit's tokens. A section with no embed draws
11
+ // nothing here.
12
+ import type { Section } from '@backgold/content'
13
+ import { Embed } from '@backgold/astro/components'
14
+
15
+ interface Props {
16
+ section: Section
17
+ }
18
+
19
+ const { section } = Astro.props
20
+ ---
21
+ {section.embed && (
22
+ <div class="vt-lookup">
23
+ <Embed embed={section.embed} title="Find your polling place" />
24
+ </div>
25
+ )}
26
+
27
+ <style>
28
+ .vt-lookup {
29
+ margin-top: 1.5rem;
30
+ }
31
+ .vt-lookup :global(.bg-embed-mount) {
32
+ --bg-vt-accent: var(--button);
33
+ --bg-vt-accent-ink: var(--button-ink);
34
+ --bg-vt-link: var(--link);
35
+ --bg-vt-text: var(--ink);
36
+ --bg-vt-muted: var(--muted);
37
+ --bg-vt-card: var(--surface);
38
+ --bg-vt-input-bg: var(--surface);
39
+ --bg-vt-border: var(--line);
40
+ --bg-vt-radius: var(--radius);
41
+ --bg-vt-heading-font: var(--font-display);
42
+ }
43
+ </style>
@@ -7,15 +7,17 @@
7
7
  // the visitor's browser ("12 days left", "Today", "Closed"), and its note.
8
8
  // The nearest open date's tile carries an accent rule across its top and
9
9
  // its day and state in the accent; a closed date's tile goes quiet. Under
10
- // the tiles, the registration link as the main call and the polling-place
11
- // link as an outline (the polling link is the main call when there is no
12
- // registration link). Nothing is drawn when the section has neither a
13
- // heading, a link nor a date.
10
+ // the tiles, BackGold's polling-place lookup when the section carries it
11
+ // (Lookup.astro), then the registration link as the main call and the
12
+ // polling-place link as an outline (the polling link is the main call when
13
+ // there is no registration link). Nothing is drawn when the section has
14
+ // neither a heading, a link, a lookup nor a date.
14
15
  import type { ComponentProps } from 'astro/types'
15
16
  import Band from '../Band.astro'
16
17
  import SectionHead from '../SectionHead.astro'
17
18
  import DaysLeft from './DaysLeft.astro'
18
19
  import type Default from './index.astro'
20
+ import Lookup from './Lookup.astro'
19
21
  import { voterTools } from './voter-tools'
20
22
 
21
23
  type Props = ComponentProps<typeof Default>
@@ -24,7 +26,8 @@ const { section } = Astro.props
24
26
  const vt = voterTools(section)
25
27
  const heading = vt.datesHeading ?? vt.heading
26
28
  const buttons = [vt.register, vt.polling].filter((link) => link !== null)
27
- const shown = !!(vt.heading || buttons.length > 0 || vt.dates.length > 0)
29
+ const lookup = !!section.embed
30
+ const shown = !!(vt.heading || buttons.length > 0 || vt.dates.length > 0 || lookup)
28
31
  const across = Math.min(vt.dates.length, 4)
29
32
  ---
30
33
  {shown && (
@@ -49,6 +52,7 @@ const across = Math.min(vt.dates.length, 4)
49
52
  ))}
50
53
  </ul>
51
54
  )}
55
+ {lookup && <Lookup section={section} />}
52
56
  {buttons.length > 0 && (
53
57
  <p class="actions vt-actions">
54
58
  {buttons.map((link, i) => <a class:list={['button', i > 0 && 'button-quiet']} href={link.href} rel={link.rel}>{link.label}</a>)}