bearminion 1.7.0 → 1.9.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/astro.d.ts +2 -2
  3. package/dist/astro.js +17 -5
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +819 -0
  6. package/dist/content.d.ts +1 -1
  7. package/dist/content.js +2 -2
  8. package/dist/hash-BeBymBO1.js +59 -0
  9. package/dist/index.d.ts +2 -2
  10. package/dist/index.js +4 -4
  11. package/dist/marks-DPBilumg.js +174 -0
  12. package/dist/marks.js +1 -174
  13. package/dist/{options-BeJQnsZM.d.ts → options-4HWVEj9O.d.ts} +7 -1
  14. package/dist/{page-BfI9cD8g.d.ts → page-CA4iyFDS.d.ts} +7 -7
  15. package/dist/{page-NOFVEqn1.js → page-X-WnOu7-.js} +1 -1
  16. package/dist/{preview--S1QUrMM.js → preview-B_88I5Jm.js} +1 -1
  17. package/dist/{reload-BPkPoQ-P.js → reload-Dkp3xC0l.js} +1 -1
  18. package/dist/rich-text-70hddxMC.js +403 -0
  19. package/dist/rich-text.js +1 -403
  20. package/dist/sections-manifest-CO9QfJPG.js +97 -0
  21. package/dist/{theme-DFjHjgFO.js → theme-Dv7_7B56.js} +2 -2
  22. package/dist/ui/mount.js +20 -7
  23. package/package.json +7 -1
  24. package/registry/default/files/src/components/atoms/Button.astro +64 -0
  25. package/registry/default/files/src/components/atoms/Emphasis.astro +24 -0
  26. package/registry/default/files/src/components/atoms/Image.astro +78 -0
  27. package/registry/default/files/src/components/atoms/Typography.astro +53 -0
  28. package/registry/default/files/src/components/atoms/button.ts +31 -0
  29. package/registry/default/files/src/components/atoms/image.ts +34 -0
  30. package/registry/default/files/src/components/atoms/options.ts +39 -0
  31. package/registry/default/files/src/components/atoms/typography.ts +64 -0
  32. package/registry/default/files/src/components/molecules/CommandLine.astro +109 -0
  33. package/registry/default/files/src/components/molecules/MediaFrame.astro +71 -0
  34. package/registry/default/files/src/components/molecules/Pill.astro +24 -0
  35. package/registry/default/files/src/components/molecules/SectionHeader.astro +63 -0
  36. package/registry/default/files/src/components/molecules/SectionShell.astro +33 -0
  37. package/registry/default/files/src/components/sections/contact/Contact.astro +231 -0
  38. package/registry/default/files/src/components/sections/contact/definition.ts +52 -0
  39. package/registry/default/files/src/components/sections/contact/form.ts +313 -0
  40. package/registry/default/files/src/components/sections/contact/wireframe.ts +15 -0
  41. package/registry/default/files/src/components/sections/cta/Cta.astro +206 -0
  42. package/registry/default/files/src/components/sections/cta/definition.ts +49 -0
  43. package/registry/default/files/src/components/sections/cta/wireframe.ts +9 -0
  44. package/registry/default/files/src/components/sections/faq/Faq.astro +136 -0
  45. package/registry/default/files/src/components/sections/faq/definition.ts +54 -0
  46. package/registry/default/files/src/components/sections/faq/wireframe.ts +19 -0
  47. package/registry/default/files/src/components/sections/features/Features.astro +146 -0
  48. package/registry/default/files/src/components/sections/features/definition.ts +54 -0
  49. package/registry/default/files/src/components/sections/features/wireframe.ts +19 -0
  50. package/registry/default/files/src/components/sections/gallery/Gallery.astro +128 -0
  51. package/registry/default/files/src/components/sections/gallery/definition.ts +59 -0
  52. package/registry/default/files/src/components/sections/gallery/lightbox.ts +159 -0
  53. package/registry/default/files/src/components/sections/gallery/wireframe.ts +12 -0
  54. package/registry/default/files/src/components/sections/hero/Hero.astro +185 -0
  55. package/registry/default/files/src/components/sections/hero/HeroBadge.astro +26 -0
  56. package/registry/default/files/src/components/sections/hero/definition.ts +74 -0
  57. package/registry/default/files/src/components/sections/hero/wireframe.ts +12 -0
  58. package/registry/default/files/src/components/sections/logo-strip/LogoStrip.astro +107 -0
  59. package/registry/default/files/src/components/sections/logo-strip/definition.ts +30 -0
  60. package/registry/default/files/src/components/sections/logo-strip/wireframe.ts +11 -0
  61. package/registry/default/files/src/components/sections/media/Media.astro +118 -0
  62. package/registry/default/files/src/components/sections/media/MediaPlayer.astro +176 -0
  63. package/registry/default/files/src/components/sections/media/definition.ts +77 -0
  64. package/registry/default/files/src/components/sections/media/source.ts +3 -0
  65. package/registry/default/files/src/components/sections/media/wireframe.ts +9 -0
  66. package/registry/default/files/src/components/sections/pricing/Pricing.astro +210 -0
  67. package/registry/default/files/src/components/sections/pricing/definition.ts +62 -0
  68. package/registry/default/files/src/components/sections/pricing/wireframe.ts +18 -0
  69. package/registry/default/files/src/components/sections/shared.ts +13 -0
  70. package/registry/default/files/src/components/sections/stats/Stats.astro +110 -0
  71. package/registry/default/files/src/components/sections/stats/definition.ts +41 -0
  72. package/registry/default/files/src/components/sections/stats/wireframe.ts +15 -0
  73. package/registry/default/files/src/components/sections/steps/Steps.astro +139 -0
  74. package/registry/default/files/src/components/sections/steps/definition.ts +62 -0
  75. package/registry/default/files/src/components/sections/steps/icons.ts +27 -0
  76. package/registry/default/files/src/components/sections/steps/wireframe.ts +16 -0
  77. package/registry/default/files/src/components/sections/testimonials/Testimonials.astro +172 -0
  78. package/registry/default/files/src/components/sections/testimonials/definition.ts +42 -0
  79. package/registry/default/files/src/components/sections/testimonials/wireframe.ts +21 -0
  80. package/registry/default/files/src/components/sections/text/Text.astro +43 -0
  81. package/registry/default/files/src/components/sections/text/definition.ts +36 -0
  82. package/registry/default/files/src/components/sections/text/wireframe.ts +12 -0
  83. package/registry/default/files/src/components/sections/text-image/TextImage.astro +107 -0
  84. package/registry/default/files/src/components/sections/text-image/definition.ts +39 -0
  85. package/registry/default/files/src/components/sections/text-image/wireframe.ts +12 -0
  86. package/registry/default/files/src/lib/assets.ts +13 -0
  87. package/registry/default/files/src/lib/cn.ts +6 -0
  88. package/registry/default/files/src/lib/contact-form.ts +97 -0
  89. package/registry/default/files/src/lib/hidden-text.ts +32 -0
  90. package/registry/default/files/src/lib/image-url.ts +38 -0
  91. package/registry/default/files/src/lib/link-attrs.ts +74 -0
  92. package/registry/default/registry.json +670 -0
