bearminion 1.8.0 → 1.9.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 (86) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/astro.js +5 -5
  3. package/dist/cli.js +762 -25
  4. package/dist/content.js +2 -2
  5. package/dist/hash-BeBymBO1.js +59 -0
  6. package/dist/index.js +4 -4
  7. package/dist/marks-DPBilumg.js +174 -0
  8. package/dist/marks.js +1 -174
  9. package/dist/{page-NOFVEqn1.js → page-X-WnOu7-.js} +1 -1
  10. package/dist/{preview--S1QUrMM.js → preview-B_88I5Jm.js} +1 -1
  11. package/dist/{reload-BPkPoQ-P.js → reload-Dkp3xC0l.js} +1 -1
  12. package/dist/rich-text-70hddxMC.js +403 -0
  13. package/dist/rich-text.js +1 -403
  14. package/dist/{sections-manifest-CU-xBjMi.js → sections-manifest-CO9QfJPG.js} +1 -1
  15. package/dist/{theme-DFjHjgFO.js → theme-Dv7_7B56.js} +2 -2
  16. package/dist/ui/mount.js +20 -7
  17. package/package.json +4 -1
  18. package/registry/default/files/src/components/atoms/Button.astro +64 -0
  19. package/registry/default/files/src/components/atoms/Emphasis.astro +24 -0
  20. package/registry/default/files/src/components/atoms/Image.astro +78 -0
  21. package/registry/default/files/src/components/atoms/Typography.astro +53 -0
  22. package/registry/default/files/src/components/atoms/button.ts +31 -0
  23. package/registry/default/files/src/components/atoms/image.ts +34 -0
  24. package/registry/default/files/src/components/atoms/options.ts +39 -0
  25. package/registry/default/files/src/components/atoms/typography.ts +64 -0
  26. package/registry/default/files/src/components/molecules/CommandLine.astro +109 -0
  27. package/registry/default/files/src/components/molecules/MediaFrame.astro +71 -0
  28. package/registry/default/files/src/components/molecules/Pill.astro +24 -0
  29. package/registry/default/files/src/components/molecules/SectionHeader.astro +63 -0
  30. package/registry/default/files/src/components/molecules/SectionShell.astro +33 -0
  31. package/registry/default/files/src/components/sections/contact/Contact.astro +231 -0
  32. package/registry/default/files/src/components/sections/contact/definition.ts +52 -0
  33. package/registry/default/files/src/components/sections/contact/form.ts +313 -0
  34. package/registry/default/files/src/components/sections/contact/wireframe.ts +15 -0
  35. package/registry/default/files/src/components/sections/cta/Cta.astro +206 -0
  36. package/registry/default/files/src/components/sections/cta/definition.ts +49 -0
  37. package/registry/default/files/src/components/sections/cta/wireframe.ts +9 -0
  38. package/registry/default/files/src/components/sections/faq/Faq.astro +136 -0
  39. package/registry/default/files/src/components/sections/faq/definition.ts +54 -0
  40. package/registry/default/files/src/components/sections/faq/wireframe.ts +19 -0
  41. package/registry/default/files/src/components/sections/features/Features.astro +146 -0
  42. package/registry/default/files/src/components/sections/features/definition.ts +54 -0
  43. package/registry/default/files/src/components/sections/features/wireframe.ts +19 -0
  44. package/registry/default/files/src/components/sections/gallery/Gallery.astro +128 -0
  45. package/registry/default/files/src/components/sections/gallery/definition.ts +59 -0
  46. package/registry/default/files/src/components/sections/gallery/lightbox.ts +159 -0
  47. package/registry/default/files/src/components/sections/gallery/wireframe.ts +12 -0
  48. package/registry/default/files/src/components/sections/hero/Hero.astro +185 -0
  49. package/registry/default/files/src/components/sections/hero/HeroBadge.astro +26 -0
  50. package/registry/default/files/src/components/sections/hero/definition.ts +74 -0
  51. package/registry/default/files/src/components/sections/hero/wireframe.ts +12 -0
  52. package/registry/default/files/src/components/sections/logo-strip/LogoStrip.astro +107 -0
  53. package/registry/default/files/src/components/sections/logo-strip/definition.ts +30 -0
  54. package/registry/default/files/src/components/sections/logo-strip/wireframe.ts +11 -0
  55. package/registry/default/files/src/components/sections/media/Media.astro +118 -0
  56. package/registry/default/files/src/components/sections/media/MediaPlayer.astro +176 -0
  57. package/registry/default/files/src/components/sections/media/definition.ts +77 -0
  58. package/registry/default/files/src/components/sections/media/source.ts +3 -0
  59. package/registry/default/files/src/components/sections/media/wireframe.ts +9 -0
  60. package/registry/default/files/src/components/sections/pricing/Pricing.astro +210 -0
  61. package/registry/default/files/src/components/sections/pricing/definition.ts +62 -0
  62. package/registry/default/files/src/components/sections/pricing/wireframe.ts +18 -0
  63. package/registry/default/files/src/components/sections/shared.ts +13 -0
  64. package/registry/default/files/src/components/sections/stats/Stats.astro +110 -0
  65. package/registry/default/files/src/components/sections/stats/definition.ts +41 -0
  66. package/registry/default/files/src/components/sections/stats/wireframe.ts +15 -0
  67. package/registry/default/files/src/components/sections/steps/Steps.astro +139 -0
  68. package/registry/default/files/src/components/sections/steps/definition.ts +62 -0
  69. package/registry/default/files/src/components/sections/steps/icons.ts +27 -0
  70. package/registry/default/files/src/components/sections/steps/wireframe.ts +16 -0
  71. package/registry/default/files/src/components/sections/testimonials/Testimonials.astro +172 -0
  72. package/registry/default/files/src/components/sections/testimonials/definition.ts +42 -0
  73. package/registry/default/files/src/components/sections/testimonials/wireframe.ts +21 -0
  74. package/registry/default/files/src/components/sections/text/Text.astro +43 -0
  75. package/registry/default/files/src/components/sections/text/definition.ts +36 -0
  76. package/registry/default/files/src/components/sections/text/wireframe.ts +12 -0
  77. package/registry/default/files/src/components/sections/text-image/TextImage.astro +107 -0
  78. package/registry/default/files/src/components/sections/text-image/definition.ts +39 -0
  79. package/registry/default/files/src/components/sections/text-image/wireframe.ts +12 -0
  80. package/registry/default/files/src/lib/assets.ts +13 -0
  81. package/registry/default/files/src/lib/cn.ts +6 -0
  82. package/registry/default/files/src/lib/contact-form.ts +97 -0
  83. package/registry/default/files/src/lib/hidden-text.ts +32 -0
  84. package/registry/default/files/src/lib/image-url.ts +38 -0
  85. package/registry/default/files/src/lib/link-attrs.ts +74 -0
  86. package/registry/default/registry.json +670 -0
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod'
2
+ import { defineSection, imageSchema, linkSchema, richTextSchema, textSchema, withEmphasis, type CountRule } from 'bearminion'
3
+ import { accent, eyebrow, heading } from '../shared'
4
+ import { featuresWireframe } from './wireframe'
5
+
6
+ export const featuresVariants = ['cards', 'list', 'bento'] as const
7
+
8
+ /** Three to six cards. In the bento grid, four keeps a wide fourth card; any other count fills rows of three. */
9
+ export const featuresCounts = {
10
+ items: { recommended: '3–6; 4 or 6 fill the bento grid best', min: 3, max: 6 },
11
+ } as const satisfies Record<string, CountRule>
12
+
13
+ export const featureItemSchema = z
14
+ .object({
15
+ title: textSchema,
16
+ description: richTextSchema.optional(),
17
+ image: imageSchema.optional(),
18
+ })
19
+ .strict()
20
+
21
+ export const featuresSchema = withEmphasis({
22
+ eyebrow,
23
+ heading,
24
+ intro: richTextSchema.optional(),
25
+ link: linkSchema.optional(),
26
+ items: z.array(featureItemSchema).min(featuresCounts.items.min).max(featuresCounts.items.max),
27
+ })
28
+
29
+ export type FeatureItem = z.infer<typeof featureItemSchema>
30
+ export type FeaturesProps = z.infer<typeof featuresSchema>
31
+
32
+ export const features = defineSection({
33
+ type: 'features',
34
+ label: 'Features',
35
+ description: 'Grid of feature cards with titles and text.',
36
+ schema: featuresSchema,
37
+ defaults: {
38
+ eyebrow: 'Features',
39
+ heading: 'Reasons to choose you',
40
+ marks: accent('Reasons to choose you', 'choose you'),
41
+ intro: 'Introduce the list in a sentence. Each card takes a short title and a description.',
42
+ items: [
43
+ { title: 'First benefit', description: 'Describe one benefit in a sentence or two. Lead with what the reader gets.' },
44
+ { title: 'Second benefit', description: 'Keep each description about the same length so the cards line up.' },
45
+ { title: 'Third benefit', description: 'Name a concrete outcome, a number or a time saved.' },
46
+ { title: 'Fourth benefit', description: 'Close with the point that removes the last doubt.' },
47
+ ],
48
+ },
49
+ variants: featuresVariants,
50
+ defaultVariant: 'cards',
51
+ optional: { props: ['eyebrow', 'heading', 'intro', 'link'], items: { items: ['description', 'image'] } },
52
+ counts: featuresCounts,
53
+ wireframe: featuresWireframe,
54
+ })
@@ -0,0 +1,19 @@
1
+ import { defineWireframe } from 'bearminion'
2
+
3
+ /** Add section picker thumbnail: [left %, top %, width %, height %, kind]. */
4
+ export const featuresWireframe = defineWireframe([
5
+ [8, 12, 34, 8, 'title'],
6
+ [8, 24, 24, 5, 'text'],
7
+ [8, 40, 26, 48, 'card'],
8
+ [37, 40, 26, 48, 'card'],
9
+ [66, 40, 26, 48, 'card'],
10
+ [11, 46, 6, 10, 'block'],
11
+ [40, 46, 6, 10, 'block'],
12
+ [69, 46, 6, 10, 'block'],
13
+ [11, 64, 18, 5, 'title'],
14
+ [40, 64, 18, 5, 'title'],
15
+ [69, 64, 18, 5, 'title'],
16
+ [11, 74, 20, 4, 'text'],
17
+ [40, 74, 20, 4, 'text'],
18
+ [69, 74, 20, 4, 'text'],
19
+ ])
@@ -0,0 +1,128 @@
1
+ ---
2
+ import type { Section } from '../definitions'
3
+ import Typography from '../../atoms/Typography.astro'
4
+ import MediaFrame from '../../molecules/MediaFrame.astro'
5
+ import SectionHeader from '../../molecules/SectionHeader.astro'
6
+ import SectionShell from '../../molecules/SectionShell.astro'
7
+ import { isRemote, resolveLocalAsset } from '../../../lib/assets'
8
+ import { imageUrl } from '../../../lib/image-url'
9
+ import { cn } from '../../../lib/cn'
10
+
11
+ interface Props {
12
+ section: Extract<Section, { type: 'gallery' }>
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 images = props.images.filter((image) => !image.hidden)
22
+ const featured = section.variant === 'featured'
23
+ const masonry = section.variant === 'masonry'
24
+
25
+ // Static class names, so Tailwind sees them.
26
+ const gridColumns = {
27
+ '2': 'grid-cols-1 @min-[560px]:grid-cols-2',
28
+ '3': 'grid-cols-1 @min-[560px]:grid-cols-2 @min-[900px]:grid-cols-3',
29
+ '4': 'grid-cols-2 @min-[700px]:grid-cols-3 @min-[1000px]:grid-cols-4',
30
+ } as const
31
+ const masonryColumns = {
32
+ '2': 'columns-1 @min-[560px]:columns-2',
33
+ '3': 'columns-1 @min-[560px]:columns-2 @min-[900px]:columns-3',
34
+ '4': 'columns-2 @min-[700px]:columns-3 @min-[1000px]:columns-4',
35
+ } as const
36
+
37
+ /** The index of an image in the section's full list, so the editor's field paths stay right when some are hidden. */
38
+ const pathIndex = (image: (typeof images)[number]) => props.images.indexOf(image)
39
+ const aspect = (position: number) => {
40
+ if (featured && position === 0) return 'aspect-[4/3] @min-[900px]:aspect-auto @min-[900px]:h-full'
41
+ if (masonry) return position % 3 === 0 ? 'aspect-[3/4]' : position % 3 === 1 ? 'aspect-[4/3]' : 'aspect-square'
42
+ return 'aspect-[4/3]'
43
+ }
44
+ const tileClass = (position: number) =>
45
+ cn(featured && position === 0 && '@min-[900px]:col-span-2 @min-[900px]:row-span-2', masonry && 'mb-4 break-inside-avoid')
46
+
47
+ /** A picture the lightbox can show: a real file or address, not the placeholder. */
48
+ const viewable = (src: string) => src !== 'placeholder' && (isRemote(src) || Boolean(resolveLocalAsset(src)) || src.replace(/^\//, '').startsWith('src/assets/'))
49
+
50
+ // The large file each link points at. With JavaScript off the link opens it; with JavaScript on it is what the lightbox loads.
51
+ const larges = await Promise.all(images.map((image) => (props.lightbox && viewable(image.src) ? imageUrl(image) : undefined)))
52
+ const lightbox = props.lightbox && larges.some(Boolean)
53
+ ---
54
+
55
+ <SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={reveal}>
56
+ <div class="section-container flex flex-col gap-[clamp(2rem,4cqi,3.5rem)]">
57
+ <SectionHeader eyebrow={props.eyebrow} heading={props.heading} marks={props.marks} size="h2-md" field={field} class="gap-5" />
58
+ {props.body && <Typography as="div" size="lead" color="muted" class="max-w-[40rem]" data-field={field('body')} markdown={props.body} />}
59
+ <ul
60
+ class={cn(
61
+ masonry ? masonryColumns[props.columns] : gridColumns[props.columns],
62
+ masonry ? 'gap-x-4' : cn('grid gap-4', featured && '@min-[900px]:auto-rows-fr'),
63
+ )}
64
+ >
65
+ {
66
+ images.map((image, position) => {
67
+ const frame = (
68
+ <MediaFrame
69
+ src={image.src}
70
+ alt={image.alt}
71
+ aspectClass={aspect(position)}
72
+ fit={masonry ? 'auto' : image.fit}
73
+ position={image.position}
74
+ class={cn(props.frame && 'border border-line bg-surface', larges[position] && 'transition-transform duration-300 hover:scale-[1.01] motion-reduce:transition-none')}
75
+ data-field={field(`images.${pathIndex(image)}.alt`)}
76
+ />
77
+ )
78
+ return (
79
+ <li class={tileClass(position)}>
80
+ {larges[position] ? (
81
+ <a
82
+ href={larges[position]}
83
+ class="block size-full cursor-zoom-in rounded-card-lg focus-visible:outline-offset-2"
84
+ data-gallery-open
85
+ data-alt={image.alt}
86
+ data-caption={image.caption}
87
+ aria-label={`View larger: ${image.alt}`}
88
+ >
89
+ {frame}
90
+ </a>
91
+ ) : (
92
+ frame
93
+ )}
94
+ </li>
95
+ )
96
+ })
97
+ }
98
+ </ul>
99
+ </div>
100
+ {
101
+ lightbox && (
102
+ <dialog class="bm-lightbox" aria-label={props.heading ? `${props.heading}: pictures` : 'Pictures'} data-gallery-dialog>
103
+ <div class="bm-lightbox-stage" data-gallery-stage>
104
+ <button type="button" class="bm-lightbox-close" aria-label="Close" data-gallery-close>
105
+ <svg viewBox="0 0 24 24" aria-hidden="true" class="bm-lightbox-icon"><path d="M6 6l12 12M18 6L6 18" /></svg>
106
+ </button>
107
+ <p class="bm-lightbox-counter" data-gallery-counter aria-hidden="true" />
108
+ <button type="button" class="bm-lightbox-nav bm-lightbox-prev" aria-label="Previous picture" data-gallery-step="-1">
109
+ <svg viewBox="0 0 24 24" aria-hidden="true" class="bm-lightbox-icon"><path d="M14.5 5.5L8 12l6.5 6.5" /></svg>
110
+ </button>
111
+ <figure class="bm-lightbox-figure" data-gallery-figure>
112
+ <img class="bm-lightbox-image" alt="" data-gallery-image decoding="async" />
113
+ <figcaption class="bm-lightbox-caption" data-gallery-caption hidden />
114
+ </figure>
115
+ <button type="button" class="bm-lightbox-nav bm-lightbox-next" aria-label="Next picture" data-gallery-step="1">
116
+ <svg viewBox="0 0 24 24" aria-hidden="true" class="bm-lightbox-icon"><path d="M9.5 5.5L16 12l-6.5 6.5" /></svg>
117
+ </button>
118
+ <p class="sr-only" role="status" aria-live="polite" data-gallery-status />
119
+ </div>
120
+ </dialog>
121
+ )
122
+ }
123
+ </SectionShell>
124
+
125
+ <script>
126
+ import { initGalleries } from './lightbox'
127
+ initGalleries()
128
+ </script>
@@ -0,0 +1,59 @@
1
+ import { z } from 'zod'
2
+ import { defineSection, imageSchema, richTextSchema, textSchema, withEmphasis } from 'bearminion'
3
+ import { accent, eyebrow, heading } from '../shared'
4
+ import { galleryWireframe } from './wireframe'
5
+
6
+ export const galleryVariants = ['grid', 'masonry', 'featured'] as const
7
+ export const galleryColumns = ['2', '3', '4'] as const
8
+
9
+ export const galleryCounts = { images: { recommended: '6 to 12', min: 1, max: 24 } } as const
10
+
11
+ /**
12
+ * A gallery picture needs a description: it is the only thing a screen reader or a failed load shows. The optional
13
+ * `caption` is for everyone else: it shows under the picture in the lightbox.
14
+ */
15
+ export const galleryImageSchema = imageSchema.extend({
16
+ alt: z.string().min(1, 'Describe the picture'),
17
+ caption: textSchema.optional(),
18
+ })
19
+
20
+ export const gallerySchema = withEmphasis({
21
+ eyebrow,
22
+ heading,
23
+ body: richTextSchema.optional(),
24
+ images: z.array(galleryImageSchema).min(galleryCounts.images.min).max(galleryCounts.images.max),
25
+ /** Pictures per row on a wide screen. Fewer on narrow ones. */
26
+ columns: z.enum(galleryColumns).default('3'),
27
+ /** Off: pictures stay where they are. On: a click opens the picture large, with arrows to move through the rest. */
28
+ lightbox: z.boolean().default(true),
29
+ /** On: each picture sits in a bordered box, so a picture that does not fill its frame still shows where the frame ends. */
30
+ frame: z.boolean().default(false),
31
+ })
32
+
33
+ export type GalleryProps = z.infer<typeof gallerySchema>
34
+
35
+ export const gallery = defineSection({
36
+ type: 'gallery',
37
+ label: 'Gallery',
38
+ description: 'A set of pictures. Click one to see it large, with captions, arrows and swipe.',
39
+ schema: gallerySchema,
40
+ defaults: {
41
+ eyebrow: 'Gallery',
42
+ heading: 'A few pictures say it faster.',
43
+ marks: accent('A few pictures say it faster.', 'faster.'),
44
+ images: [1, 2, 3, 4, 5, 6].map((n) => ({ src: 'placeholder', alt: `Picture ${n}` })),
45
+ columns: '3',
46
+ lightbox: true,
47
+ frame: false,
48
+ },
49
+ variants: galleryVariants,
50
+ defaultVariant: 'grid',
51
+ options: [
52
+ { name: 'columns', label: 'Pictures per row', type: 'enum', choices: galleryColumns, default: '3' },
53
+ { name: 'lightbox', label: 'Open pictures large on click', type: 'boolean', default: true },
54
+ { name: 'frame', label: 'Draw a box around each picture', type: 'boolean', default: false },
55
+ ],
56
+ optional: { props: ['eyebrow', 'heading', 'body'], items: { images: ['caption'] } },
57
+ counts: galleryCounts,
58
+ wireframe: galleryWireframe,
59
+ })
@@ -0,0 +1,159 @@
1
+ /**
2
+ * The gallery lightbox. Each picture in the page is a link to its large file, so with JavaScript off a click simply
3
+ * opens the picture. With it on, a click opens a native <dialog> that shows one picture at a time. The large file is
4
+ * requested when the dialog opens (and the pictures next to it, so the arrows feel instant), never before.
5
+ */
6
+
7
+ /** The index after moving `step` places from `from` in a list of `count`, wrapping at both ends. */
8
+ export function stepIndex(from: number, step: number, count: number): number {
9
+ if (count <= 0) return 0
10
+ return (((from + step) % count) + count) % count
11
+ }
12
+
13
+ /** Which way a finger moved: a mostly horizontal drag of at least `threshold` px. Positive is toward the next picture. */
14
+ export function swipeStep(dx: number, dy: number, threshold = 48): -1 | 0 | 1 {
15
+ if (Math.abs(dx) < threshold || Math.abs(dx) < Math.abs(dy) * 1.25) return 0
16
+ return dx < 0 ? 1 : -1
17
+ }
18
+
19
+ interface Item {
20
+ src: string
21
+ alt: string
22
+ caption: string
23
+ opener: HTMLElement
24
+ }
25
+
26
+ function itemsOf(section: Element): Item[] {
27
+ return [...section.querySelectorAll<HTMLElement>('[data-gallery-open]')].map((opener) => ({
28
+ src: opener.getAttribute('href') ?? '',
29
+ alt: opener.dataset.alt ?? '',
30
+ caption: opener.dataset.caption ?? '',
31
+ opener,
32
+ }))
33
+ }
34
+
35
+ class Lightbox {
36
+ private items: Item[] = []
37
+ private index = 0
38
+ private touch: { x: number; y: number } | null = null
39
+ private readonly image: HTMLImageElement
40
+ private readonly caption: HTMLElement
41
+ private readonly counter: HTMLElement
42
+ private readonly status: HTMLElement
43
+ private readonly figure: HTMLElement
44
+
45
+ constructor(private readonly dialog: HTMLDialogElement) {
46
+ this.image = this.part<HTMLImageElement>('[data-gallery-image]')
47
+ this.caption = this.part('[data-gallery-caption]')
48
+ this.counter = this.part('[data-gallery-counter]')
49
+ this.status = this.part('[data-gallery-status]')
50
+ this.figure = this.part('[data-gallery-figure]')
51
+
52
+ dialog.addEventListener('click', (event) => {
53
+ const target = event.target as HTMLElement
54
+ if (target.closest('[data-gallery-close]')) return this.close()
55
+ const step = target.closest<HTMLElement>('[data-gallery-step]')
56
+ if (step) return this.go(Number(step.dataset.galleryStep))
57
+ // The backdrop and the empty space around the picture close it; the picture and its caption do not.
58
+ if (target === dialog || target === this.figure || target.hasAttribute('data-gallery-stage')) this.close()
59
+ })
60
+ dialog.addEventListener('keydown', (event) => {
61
+ if (event.key === 'ArrowLeft') this.go(-1)
62
+ else if (event.key === 'ArrowRight') this.go(1)
63
+ else if (event.key === 'Home') this.show(0)
64
+ else if (event.key === 'End') this.show(this.items.length - 1)
65
+ else return
66
+ event.preventDefault()
67
+ })
68
+ // The dialog's own Escape and the close button both end here, so focus always goes back to the picture opened.
69
+ dialog.addEventListener('close', () => this.items[this.index]?.opener.focus({ preventScroll: true }))
70
+ dialog.addEventListener('pointerdown', (event) => {
71
+ if (event.pointerType !== 'touch') return
72
+ this.touch = { x: event.clientX, y: event.clientY }
73
+ })
74
+ dialog.addEventListener('pointerup', (event) => {
75
+ if (!this.touch) return
76
+ const step = swipeStep(event.clientX - this.touch.x, event.clientY - this.touch.y)
77
+ this.touch = null
78
+ if (step !== 0) this.go(step)
79
+ })
80
+ dialog.addEventListener('pointercancel', () => {
81
+ this.touch = null
82
+ })
83
+ this.image.addEventListener('load', () => this.dialog.removeAttribute('data-loading'))
84
+ this.image.addEventListener('error', () => {
85
+ this.dialog.removeAttribute('data-loading')
86
+ this.status.textContent = 'This picture could not be loaded.'
87
+ })
88
+ }
89
+
90
+ private part<T extends HTMLElement = HTMLElement>(selector: string): T {
91
+ const node = this.dialog.querySelector<T>(selector)
92
+ if (!node) throw new Error(`Gallery lightbox is missing ${selector}`)
93
+ return node
94
+ }
95
+
96
+ open(section: Element, opener: Element) {
97
+ this.items = itemsOf(section)
98
+ const start = this.items.findIndex((item) => item.opener === opener)
99
+ this.dialog.toggleAttribute('data-single', this.items.length < 2)
100
+ this.show(Math.max(0, start))
101
+ if (!this.dialog.open) this.dialog.showModal()
102
+ this.dialog.querySelector<HTMLElement>('[data-gallery-close]')?.focus({ preventScroll: true })
103
+ }
104
+
105
+ private go(step: number) {
106
+ this.show(stepIndex(this.index, step, this.items.length))
107
+ }
108
+
109
+ private show(index: number) {
110
+ const item = this.items[index]
111
+ if (!item) return
112
+ this.index = index
113
+ this.status.textContent = ''
114
+ this.dialog.setAttribute('data-loading', '')
115
+ this.image.alt = item.alt
116
+ this.image.src = item.src
117
+ // A picture without a caption shows its description, so every picture in the lightbox says what it is.
118
+ const text = item.caption || item.alt
119
+ this.caption.textContent = text
120
+ this.caption.hidden = text === ''
121
+ this.counter.textContent = `${index + 1} / ${this.items.length}`
122
+ // Fetch the neighbours now, so the next arrow press shows its picture at once.
123
+ for (const near of [stepIndex(index, 1, this.items.length), stepIndex(index, -1, this.items.length)]) {
124
+ if (near !== index) new Image().src = this.items[near]?.src ?? ''
125
+ }
126
+ }
127
+
128
+ close() {
129
+ if (this.dialog.open) this.dialog.close()
130
+ }
131
+ }
132
+
133
+ const lightboxes = new WeakMap<HTMLDialogElement, Lightbox>()
134
+
135
+ /** One delegated listener, so sections added later by the editor's live preview work too. Safe to call twice. */
136
+ export function initGalleries(): void {
137
+ const flag = '__bearminionGallery'
138
+ const scope = window as unknown as Record<string, boolean | undefined>
139
+ if (scope[flag]) return
140
+ scope[flag] = true
141
+ document.addEventListener('click', (event) => {
142
+ const opener = (event.target as Element | null)?.closest<HTMLElement>('[data-gallery-open]')
143
+ if (!opener) return
144
+ // While the editor is on the page a click edits the picture. Either way the link itself must not navigate.
145
+ event.preventDefault()
146
+ // Preview mode shows the page as visitors see it, so the lightbox works there.
147
+ const root = document.documentElement
148
+ if (root.hasAttribute('data-bearminion-ready') && !root.hasAttribute('data-bearminion-preview')) return
149
+ const section = opener.closest('[data-section-id]')
150
+ const dialog = section?.querySelector<HTMLDialogElement>('dialog[data-gallery-dialog]')
151
+ if (!section || !dialog) return
152
+ let box = lightboxes.get(dialog)
153
+ if (!box) {
154
+ box = new Lightbox(dialog)
155
+ lightboxes.set(dialog, box)
156
+ }
157
+ box.open(section, opener)
158
+ })
159
+ }
@@ -0,0 +1,12 @@
1
+ import { defineWireframe } from 'bearminion'
2
+
3
+ /** Add section picker thumbnail: [left %, top %, width %, height %, kind]. */
4
+ export const galleryWireframe = defineWireframe([
5
+ [8, 10, 34, 8, 'title'],
6
+ [8, 24, 20, 12, 'figure'],
7
+ [32, 24, 20, 12, 'figure'],
8
+ [56, 24, 20, 12, 'figure'],
9
+ [8, 40, 20, 12, 'figure'],
10
+ [32, 40, 20, 12, 'figure'],
11
+ [56, 40, 20, 12, 'figure'],
12
+ ])
@@ -0,0 +1,185 @@
1
+ ---
2
+ import type { Section } from '../definitions'
3
+ import Button from '../../atoms/Button.astro'
4
+ import { buttonLinkProps, buttonVariant } from '../../../lib/link-attrs'
5
+ import Emphasis from '../../atoms/Emphasis.astro'
6
+ import Typography from '../../atoms/Typography.astro'
7
+ import CommandLine from '../../molecules/CommandLine.astro'
8
+ import HeroBadge from './HeroBadge.astro'
9
+ import MediaFrame from '../../molecules/MediaFrame.astro'
10
+ import Pill from '../../molecules/Pill.astro'
11
+ import SectionShell from '../../molecules/SectionShell.astro'
12
+
13
+ interface Props {
14
+ section: Extract<Section, { type: 'hero' }>
15
+ index: number
16
+ motion?: boolean
17
+ }
18
+
19
+ const { section, index, motion = true } = Astro.props
20
+ const props = section.props
21
+ const field = (path: string) => `sections.${index}.props.${path}`
22
+ const reveal = section.motion ?? motion
23
+ const primary = props.button ? props.primary : undefined
24
+ const command = props.code !== 'off' ? props.command : undefined
25
+ // `action` puts the command in the button row, in the secondary button's place.
26
+ const action = props.code === 'action' ? command : undefined
27
+ const secondary = action ? undefined : props.secondary
28
+ const below = props.code === 'chip' || props.code === 'terminal' ? command : undefined
29
+ const belowVariant = props.code === 'terminal' ? 'terminal' : 'chip'
30
+ const hasActions = Boolean(primary || secondary || action)
31
+ const media = props.image ?? { src: 'placeholder', alt: 'hero visual — editor beside live page preview' }
32
+ ---
33
+
34
+ <SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={reveal}>
35
+ {
36
+ // Centred on the heading and faded out well before the edges, so it never meets the section above in a seam.
37
+ props.glow && (
38
+ <div
39
+ class="pointer-events-none absolute inset-0"
40
+ style="background: radial-gradient(ellipse 70% 60% at 50% 36%, color-mix(in oklch, var(--accent) var(--hero-glow, 20%), transparent), transparent 72%)"
41
+ aria-hidden="true"
42
+ data-hero-glow
43
+ />
44
+ )
45
+ }
46
+ {
47
+ section.variant === 'split' && (
48
+ <div class="relative mx-auto grid max-w-[80rem] grid-cols-[repeat(auto-fit,minmax(min(100%,26rem),1fr))] items-center gap-[clamp(2.5rem,5cqi,5rem)] px-[clamp(1.25rem,4cqi,3rem)] py-[clamp(3.5rem,2rem+5cqi,7rem)]">
49
+ <div class="flex flex-col items-start gap-6">
50
+ {props.badge ? <HeroBadge badge={props.badge} field={field} /> : props.eyebrow && <Pill data-field={field('eyebrow')}>{props.eyebrow}</Pill>}
51
+ {
52
+ props.heading && (
53
+ <Typography as="h1" size="display">
54
+ <Emphasis heading={props.heading} marks={props.marks} data-field={field('heading')} />
55
+ </Typography>
56
+ )
57
+ }
58
+ {props.sub && <Typography as="p" size="lead" color="muted" data-field={field('sub')} class="max-w-[34rem]" markdown={props.sub} />}
59
+ {
60
+ hasActions && (
61
+ <div class="mt-2 flex flex-wrap gap-2.5">
62
+ {primary && (
63
+ <Button {...buttonLinkProps(primary)} variant={buttonVariant(primary, 'primary')} arrow data-field={field('primary.label')}>
64
+ {primary.label}
65
+ </Button>
66
+ )}
67
+ {secondary && (
68
+ <Button {...buttonLinkProps(secondary)} variant={buttonVariant(secondary, 'secondary')} data-field={field('secondary.label')}>
69
+ {secondary.label}
70
+ </Button>
71
+ )}
72
+ {action && <CommandLine command={action} variant="action" data-field={field('command')} />}
73
+ </div>
74
+ )
75
+ }
76
+ {below && <CommandLine command={below} variant={belowVariant} data-field={field('command')} />}
77
+ </div>
78
+ {!props.image?.hidden && (
79
+ <MediaFrame src={media.src} alt={media.alt} aspectClass="aspect-[4/3.4]" fit={media?.fit} position={media?.position} data-field={field('image.alt')} priority />
80
+ )}
81
+ </div>
82
+ )
83
+ }
84
+ {
85
+ section.variant === 'centered' && (
86
+ <div class="relative mx-auto flex max-w-[80rem] flex-col items-center gap-6 px-[clamp(1.25rem,4cqi,3rem)] pt-[clamp(4rem,2rem+6cqi,8rem)] pb-[clamp(5rem,3rem+7cqi,10rem)] text-center">
87
+ {props.badge ? <HeroBadge badge={props.badge} field={field} /> : props.eyebrow && <Pill data-field={field('eyebrow')}>{props.eyebrow}</Pill>}
88
+ {
89
+ props.heading && (
90
+ <Typography as="h1" size="display-center">
91
+ <Emphasis heading={props.heading} marks={props.marks} data-field={field('heading')} />
92
+ </Typography>
93
+ )
94
+ }
95
+ {props.sub && <Typography as="p" size="lead" color="muted" data-field={field('sub')} class="max-w-[38rem]" markdown={props.sub} />}
96
+ {
97
+ hasActions && (
98
+ <div class="mt-2 flex flex-wrap justify-center gap-2.5">
99
+ {primary && (
100
+ <Button {...buttonLinkProps(primary)} variant={buttonVariant(primary, 'primary')} arrow data-field={field('primary.label')}>
101
+ {primary.label}
102
+ </Button>
103
+ )}
104
+ {secondary && (
105
+ <Button {...buttonLinkProps(secondary)} variant={buttonVariant(secondary, 'secondary')} data-field={field('secondary.label')}>
106
+ {secondary.label}
107
+ </Button>
108
+ )}
109
+ {action && <CommandLine command={action} variant="action" data-field={field('command')} />}
110
+ </div>
111
+ )
112
+ }
113
+ {below && <CommandLine command={below} variant={belowVariant} data-field={field('command')} class="mt-1" />}
114
+ {!props.image?.hidden && (
115
+ <MediaFrame
116
+ src={media.src}
117
+ alt={media.alt}
118
+ aspectClass="mt-[clamp(2rem,4cqi,4rem)] aspect-video min-h-52 w-full"
119
+ roundedClass="rounded-[clamp(1rem,2cqi,1.75rem)]"
120
+ class="text-left shadow-[0_40px_80px_-48px_oklch(0.2_0.02_255/0.45)]"
121
+ fit={media?.fit} position={media?.position} data-field={field('image.alt')}
122
+ priority
123
+ />
124
+ )}
125
+ </div>
126
+ )
127
+ }
128
+ {
129
+ section.variant === 'editorial' && (
130
+ <div class="relative mx-auto max-w-[80rem] px-[clamp(1.25rem,4cqi,3rem)] pt-[clamp(3.5rem,2rem+5cqi,7rem)] pb-[clamp(2.5rem,2rem+3cqi,5rem)]">
131
+ {
132
+ props.eyebrow && (
133
+ <Typography as="p" size="eyebrow" color="muted" data-field={field('eyebrow')}>
134
+ {props.eyebrow}
135
+ </Typography>
136
+ )
137
+ }
138
+ {
139
+ props.heading && (
140
+ <Typography as="h1" size="display-editorial" class="mt-5">
141
+ <Emphasis heading={props.heading} marks={props.marks} data-field={field('heading')} />
142
+ </Typography>
143
+ )
144
+ }
145
+ {
146
+ (props.sub || hasActions || below) && (
147
+ <div class="mt-[clamp(2rem,4cqi,3.5rem)] flex flex-wrap items-end justify-between gap-x-12 gap-y-6 border-t border-[var(--line)] pt-6">
148
+ {props.sub && <Typography as="p" size="lead" color="muted" data-field={field('sub')} class="max-w-xl flex-[1_1_22rem]" markdown={props.sub} />}
149
+ {(hasActions || below) && (
150
+ <div class="flex flex-col items-start gap-4">
151
+ {hasActions && (
152
+ <div class="flex flex-wrap items-center gap-2.5">
153
+ {action && <CommandLine command={action} variant="action" data-field={field('command')} />}
154
+ {secondary && (
155
+ <Button {...buttonLinkProps(secondary)} variant={buttonVariant(secondary, 'secondary')} data-field={field('secondary.label')}>
156
+ {secondary.label}
157
+ </Button>
158
+ )}
159
+ {primary && (
160
+ <Button {...buttonLinkProps(primary)} variant={buttonVariant(primary, 'primary')} arrow data-field={field('primary.label')}>
161
+ {primary.label}
162
+ </Button>
163
+ )}
164
+ </div>
165
+ )}
166
+ {below && <CommandLine command={below} variant={belowVariant} data-field={field('command')} />}
167
+ </div>
168
+ )}
169
+ </div>
170
+ )
171
+ }
172
+ {!props.image?.hidden && (
173
+ <MediaFrame
174
+ src={media.src}
175
+ alt={media.alt}
176
+ aspectClass="mt-[clamp(2rem,4cqi,3.5rem)] aspect-[21/9] min-h-48"
177
+ roundedClass="rounded-[clamp(1rem,2cqi,1.75rem)]"
178
+ fit={media?.fit} position={media?.position} data-field={field('image.alt')}
179
+ priority
180
+ />
181
+ )}
182
+ </div>
183
+ )
184
+ }
185
+ </SectionShell>
@@ -0,0 +1,26 @@
1
+ ---
2
+ import { anchorAttrs } from '../../../lib/link-attrs'
3
+ import type { HeroProps } from './definition'
4
+
5
+ interface Props {
6
+ badge: NonNullable<HeroProps['badge']>
7
+ field: (path: string) => string
8
+ }
9
+
10
+ const { badge, field } = Astro.props
11
+ ---
12
+
13
+ <a
14
+ {...anchorAttrs({ href: badge.href })}
15
+ class="inline-flex h-9 max-w-full items-center gap-2.5 rounded-full bg-surface ps-1.5 pe-3.5 text-[0.875rem] text-fg ring-line transition-shadow hover:shadow-[inset_0_0_0_1px_var(--fg)]"
16
+ >
17
+ {
18
+ badge.tag && (
19
+ <span class="inline-flex h-6 shrink-0 items-center rounded-full bg-accent px-2.5 text-[0.8125rem] font-semibold tracking-[-0.01em] text-on" data-field={field('badge.tag')}>
20
+ {badge.tag}
21
+ </span>
22
+ )
23
+ }
24
+ <span class="truncate font-medium" data-field={field('badge.text')}>{badge.text}</span>
25
+ <span class="text-muted" aria-hidden="true">→</span>
26
+ </a>