@@ -0,0 +1,206 @@
1
+ ---
2
+ import type { Section } from '../definitions'
3
+ import { renderRichText } from 'bearminion/rich-text'
4
+ import Button from '../../atoms/Button.astro'
5
+ import { buttonLinkProps, buttonVariant, onAccentClass } from '../../../lib/link-attrs'
6
+ import Emphasis from '../../atoms/Emphasis.astro'
7
+ import Typography from '../../atoms/Typography.astro'
8
+ import SectionShell from '../../molecules/SectionShell.astro'
9
+
10
+ interface Props {
11
+ section: Extract<Section, { type: 'cta' }>
12
+ index: number
13
+ motion?: boolean
14
+ }
15
+
16
+ const { section, index, motion = true } = Astro.props
17
+ const props = section.props
18
+ const field = (path: string) => `sections.${index}.props.${path}`
19
+ const reveal = section.motion ?? motion
20
+ const bodyHtml = props.body ? renderRichText(props.body) : ''
21
+ const hasActions = Boolean(props.primary || props.secondary)
22
+ // The band is an accent surface: the default primary there is the inverted button, the secondary an outline.
23
+ const bandPrimary = props.primary ? buttonVariant(props.primary, 'strong', true) : 'strong'
24
+ const bandSecondary = props.secondary ? buttonVariant(props.secondary, 'secondary', true) : 'secondary'
25
+ ---
26
+
27
+ <SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={reveal}>
28
+ {
29
+ section.variant === 'band' && (
30
+ <div class="section-container" data-cta>
31
+ <div class="flex flex-wrap items-center justify-between gap-8 rounded-panel bg-accent px-8 py-10 text-on @min-[900px]:px-12">
32
+ {
33
+ (props.heading || props.body) && (
34
+ <div class="min-w-0 flex-[1_1_24rem]">
35
+ {props.heading && (
36
+ <h2 class="text-[clamp(2.25rem,1.2rem+4.4cqi,4.75rem)] leading-[0.95] font-semibold tracking-[-0.05em]">
37
+ <Emphasis heading={props.heading} marks={props.marks} data-field={field('heading')} />
38
+ </h2>
39
+ )}
40
+ {props.body && (
41
+ <div class="mt-4 max-w-xl text-[1.0625rem] leading-[1.55] text-on/80" data-field={field('body')} data-field-kind="rich" set:html={bodyHtml} />
42
+ )}
43
+ </div>
44
+ )
45
+ }
46
+ {(props.command || hasActions) && (
47
+ <div class="flex min-w-[16rem] flex-[0_1_24rem] flex-col items-stretch gap-3">
48
+ {props.command && (
49
+ <button type="button" data-copy class="flex h-12 items-center justify-between gap-3 rounded-full bg-on/10 px-4 font-mono text-[0.8125rem] text-on" data-command={props.command}>
50
+ <span class="truncate" data-field={field('command')}>{props.command}</span>
51
+ <span data-copy-label>Copy</span>
52
+ </button>
53
+ )}
54
+ {hasActions && (
55
+ <div class="flex flex-wrap gap-2.5">
56
+ {props.primary && (
57
+ <Button {...buttonLinkProps(props.primary)} variant={bandPrimary} class={onAccentClass(bandPrimary)} data-field={field('primary.label')}>
58
+ {props.primary.label}
59
+ </Button>
60
+ )}
61
+ {props.secondary && (
62
+ <Button {...buttonLinkProps(props.secondary)} variant={bandSecondary} class={onAccentClass(bandSecondary)} data-field={field('secondary.label')}>
63
+ {props.secondary.label}
64
+ </Button>
65
+ )}
66
+ </div>
67
+ )}
68
+ </div>
69
+ )}
70
+ </div>
71
+ </div>
72
+ )
73
+ }
74
+ {
75
+ section.variant === 'centered' && (
76
+ <div class="section-container text-center" data-cta>
77
+ {
78
+ props.heading && (
79
+ <h2 class="mx-auto max-w-[14ch] text-[clamp(2.75rem,1rem+6cqi,7rem)] leading-[0.92] font-semibold tracking-[-0.05em]">
80
+ <Emphasis heading={props.heading} marks={props.marks} data-field={field('heading')} />
81
+ </h2>
82
+ )
83
+ }
84
+ {props.body && <Typography as="p" size="lead" color="muted" class="mx-auto mt-5 max-w-xl" data-field={field('body')} markdown={props.body} />}
85
+ {
86
+ hasActions && (
87
+ <div class="mt-8 flex flex-wrap justify-center gap-2.5">
88
+ {props.primary && (
89
+ <Button {...buttonLinkProps(props.primary)} variant={buttonVariant(props.primary, 'primary')} size="lg" arrow data-field={field('primary.label')}>
90
+ {props.primary.label}
91
+ </Button>
92
+ )}
93
+ {props.secondary && (
94
+ <Button {...buttonLinkProps(props.secondary)} variant={buttonVariant(props.secondary, 'secondary')} size="lg" data-field={field('secondary.label')}>
95
+ {props.secondary.label}
96
+ </Button>
97
+ )}
98
+ </div>
99
+ )
100
+ }
101
+ {props.command && (
102
+ <button type="button" data-copy class="mt-6 font-mono text-[0.8125rem] tracking-[0.04em] text-muted" data-command={props.command}>
103
+ <span data-field={field('command')}>{props.command}</span>
104
+ <span data-copy-label> · Copy</span>
105
+ </button>
106
+ )}
107
+ </div>
108
+ )
109
+ }
110
+ {
111
+ section.variant === 'terminal' && (
112
+ <div class="section-container grid grid-cols-[repeat(auto-fit,minmax(min(100%,22rem),1fr))] items-center gap-[clamp(2.5rem,6cqi,5rem)]" data-cta>
113
+ {
114
+ (props.heading || props.body || hasActions) && (
115
+ <div class="flex flex-col items-start gap-6">
116
+ {props.heading && (
117
+ <h2 class="text-[clamp(2.25rem,1.2rem+4.4cqi,4.75rem)] leading-[0.95] font-semibold tracking-[-0.05em]">
118
+ <Emphasis heading={props.heading} marks={props.marks} data-field={field('heading')} />
119
+ </h2>
120
+ )}
121
+ {props.body && <Typography as="p" size="lead" color="muted" data-field={field('body')} markdown={props.body} />}
122
+ {hasActions && (
123
+ <div class="flex flex-wrap gap-2.5">
124
+ {props.primary && (
125
+ <Button {...buttonLinkProps(props.primary)} variant={buttonVariant(props.primary, 'primary')} arrow data-field={field('primary.label')}>
126
+ {props.primary.label}
127
+ </Button>
128
+ )}
129
+ {props.secondary && (
130
+ <Button {...buttonLinkProps(props.secondary)} variant={buttonVariant(props.secondary, 'secondary')} data-field={field('secondary.label')}>
131
+ {props.secondary.label}
132
+ </Button>
133
+ )}
134
+ </div>
135
+ )}
136
+ </div>
137
+ )
138
+ }
139
+ {/* A dark terminal in every tone, like the one on your machine. Nothing to print, no terminal. */}
140
+ {(props.command || (props.output ?? []).length > 0) && (<div class="overflow-hidden rounded-[1.25rem] bg-[oklch(0.17_0.012_255)] text-[oklch(0.93_0.004_250)] shadow-[0_0_0_1px_oklch(0.97_0.004_250/0.08),0_40px_80px_-40px_oklch(0.15_0.02_255/0.6)]">
141
+ <div class="flex items-center justify-between border-b border-[oklch(0.97_0.004_250/0.08)] py-3 ps-4 pe-3">
142
+ <div class="flex gap-1.5" aria-hidden="true">
143
+ <span class="size-2.5 rounded-full bg-[oklch(0.97_0.004_250/0.18)]" />
144
+ <span class="size-2.5 rounded-full bg-[oklch(0.97_0.004_250/0.18)]" />
145
+ <span class="size-2.5 rounded-full bg-[oklch(0.97_0.004_250/0.18)]" />
146
+ </div>
147
+ {props.command && (
148
+ <button
149
+ type="button"
150
+ data-copy
151
+ class="h-[1.875rem] rounded-full bg-[oklch(0.97_0.004_250/0.08)] px-3 text-[0.75rem] font-medium transition-colors hover:bg-[oklch(0.97_0.004_250/0.14)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[oklch(0.87_0.2_145)]"
152
+ aria-label="Copy command"
153
+ data-command={props.command}
154
+ >
155
+ <span data-copy-label>Copy</span>
156
+ </button>
157
+ )}
158
+ </div>
159
+ <ol class="flex flex-col gap-2.5 overflow-x-auto px-5 pt-5 pb-6 font-mono text-[clamp(0.75rem,0.7rem+0.2cqi,0.875rem)] leading-[1.6]">
160
+ {props.command && (
161
+ <li class="flex gap-3 whitespace-pre">
162
+ <span class="text-[oklch(0.87_0.2_145)] select-none" aria-hidden="true">$</span>
163
+ <span data-terminal-command data-field={field('command')}>{props.command}</span>
164
+ </li>
165
+ )}
166
+ {(props.output ?? []).map((line, lineIndex) => (
167
+ <li class="flex gap-3 whitespace-pre">
168
+ <span class="min-w-[1ch] text-[oklch(0.87_0.2_145)] select-none" aria-hidden={line.prompt ? undefined : 'true'} data-field={line.prompt ? field(`output.${lineIndex}.prompt`) : undefined}>
169
+ {line.prompt ?? ' '}
170
+ </span>
171
+ <span class="text-[oklch(0.93_0.004_250/0.45)]" data-field={field(`output.${lineIndex}.text`)}>{line.text}</span>
172
+ </li>
173
+ ))}
174
+ </ol>
175
+ </div>)}
176
+ </div>
177
+ )
178
+ }
179
+ </SectionShell>
180
+
181
+ <script>
182
+ function bindCta() {
183
+ document.querySelectorAll('[data-cta] [data-copy]').forEach((button) => {
184
+ if (!(button instanceof HTMLButtonElement) || button.dataset.bound === 'true') return
185
+ button.dataset.bound = 'true'
186
+ const label = button.querySelector('[data-copy-label]')
187
+ const original = label?.textContent ?? 'Copy'
188
+ button.addEventListener('click', async () => {
189
+ // The command as it is on the page now, so an edit made in the editor is what gets copied.
190
+ const shown = button.closest('[data-cta]')?.querySelector('[data-terminal-command]')?.textContent?.trim()
191
+ const command = shown || button.dataset.command || ''
192
+ try {
193
+ await navigator.clipboard.writeText(command)
194
+ } catch {
195
+ return
196
+ }
197
+ if (label) label.textContent = 'Copied'
198
+ window.setTimeout(() => {
199
+ if (label) label.textContent = original
200
+ }, 1600)
201
+ })
202
+ })
203
+ }
204
+ bindCta()
205
+ document.addEventListener('bearminion:preview', bindCta)
206
+ </script>
@@ -0,0 +1,49 @@
1
+ import { z } from 'zod'
2
+ import { defineSection, linkSchema, richTextSchema, textSchema, withEmphasis } from 'bearminion'
3
+ import { accent, heading } from '../shared'
4
+ import { ctaWireframe } from './wireframe'
5
+
6
+ export const ctaVariants = ['band', 'centered', 'terminal'] as const
7
+
8
+ export const ctaLineSchema = z
9
+ .object({
10
+ prompt: textSchema.optional(),
11
+ text: textSchema,
12
+ })
13
+ .strict()
14
+
15
+ export const ctaSchema = withEmphasis({
16
+ heading,
17
+ body: richTextSchema.optional(),
18
+ command: textSchema.optional(),
19
+ /** Lines the terminal variant shows under the command, such as what it prints. `prompt` is a mark before the line, such as → or ✓. */
20
+ output: z.array(ctaLineSchema).max(8).optional(),
21
+ primary: linkSchema.optional(),
22
+ secondary: linkSchema.optional(),
23
+ })
24
+
25
+ export type CtaProps = z.infer<typeof ctaSchema>
26
+
27
+ export const cta = defineSection({
28
+ type: 'cta',
29
+ label: 'Call to action',
30
+ description: 'A band with a heading and a button.',
31
+ schema: ctaSchema,
32
+ defaults: {
33
+ heading: 'Ready to get started?',
34
+ marks: accent('Ready to get started?', 'get started?'),
35
+ body: 'One sentence that repeats the main benefit and tells the reader what happens next.',
36
+ command: 'npm create astro@latest',
37
+ output: [
38
+ { text: '# pages live in content/pages' },
39
+ { text: '# site chrome lives in content/site.json' },
40
+ { text: '# production is the static build' },
41
+ ],
42
+ primary: { label: 'Primary action', href: '#' },
43
+ secondary: { label: 'Secondary action', href: '#' },
44
+ },
45
+ variants: ctaVariants,
46
+ defaultVariant: 'band',
47
+ optional: { props: ['heading', 'body', 'command', 'output', 'primary', 'secondary'], items: { output: ['prompt'] } },
48
+ wireframe: ctaWireframe,
49
+ })
@@ -0,0 +1,9 @@
1
+ import { defineWireframe } from 'bearminion'
2
+
3
+ /** Add section picker thumbnail: [left %, top %, width %, height %, kind]. */
4
+ export const ctaWireframe = defineWireframe([
5
+ [6, 16, 88, 68, 'dark'],
6
+ [12, 32, 40, 9, 'light'],
7
+ [12, 48, 30, 5, 'text'],
8
+ [66, 40, 22, 14, 'button'],
9
+ ])
@@ -0,0 +1,136 @@
1
+ ---
2
+ import { anchorAttrs } from '../../../lib/link-attrs'
3
+ import type { Section } from '../definitions'
4
+ import Typography from '../../atoms/Typography.astro'
5
+ import SectionHeader from '../../molecules/SectionHeader.astro'
6
+ import SectionShell from '../../molecules/SectionShell.astro'
7
+
8
+ interface Props {
9
+ section: Extract<Section, { type: 'faq' }>
10
+ index: number
11
+ motion?: boolean
12
+ }
13
+
14
+ const { section, index, motion = true } = Astro.props
15
+ const props = section.props
16
+ const field = (path: string) => `sections.${index}.props.${path}`
17
+ const reveal = section.motion ?? motion
18
+ ---
19
+
20
+ <SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={reveal}>
21
+ {
22
+ section.variant === 'accordion' && (
23
+ <div class="section-container">
24
+ <div class="mx-auto max-w-3xl" data-faq data-open="0">
25
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} align="center" field={field} />
26
+ <div class="mt-10 flex flex-col gap-3">
27
+ {props.items.map((item, itemIndex) => (
28
+ <div class="rounded-card-lg bg-surface px-6 ring-line" data-faq-item>
29
+ <button type="button" class="flex min-h-14 w-full items-center justify-between gap-4 py-4 text-left" data-faq-button aria-expanded={itemIndex === 0 ? 'true' : 'false'}>
30
+ <span class="text-[1.0625rem] font-medium tracking-[-0.02em]" data-field={field(`items.${itemIndex}.q`)}>{item.q}</span>
31
+ <span class="inline-flex size-8 shrink-0 items-center justify-center rounded-full text-lg transition duration-200" data-faq-icon aria-hidden="true">+</span>
32
+ </button>
33
+ <div class="pb-5" data-faq-panel hidden={itemIndex !== 0}>
34
+ <Typography as="p" size="body" color="muted" data-field={field(`items.${itemIndex}.a`)} markdown={item.a} />
35
+ </div>
36
+ </div>
37
+ ))}
38
+ </div>
39
+ </div>
40
+ </div>
41
+ )
42
+ }
43
+ {
44
+ section.variant === 'split' && (
45
+ <div class="section-container grid items-start gap-12 @min-[760px]:grid-cols-[minmax(min(100%,20rem),0.8fr)_minmax(0,1.2fr)]" data-faq data-open="0">
46
+ <div class="flex flex-col items-start gap-6">
47
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} field={field} />
48
+ {props.more && (
49
+ <Typography as="p" size="body" color="muted" data-field={field('more')}>
50
+ {props.more}
51
+ </Typography>
52
+ )}
53
+ {props.link && (
54
+ <a
55
+ {...anchorAttrs(props.link)}
56
+ class="text-[0.9375rem] font-medium text-link underline-offset-4 hover:underline"
57
+ >
58
+ <span data-field={field('link.label')}>{props.link.label}</span> <span aria-hidden="true">→</span>
59
+ </a>
60
+ )}
61
+ </div>
62
+ <div>
63
+ {props.items.map((item, itemIndex) => (
64
+ <div class="border-t border-[var(--line)]" data-faq-item>
65
+ <button type="button" class="flex min-h-16 w-full items-center justify-between gap-4 py-4 text-left" data-faq-button aria-expanded={itemIndex === 0 ? 'true' : 'false'}>
66
+ <span class="text-[1.0625rem] font-medium tracking-[-0.02em]" data-field={field(`items.${itemIndex}.q`)}>{item.q}</span>
67
+ <span class="inline-flex size-8 shrink-0 items-center justify-center rounded-full text-lg transition duration-200" data-faq-icon aria-hidden="true">+</span>
68
+ </button>
69
+ <div class="pb-5" data-faq-panel hidden={itemIndex !== 0}>
70
+ <Typography as="p" size="body" color="muted" data-field={field(`items.${itemIndex}.a`)} markdown={item.a} />
71
+ </div>
72
+ </div>
73
+ ))}
74
+ </div>
75
+ </div>
76
+ )
77
+ }
78
+ {
79
+ section.variant === 'grid' && (
80
+ <div class="section-container">
81
+ <div class="grid items-end gap-8 @min-[760px]:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
82
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} field={field} />
83
+ {props.more && (
84
+ <Typography as="p" size="lead" color="muted" data-field={field('more')}>
85
+ {props.more}
86
+ </Typography>
87
+ )}
88
+ </div>
89
+ <ul class="mt-12 grid grid-cols-[repeat(auto-fit,minmax(min(100%,20rem),1fr))] gap-x-8 gap-y-10">
90
+ {props.items.map((item, itemIndex) => (
91
+ <li class="border-t border-[var(--line)] pt-5">
92
+ <p class="font-mono text-[0.75rem] tracking-[0.08em] text-muted">{String(itemIndex + 1).padStart(2, '0')}</p>
93
+ <h3 class="mt-3 text-[1.125rem] font-semibold tracking-[-0.02em]" data-field={field(`items.${itemIndex}.q`)}>{item.q}</h3>
94
+ <Typography as="p" size="body" color="muted" class="mt-2" data-field={field(`items.${itemIndex}.a`)} markdown={item.a} />
95
+ </li>
96
+ ))}
97
+ </ul>
98
+ </div>
99
+ )
100
+ }
101
+ </SectionShell>
102
+
103
+ <script>
104
+ function bindFaq() {
105
+ document.querySelectorAll('[data-faq]').forEach((root) => {
106
+ if (!(root instanceof HTMLElement) || root.dataset.bound === 'true') return
107
+ root.dataset.bound = 'true'
108
+ const items = [...root.querySelectorAll('[data-faq-item]')]
109
+ const paint = (openIndex: number) => {
110
+ root.dataset.open = String(openIndex)
111
+ items.forEach((item, index) => {
112
+ const button = item.querySelector('[data-faq-button]')
113
+ const panel = item.querySelector('[data-faq-panel]')
114
+ const icon = item.querySelector('[data-faq-icon]')
115
+ const open = index === openIndex
116
+ if (button instanceof HTMLButtonElement) button.setAttribute('aria-expanded', String(open))
117
+ if (panel instanceof HTMLElement) panel.hidden = !open
118
+ if (icon instanceof HTMLElement) {
119
+ icon.style.transform = open ? 'rotate(45deg)' : 'none'
120
+ icon.style.background = open ? 'var(--accent)' : 'transparent'
121
+ icon.style.color = open ? 'var(--on)' : 'inherit'
122
+ }
123
+ })
124
+ }
125
+ paint(Number(root.dataset.open ?? '0'))
126
+ items.forEach((item, index) => {
127
+ item.querySelector('[data-faq-button]')?.addEventListener('click', () => {
128
+ const current = Number(root.dataset.open ?? '0')
129
+ paint(current === index ? -1 : index)
130
+ })
131
+ })
132
+ })
133
+ }
134
+ bindFaq()
135
+ document.addEventListener('bearminion:preview', bindFaq)
136
+ </script>
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod'
2
+ import { defineSection, linkSchema, richTextSchema, textSchema, withEmphasis, type CountRule } from 'bearminion'
3
+ import { DEFAULT_CONTACT_ANCHOR, accent, eyebrow, heading } from '../shared'
4
+ import { faqWireframe } from './wireframe'
5
+
6
+ export const faqVariants = ['accordion', 'split', 'grid'] as const
7
+
8
+ /** Four to eight questions. */
9
+ export const faqCounts = {
10
+ items: { recommended: '4–8', min: 4, max: 8 },
11
+ } as const satisfies Record<string, CountRule>
12
+
13
+ export const faqItemSchema = z
14
+ .object({
15
+ q: textSchema,
16
+ a: richTextSchema,
17
+ })
18
+ .strict()
19
+
20
+ export const faqSchema = withEmphasis({
21
+ eyebrow,
22
+ heading,
23
+ more: textSchema.optional(),
24
+ /** The link under the heading in the split layout, such as one to the contact section. */
25
+ link: linkSchema.optional(),
26
+ items: z.array(faqItemSchema).min(faqCounts.items.min).max(faqCounts.items.max),
27
+ })
28
+
29
+ export type FaqItem = z.infer<typeof faqItemSchema>
30
+ export type FaqProps = z.infer<typeof faqSchema>
31
+
32
+ export const faq = defineSection({
33
+ type: 'faq',
34
+ label: 'FAQ',
35
+ description: 'Questions that open to show answers.',
36
+ schema: faqSchema,
37
+ defaults: {
38
+ eyebrow: 'FAQ',
39
+ heading: 'Questions, answered plainly.',
40
+ marks: accent('Questions, answered plainly.', 'plainly.'),
41
+ link: { label: 'Contact us', href: `#${DEFAULT_CONTACT_ANCHOR}` },
42
+ items: [
43
+ { q: 'What is included?', a: 'Answer the question people ask most before they buy, in two or three sentences.' },
44
+ { q: 'How long does it take to get started?', a: 'Give a realistic time frame and say what the reader needs to have ready.' },
45
+ { q: 'Can I change plans later?', a: 'Explain how upgrades, downgrades and billing changes work.' },
46
+ { q: 'How do I get help?', a: 'List the ways to reach you and how quickly people can expect a reply.' },
47
+ ],
48
+ },
49
+ variants: faqVariants,
50
+ defaultVariant: 'accordion',
51
+ optional: { props: ['eyebrow', 'heading', 'more', 'link'] },
52
+ counts: faqCounts,
53
+ wireframe: faqWireframe,
54
+ })
@@ -0,0 +1,19 @@
1
+ import { defineWireframe } from 'bearminion'
2
+
3
+ /** Add section picker thumbnail: [left %, top %, width %, height %, kind]. */
4
+ export const faqWireframe = defineWireframe([
5
+ [8, 14, 26, 8, 'title'],
6
+ [8, 28, 22, 5, 'text'],
7
+ [42, 12, 50, 13, 'card'],
8
+ [42, 31, 50, 13, 'card'],
9
+ [42, 50, 50, 13, 'card'],
10
+ [42, 69, 50, 13, 'card'],
11
+ [45, 16, 26, 5, 'title'],
12
+ [45, 35, 22, 5, 'title'],
13
+ [45, 54, 28, 5, 'title'],
14
+ [45, 73, 20, 5, 'title'],
15
+ [86, 16, 3, 5, 'text'],
16
+ [86, 35, 3, 5, 'text'],
17
+ [86, 54, 3, 5, 'text'],
18
+ [86, 73, 3, 5, 'text'],
19
+ ])
@@ -0,0 +1,146 @@
1
+ ---
2
+ import type { Section } from '../definitions'
3
+ import Button from '../../atoms/Button.astro'
4
+ import { buttonLinkProps, buttonVariant } from '../../../lib/link-attrs'
5
+ import Typography from '../../atoms/Typography.astro'
6
+ import MediaFrame from '../../molecules/MediaFrame.astro'
7
+ import SectionHeader from '../../molecules/SectionHeader.astro'
8
+ import SectionShell from '../../molecules/SectionShell.astro'
9
+ import { cn } from '../../../lib/cn'
10
+
11
+ interface Props {
12
+ section: Extract<Section, { type: 'features' }>
13
+ index: number
14
+ motion?: boolean
15
+ }
16
+
17
+ const { section, index, motion = true } = Astro.props
18
+ const props = section.props
19
+ const field = (path: string) => `sections.${index}.props.${path}`
20
+ const reveal = section.motion ?? motion
21
+ const wideFourth = props.items.length === 4
22
+ /** At two columns, an even count leaves the last card alone on its row, so it spans the row with its text beside the picture. */
23
+ const spanLast = (itemIndex: number) => !wideFourth && itemIndex === props.items.length - 1 && props.items.length % 2 === 0
24
+ ---
25
+
26
+ <SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={reveal}>
27
+ {
28
+ section.variant === 'cards' && (
29
+ <div class="section-container">
30
+ {
31
+ (props.eyebrow || props.heading || props.intro) && (
32
+ <div class="grid items-end gap-8 @min-[760px]:grid-cols-[minmax(0,1.1fr)_minmax(0,0.9fr)]">
33
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} field={field} />
34
+ {props.intro && <Typography as="p" size="lead" color="muted" data-field={field('intro')} markdown={props.intro} />}
35
+ </div>
36
+ )
37
+ }
38
+ <ul class="mt-12 grid grid-cols-[repeat(auto-fit,minmax(min(100%,15rem),1fr))] gap-4">
39
+ {props.items.map((item, itemIndex) => (
40
+ <li class="flex flex-col gap-4 rounded-card-lg bg-surface p-6 ring-line transition duration-200 hover:-translate-y-1 hover:shadow-[0_24px_40px_-28px_oklch(0.2_0.02_255/0.4)]">
41
+ {!item.image?.hidden && (
42
+ <MediaFrame
43
+ src={item.image?.src}
44
+ alt={item.image?.alt ?? item.title}
45
+ aspectClass="aspect-[4/3]"
46
+ fit={item.image?.fit} position={item.image?.position} data-field={field(`items.${itemIndex}.image.alt`)}
47
+ />
48
+ )}
49
+ <p class="font-mono text-[0.6875rem] tracking-[0.08em] text-muted">{String(itemIndex + 1).padStart(2, '0')}</p>
50
+ <Typography as="h3" size="h3" data-field={field(`items.${itemIndex}.title`)}>
51
+ {item.title}
52
+ </Typography>
53
+ {item.description && <Typography as="p" size="body" color="muted" data-field={field(`items.${itemIndex}.description`)} markdown={item.description} />}
54
+ </li>
55
+ ))}
56
+ </ul>
57
+ </div>
58
+ )
59
+ }
60
+ {
61
+ section.variant === 'list' && (
62
+ <div class="section-container grid items-start gap-12 @min-[880px]:grid-cols-[minmax(min(100%,22rem),1fr)_minmax(0,1.2fr)]">
63
+ {
64
+ (props.eyebrow || props.heading || props.intro || props.link) && (
65
+ <div class="flex flex-col items-start gap-6 @min-[880px]:sticky @min-[880px]:top-28">
66
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} intro={props.intro} field={field} />
67
+ {props.link && (
68
+ <Button {...buttonLinkProps(props.link)} variant={buttonVariant(props.link, 'text')} arrow data-field={field('link.label')}>
69
+ {props.link.label}
70
+ </Button>
71
+ )}
72
+ </div>
73
+ )
74
+ }
75
+ <ol>
76
+ {props.items.map((item, itemIndex) => (
77
+ <li class="grid grid-cols-[auto_1fr] gap-6 border-t border-[var(--line)] py-6">
78
+ <span class="font-mono text-[0.75rem] tracking-[0.08em] text-muted">{String(itemIndex + 1).padStart(2, '0')}</span>
79
+ <div>
80
+ <Typography as="h3" size="h3" data-field={field(`items.${itemIndex}.title`)}>
81
+ {item.title}
82
+ </Typography>
83
+ {item.description && <Typography as="p" size="body" color="muted" class="mt-2" data-field={field(`items.${itemIndex}.description`)} markdown={item.description} />}
84
+ </div>
85
+ </li>
86
+ ))}
87
+ </ol>
88
+ </div>
89
+ )
90
+ }
91
+ {
92
+ section.variant === 'bento' && (
93
+ <div class="section-container">
94
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} intro={props.intro} align="center" field={field} class="mx-auto max-w-3xl" />
95
+ <ul class="mt-[clamp(2.5rem,4cqi,4rem)] grid grid-cols-1 gap-4 @min-[620px]:grid-cols-2 @min-[960px]:grid-cols-3">
96
+ {props.items.map((item, itemIndex) => (
97
+ <li
98
+ class:list={[
99
+ 'flex min-h-72 flex-col gap-4 rounded-card-lg bg-surface p-2 ring-line',
100
+ // The first card is the big one: two columns, and two rows at three columns.
101
+ itemIndex === 0 && '@min-[620px]:col-span-2 @min-[620px]:min-h-[26rem] @min-[960px]:row-span-2',
102
+ // Four cards: the fourth spans the row, with its text beside the picture at three columns.
103
+ wideFourth &&
104
+ itemIndex === 3 &&
105
+ '@min-[620px]:col-span-2 @min-[960px]:col-span-3 @min-[960px]:flex-row-reverse @min-[960px]:items-center',
106
+ // Any other count at two columns: the last card spans the row when it would sit alone, picture beside text.
107
+ spanLast(itemIndex) && '@min-[620px]:@max-[959px]:col-span-2 @min-[620px]:@max-[959px]:flex-row-reverse @min-[620px]:@max-[959px]:items-center',
108
+ ]}
109
+ >
110
+ {!item.image?.hidden && (
111
+ <MediaFrame
112
+ src={item.image?.src}
113
+ alt={item.image?.alt ?? item.title}
114
+ aspectClass={cn(
115
+ 'min-h-36 flex-1',
116
+ wideFourth && itemIndex === 3 && '@min-[960px]:self-stretch',
117
+ spanLast(itemIndex) && '@min-[620px]:@max-[959px]:self-stretch',
118
+ )}
119
+ roundedClass="rounded-2xl"
120
+ class="p-3"
121
+ fit={item.image?.fit}
122
+ position={item.image?.position}
123
+ data-field={field(`items.${itemIndex}.image.alt`)}
124
+ />
125
+ )}
126
+ <div
127
+ class:list={[
128
+ 'flex flex-col gap-1.5 px-2 pt-1 pb-2',
129
+ wideFourth && itemIndex === 3 && '@min-[960px]:flex-1 @min-[960px]:px-6',
130
+ spanLast(itemIndex) && '@min-[620px]:@max-[959px]:flex-1 @min-[620px]:@max-[959px]:px-6',
131
+ ]}
132
+ >
133
+ <Typography as="h3" size="h3" data-field={field(`items.${itemIndex}.title`)}>
134
+ {item.title}
135
+ </Typography>
136
+ {item.description && (
137
+ <Typography as="p" size="body" color="muted" class="max-w-[30rem]" data-field={field(`items.${itemIndex}.description`)} markdown={item.description} />
138
+ )}
139
+ </div>
140
+ </li>
141
+ ))}
142
+ </ul>
143
+ </div>
144
+ )
145
+ }
146
+ </SectionShell>