create-bearminion 1.19.0 → 1.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +1 -1
- package/package.json +1 -1
- package/template/AGENTS.md +1 -1
- package/template/README.md +5 -5
- package/template/astro.config.ts +16 -4
- package/template/bearminion.lock.json +80 -132
- package/template/content/pages/about.json +2 -2
- package/template/content/pages/index.json +23 -237
- package/template/content/site.json +2 -10
- package/template/package.json +1 -1
- package/template/src/components/organisms/EntryList.astro +83 -0
- package/template/src/components/organisms/Pagination.astro +56 -0
- package/template/src/components/sections/components.gen.ts +0 -10
- package/template/src/components/sections/definitions.gen.ts +0 -10
- package/template/src/components/sections/faq/definition.ts +2 -2
- package/template/src/components/sections/media/Media.astro +2 -2
- package/template/src/components/sections/media/MediaPlayer.astro +2 -2
- package/template/src/components/sections/shared.ts +3 -0
- package/template/src/components/sections/text-image/definition.ts +1 -1
- package/template/src/content.config.ts +4 -2
- package/template/src/dev/section-preview.astro +53 -0
- package/template/src/env.d.ts +2 -0
- package/template/src/layouts/Base.astro +19 -12
- package/template/src/lib/content.ts +57 -2
- package/template/src/lib/editing.ts +6 -0
- package/template/src/lib/sitemap.ts +14 -2
- package/template/src/pages/[...slug].astro +32 -13
- package/template/src/components/sections/contact/Contact.astro +0 -231
- package/template/src/components/sections/contact/Contact.stories.ts +0 -16
- package/template/src/components/sections/contact/definition.ts +0 -52
- package/template/src/components/sections/contact/form.ts +0 -313
- package/template/src/components/sections/contact/wireframe.ts +0 -15
- package/template/src/components/sections/logo-strip/LogoStrip.astro +0 -110
- package/template/src/components/sections/logo-strip/LogoStrip.stories.ts +0 -20
- package/template/src/components/sections/logo-strip/definition.ts +0 -30
- package/template/src/components/sections/logo-strip/wireframe.ts +0 -11
- package/template/src/components/sections/pricing/Pricing.astro +0 -210
- package/template/src/components/sections/pricing/Pricing.stories.ts +0 -16
- package/template/src/components/sections/pricing/definition.ts +0 -62
- package/template/src/components/sections/pricing/wireframe.ts +0 -18
- package/template/src/components/sections/stats/Stats.astro +0 -110
- package/template/src/components/sections/stats/Stats.stories.ts +0 -16
- package/template/src/components/sections/stats/definition.ts +0 -41
- package/template/src/components/sections/stats/wireframe.ts +0 -15
- package/template/src/components/sections/testimonials/Testimonials.astro +0 -172
- package/template/src/components/sections/testimonials/Testimonials.stories.ts +0 -19
- package/template/src/components/sections/testimonials/definition.ts +0 -42
- package/template/src/components/sections/testimonials/wireframe.ts +0 -21
- package/template/src/lib/contact-form.ts +0 -97
- package/template/src/lib/hidden-text.ts +0 -32
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
NETWORK_ERROR,
|
|
3
|
-
TURNSTILE_FAILED,
|
|
4
|
-
TURNSTILE_FIELD,
|
|
5
|
-
TURNSTILE_PENDING,
|
|
6
|
-
botVerdict,
|
|
7
|
-
buildRequest,
|
|
8
|
-
collectSubmission,
|
|
9
|
-
readResponse,
|
|
10
|
-
} from '../../../lib/contact-form'
|
|
11
|
-
import { reveal } from '../../../lib/hidden-text'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Wires every Contact form on the page: the states idle, sending, sent and error, field errors under their fields,
|
|
15
|
-
* a message the visitor closes themselves when something went wrong, the spam trap and Cloudflare Turnstile. The
|
|
16
|
-
* message goes to `/api/contact` as JSON. With JavaScript off the browser posts the form there itself and leaves the
|
|
17
|
-
* page; there is no status handling in that case.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
const FIELD_ERROR = 'data-field-error'
|
|
21
|
-
|
|
22
|
-
function clearFieldErrors(form: HTMLFormElement) {
|
|
23
|
-
for (const note of form.querySelectorAll(`[${FIELD_ERROR}]`)) note.remove()
|
|
24
|
-
for (const control of form.querySelectorAll('[aria-invalid]')) {
|
|
25
|
-
control.removeAttribute('aria-invalid')
|
|
26
|
-
control.removeAttribute('aria-describedby')
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Puts each message under the field it names. Returns the first control marked, so focus can go there. */
|
|
31
|
-
function showFieldErrors(form: HTMLFormElement, errors: Readonly<Record<string, string>>): HTMLElement | null {
|
|
32
|
-
let first: HTMLElement | null = null
|
|
33
|
-
let count = 0
|
|
34
|
-
for (const [name, message] of Object.entries(errors)) {
|
|
35
|
-
const control = form.elements.namedItem(name)
|
|
36
|
-
if (!(control instanceof HTMLInputElement || control instanceof HTMLTextAreaElement || control instanceof HTMLSelectElement)) continue
|
|
37
|
-
if (control.type === 'hidden') continue
|
|
38
|
-
const note = document.createElement('p')
|
|
39
|
-
note.className = 'bm-form-error'
|
|
40
|
-
note.setAttribute(FIELD_ERROR, '')
|
|
41
|
-
note.id = `${form.id || 'contact-form'}-error-${count++}`
|
|
42
|
-
note.textContent = message
|
|
43
|
-
const holder = control.closest('label') ?? control.parentElement ?? form
|
|
44
|
-
holder.append(note)
|
|
45
|
-
control.setAttribute('aria-invalid', 'true')
|
|
46
|
-
control.setAttribute('aria-describedby', note.id)
|
|
47
|
-
first ??= control
|
|
48
|
-
}
|
|
49
|
-
return first
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* A failed send is shown in a message that stays until the visitor closes it. It does not fade: an error that
|
|
54
|
-
* disappears on its own is an error nobody finishes reading. One per form; a new one replaces the old.
|
|
55
|
-
*/
|
|
56
|
-
function toastRegion(): HTMLElement {
|
|
57
|
-
const existing = document.querySelector<HTMLElement>('[data-bm-toasts]')
|
|
58
|
-
if (existing) return existing
|
|
59
|
-
const region = document.createElement('div')
|
|
60
|
-
region.className = 'bm-toasts'
|
|
61
|
-
region.setAttribute('data-bm-toasts', '')
|
|
62
|
-
// In the top layer, so nothing on the page (or the editor in `astro dev`) can sit over the close button.
|
|
63
|
-
region.setAttribute('popover', 'manual')
|
|
64
|
-
document.body.append(region)
|
|
65
|
-
return region
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function raise(region: HTMLElement) {
|
|
69
|
-
try {
|
|
70
|
-
if (!region.matches(':popover-open')) region.showPopover()
|
|
71
|
-
} catch {
|
|
72
|
-
// No popover support: the fixed position and z-index in the stylesheet still show it.
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function closeToast(owner: string) {
|
|
77
|
-
for (const toast of toastRegion().querySelectorAll('[data-toast-for]')) {
|
|
78
|
-
if (toast.getAttribute('data-toast-for') === owner) toast.remove()
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function showToast(owner: string, message: string) {
|
|
83
|
-
closeToast(owner)
|
|
84
|
-
const toast = document.createElement('div')
|
|
85
|
-
toast.className = 'bm-toast'
|
|
86
|
-
toast.setAttribute('role', 'alert')
|
|
87
|
-
toast.setAttribute('data-toast-for', owner)
|
|
88
|
-
const text = document.createElement('p')
|
|
89
|
-
text.className = 'bm-toast-text'
|
|
90
|
-
text.textContent = message
|
|
91
|
-
const close = document.createElement('button')
|
|
92
|
-
close.type = 'button'
|
|
93
|
-
close.className = 'bm-toast-close'
|
|
94
|
-
close.setAttribute('aria-label', 'Dismiss message')
|
|
95
|
-
close.textContent = '×'
|
|
96
|
-
close.addEventListener('click', () => toast.remove())
|
|
97
|
-
toast.append(text, close)
|
|
98
|
-
const region = toastRegion()
|
|
99
|
-
region.append(toast)
|
|
100
|
-
raise(region)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** The part of Cloudflare's script the form uses. */
|
|
104
|
-
interface TurnstileApi {
|
|
105
|
-
render(container: HTMLElement, options: Record<string, unknown>): string | undefined
|
|
106
|
-
reset(widgetId?: string): void
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const TURNSTILE_SCRIPT = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit'
|
|
110
|
-
let turnstileScript: Promise<TurnstileApi> | undefined
|
|
111
|
-
|
|
112
|
-
function loadTurnstile(): Promise<TurnstileApi> {
|
|
113
|
-
const present = (window as unknown as { turnstile?: TurnstileApi }).turnstile
|
|
114
|
-
if (present) return Promise.resolve(present)
|
|
115
|
-
turnstileScript ??= new Promise<TurnstileApi>((resolve, reject) => {
|
|
116
|
-
const script = document.createElement('script')
|
|
117
|
-
script.src = TURNSTILE_SCRIPT
|
|
118
|
-
script.async = true
|
|
119
|
-
script.onload = () => {
|
|
120
|
-
const api = (window as unknown as { turnstile?: TurnstileApi }).turnstile
|
|
121
|
-
if (api) resolve(api)
|
|
122
|
-
else reject(new Error('Turnstile did not load.'))
|
|
123
|
-
}
|
|
124
|
-
script.onerror = () => {
|
|
125
|
-
turnstileScript = undefined
|
|
126
|
-
reject(new Error('Turnstile is blocked.'))
|
|
127
|
-
}
|
|
128
|
-
document.head.append(script)
|
|
129
|
-
})
|
|
130
|
-
return turnstileScript
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
interface TurnstileWidget {
|
|
134
|
-
/** The current token, or an empty string while there is none. */
|
|
135
|
-
token: string
|
|
136
|
-
/** The widget reported an error, or its script never loaded. */
|
|
137
|
-
failed: boolean
|
|
138
|
-
/** A token works once. Ask for a new one after every send. */
|
|
139
|
-
reset: () => void
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function mountTurnstile(container: HTMLElement, siteKey: string): TurnstileWidget {
|
|
143
|
-
const widget: TurnstileWidget = { token: '', failed: false, reset: () => undefined }
|
|
144
|
-
loadTurnstile().then(
|
|
145
|
-
(api) => {
|
|
146
|
-
const id = api.render(container, {
|
|
147
|
-
sitekey: siteKey,
|
|
148
|
-
// The token is added to the request by the form script, not as a hidden field.
|
|
149
|
-
'response-field': false,
|
|
150
|
-
callback: (token: string) => {
|
|
151
|
-
widget.token = token
|
|
152
|
-
widget.failed = false
|
|
153
|
-
},
|
|
154
|
-
'expired-callback': () => {
|
|
155
|
-
widget.token = ''
|
|
156
|
-
},
|
|
157
|
-
'error-callback': () => {
|
|
158
|
-
widget.token = ''
|
|
159
|
-
widget.failed = true
|
|
160
|
-
},
|
|
161
|
-
})
|
|
162
|
-
widget.reset = () => {
|
|
163
|
-
widget.token = ''
|
|
164
|
-
api.reset(id)
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
() => {
|
|
168
|
-
widget.failed = true
|
|
169
|
-
},
|
|
170
|
-
)
|
|
171
|
-
return widget
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function bind(root: HTMLElement) {
|
|
175
|
-
if (root.dataset.bound === 'true') return
|
|
176
|
-
root.dataset.bound = 'true'
|
|
177
|
-
const form = root.querySelector('[data-contact-form]')
|
|
178
|
-
const success = root.querySelector('[data-contact-success]')
|
|
179
|
-
const reset = root.querySelector('[data-contact-reset]')
|
|
180
|
-
const topicInput = root.querySelector('[data-topic-input]')
|
|
181
|
-
if (!(form instanceof HTMLFormElement) || !(success instanceof HTMLElement)) return
|
|
182
|
-
const submit = form.querySelector('button[type="submit"]')
|
|
183
|
-
const label = submit?.textContent ?? ''
|
|
184
|
-
const owner = form.dataset.formId ?? form.id
|
|
185
|
-
// The clock for the "too fast" check starts when the form is on the page.
|
|
186
|
-
const openedAt = Date.now()
|
|
187
|
-
|
|
188
|
-
const container = form.querySelector('[data-turnstile-widget]')
|
|
189
|
-
const siteKey = form.dataset.turnstileKey
|
|
190
|
-
const turnstile = container instanceof HTMLElement && siteKey ? mountTurnstile(container, siteKey) : null
|
|
191
|
-
|
|
192
|
-
const busy = (on: boolean) => {
|
|
193
|
-
form.toggleAttribute('aria-busy', on)
|
|
194
|
-
if (!(submit instanceof HTMLButtonElement)) return
|
|
195
|
-
submit.disabled = on
|
|
196
|
-
submit.textContent = on ? 'Sending…' : label
|
|
197
|
-
}
|
|
198
|
-
const thanksLine = () => success.querySelector<HTMLElement>('[data-field$=".props.thanks"]')
|
|
199
|
-
const finish = (message?: string) => {
|
|
200
|
-
form.hidden = true
|
|
201
|
-
success.dataset.shown = ''
|
|
202
|
-
success.querySelector('[data-contact-message]')?.remove()
|
|
203
|
-
const thanks = thanksLine()
|
|
204
|
-
if (message) {
|
|
205
|
-
// The endpoint's own words replace the section's thank-you text. Plain text only.
|
|
206
|
-
const line = document.createElement('p')
|
|
207
|
-
line.setAttribute('data-contact-message', '')
|
|
208
|
-
line.className = thanks?.className ?? 'mt-3 text-muted'
|
|
209
|
-
line.textContent = message
|
|
210
|
-
if (thanks) thanks.hidden = true
|
|
211
|
-
success.querySelector('p')?.after(line)
|
|
212
|
-
} else if (thanks) {
|
|
213
|
-
thanks.hidden = false
|
|
214
|
-
}
|
|
215
|
-
success.focus({ preventScroll: true })
|
|
216
|
-
}
|
|
217
|
-
const failed = (message: string, field?: HTMLElement | null) => {
|
|
218
|
-
busy(false)
|
|
219
|
-
showToast(owner, message)
|
|
220
|
-
if (field) field.focus()
|
|
221
|
-
else if (submit instanceof HTMLButtonElement) submit.focus()
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
for (const chip of root.querySelectorAll('[data-topic]')) {
|
|
225
|
-
chip.addEventListener('click', () => {
|
|
226
|
-
for (const item of root.querySelectorAll('[data-topic]')) item.setAttribute('aria-pressed', 'false')
|
|
227
|
-
chip.setAttribute('aria-pressed', 'true')
|
|
228
|
-
if (topicInput instanceof HTMLInputElement) topicInput.value = chip.textContent?.trim() ?? ''
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// A field marked wrong stops being marked as soon as it is edited.
|
|
233
|
-
form.addEventListener('input', (event) => {
|
|
234
|
-
const target = event.target
|
|
235
|
-
if (!(target instanceof HTMLElement) || target.getAttribute('aria-invalid') !== 'true') return
|
|
236
|
-
document.getElementById(target.getAttribute('aria-describedby') ?? '')?.remove()
|
|
237
|
-
target.removeAttribute('aria-invalid')
|
|
238
|
-
target.removeAttribute('aria-describedby')
|
|
239
|
-
})
|
|
240
|
-
|
|
241
|
-
form.addEventListener('submit', (event) => {
|
|
242
|
-
event.preventDefault()
|
|
243
|
-
if (!form.reportValidity()) return
|
|
244
|
-
clearFieldErrors(form)
|
|
245
|
-
closeToast(owner)
|
|
246
|
-
const trap = form.elements.namedItem('_gotcha')
|
|
247
|
-
const verdict = botVerdict(trap instanceof HTMLInputElement ? trap.value : '', openedAt, Date.now())
|
|
248
|
-
if (verdict) {
|
|
249
|
-
// A script filled the trap or submitted at once. Look as if it worked, and send nothing.
|
|
250
|
-
finish()
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
if (turnstile && turnstile.token === '') {
|
|
254
|
-
showToast(owner, turnstile.failed ? TURNSTILE_FAILED : TURNSTILE_PENDING)
|
|
255
|
-
return
|
|
256
|
-
}
|
|
257
|
-
const submission = collectSubmission(new FormData(form).entries(), owner, location.pathname)
|
|
258
|
-
if (turnstile) submission[TURNSTILE_FIELD] = turnstile.token
|
|
259
|
-
const request = buildRequest(submission)
|
|
260
|
-
busy(true)
|
|
261
|
-
void fetch(request.url, request.init).then(
|
|
262
|
-
async (response) => {
|
|
263
|
-
const body: unknown = await response.json().catch(() => undefined)
|
|
264
|
-
const result = readResponse(response.status, body)
|
|
265
|
-
// The token is spent whether the send worked or not.
|
|
266
|
-
turnstile?.reset()
|
|
267
|
-
if (result.ok) {
|
|
268
|
-
busy(false)
|
|
269
|
-
finish(result.message)
|
|
270
|
-
return
|
|
271
|
-
}
|
|
272
|
-
failed(result.error, result.fieldErrors ? showFieldErrors(form, result.fieldErrors) : null)
|
|
273
|
-
},
|
|
274
|
-
() => {
|
|
275
|
-
turnstile?.reset()
|
|
276
|
-
failed(NETWORK_ERROR)
|
|
277
|
-
},
|
|
278
|
-
)
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
reset?.addEventListener('click', () => {
|
|
282
|
-
form.reset()
|
|
283
|
-
clearFieldErrors(form)
|
|
284
|
-
closeToast(owner)
|
|
285
|
-
success.querySelector('[data-contact-message]')?.remove()
|
|
286
|
-
const thanks = thanksLine()
|
|
287
|
-
if (thanks) thanks.hidden = false
|
|
288
|
-
form.hidden = false
|
|
289
|
-
delete success.dataset.shown
|
|
290
|
-
})
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/** Puts back the contact details the page was built without (`hideFromCrawlers`). The marker goes, so it runs once. */
|
|
294
|
-
function revealHidden(root: HTMLElement): void {
|
|
295
|
-
for (const element of root.querySelectorAll('[data-hidden-value]')) {
|
|
296
|
-
const hidden = element.getAttribute('data-hidden-value')
|
|
297
|
-
element.removeAttribute('data-hidden-value')
|
|
298
|
-
if (hidden === null) continue
|
|
299
|
-
try {
|
|
300
|
-
element.textContent = reveal(hidden)
|
|
301
|
-
} catch {
|
|
302
|
-
// A damaged value stays as the "turn on JavaScript" line rather than breaking the form.
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export function bindContacts(): void {
|
|
308
|
-
for (const root of document.querySelectorAll('[data-contact]')) {
|
|
309
|
-
if (!(root instanceof HTMLElement)) continue
|
|
310
|
-
revealHidden(root)
|
|
311
|
-
bind(root)
|
|
312
|
-
}
|
|
313
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { defineWireframe } from 'bearminion'
|
|
2
|
-
|
|
3
|
-
/** Add section picker thumbnail: [left %, top %, width %, height %, kind]. */
|
|
4
|
-
export const contactWireframe = defineWireframe([
|
|
5
|
-
[8, 16, 30, 8, 'title'],
|
|
6
|
-
[8, 30, 34, 4, 'text'],
|
|
7
|
-
[8, 38, 28, 4, 'text'],
|
|
8
|
-
[8, 56, 22, 4, 'text'],
|
|
9
|
-
[8, 64, 26, 4, 'text'],
|
|
10
|
-
[52, 12, 40, 76, 'card'],
|
|
11
|
-
[56, 20, 32, 9, 'block'],
|
|
12
|
-
[56, 34, 32, 9, 'block'],
|
|
13
|
-
[56, 48, 32, 18, 'block'],
|
|
14
|
-
[56, 72, 14, 9, 'button'],
|
|
15
|
-
])
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { Section } from '../definitions'
|
|
3
|
-
import Image from '../../atoms/Image.astro'
|
|
4
|
-
import { isRemote, resolveLocalAsset } from '../../../lib/assets'
|
|
5
|
-
import { editing } from '../../../lib/editing'
|
|
6
|
-
import SectionShell from '../../molecules/SectionShell.astro'
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
section: Extract<Section, { type: 'logoStrip' }>
|
|
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
|
-
function showImage(src: string) {
|
|
20
|
-
if (src === 'placeholder') return false
|
|
21
|
-
if (isRemote(src)) return true
|
|
22
|
-
if (src.replace(/^\//, '').startsWith('src/assets/') && !resolveLocalAsset(src)) {
|
|
23
|
-
// Just uploaded in the hosted editor: <Image> draws it from the editor's route.
|
|
24
|
-
if (editing) return true
|
|
25
|
-
throw new Error(`No file in src/assets for image path "${src}". Restore the file, or choose another image in the editor and save.`)
|
|
26
|
-
}
|
|
27
|
-
return Boolean(resolveLocalAsset(src))
|
|
28
|
-
}
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
<SectionShell id={section.id} anchor={section.anchor} type={section.type} variant={section.variant} tone={section.tone} motion={reveal} reveal="16">
|
|
32
|
-
{
|
|
33
|
-
section.variant === 'row' && (
|
|
34
|
-
<div class="mx-auto flex max-w-[80rem] flex-wrap items-center gap-8 px-[clamp(1.25rem,4cqi,3rem)] py-10">
|
|
35
|
-
{props.label && (
|
|
36
|
-
<p class="max-w-[13rem] flex-[0_1_13rem] font-mono text-[0.75rem] tracking-[0.04em] text-muted uppercase" data-field={field('label')}>
|
|
37
|
-
{props.label}
|
|
38
|
-
</p>
|
|
39
|
-
)}
|
|
40
|
-
<ul class="flex min-w-[min(100%,30rem)] flex-[1_1_30rem] flex-wrap items-center justify-between gap-x-6 gap-y-4">
|
|
41
|
-
{props.logos.map((logo, logoIndex) => (
|
|
42
|
-
<li class="flex h-9 min-w-[7.5rem] items-center justify-center" data-field={field(`logos.${logoIndex}.alt`)}>
|
|
43
|
-
{showImage(logo.src) ? (
|
|
44
|
-
<Image src={logo.src} alt={logo.alt} class="h-9 w-auto" widths={[120, 240]} sizes="120px" />
|
|
45
|
-
) : (
|
|
46
|
-
<span class="font-mono text-[0.75rem] tracking-[0.08em] text-muted uppercase">
|
|
47
|
-
{logo.alt}
|
|
48
|
-
</span>
|
|
49
|
-
)}
|
|
50
|
-
</li>
|
|
51
|
-
))}
|
|
52
|
-
</ul>
|
|
53
|
-
</div>
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
{
|
|
57
|
-
section.variant === 'grid' && (
|
|
58
|
-
<div class="mx-auto max-w-[80rem] px-[clamp(1.25rem,4cqi,3rem)] py-12">
|
|
59
|
-
{props.label && (
|
|
60
|
-
<p class="mb-8 text-center font-mono text-[0.75rem] tracking-[0.08em] text-muted uppercase" data-field={field('label')}>
|
|
61
|
-
{props.label}
|
|
62
|
-
</p>
|
|
63
|
-
)}
|
|
64
|
-
<ul class="grid grid-cols-[repeat(auto-fit,minmax(min(100%,10rem),1fr))] gap-px bg-[var(--line)] ring-line">
|
|
65
|
-
{props.logos.map((logo, logoIndex) => (
|
|
66
|
-
<li class="flex h-20 items-center justify-center bg-bg transition-colors hover:bg-surface" data-field={field(`logos.${logoIndex}.alt`)}>
|
|
67
|
-
{showImage(logo.src) ? (
|
|
68
|
-
<Image src={logo.src} alt={logo.alt} class="h-9 w-auto" widths={[120, 240]} sizes="120px" />
|
|
69
|
-
) : (
|
|
70
|
-
<span class="font-mono text-[0.75rem] tracking-[0.08em] text-muted uppercase">
|
|
71
|
-
{logo.alt}
|
|
72
|
-
</span>
|
|
73
|
-
)}
|
|
74
|
-
</li>
|
|
75
|
-
))}
|
|
76
|
-
</ul>
|
|
77
|
-
</div>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
{
|
|
81
|
-
section.variant === 'marquee' && (
|
|
82
|
-
<div class="mx-auto max-w-[80rem] px-[clamp(1.25rem,4cqi,3rem)] py-12">
|
|
83
|
-
{props.label && (
|
|
84
|
-
<p class="mb-8 text-center font-mono text-[0.75rem] tracking-[0.08em] text-muted uppercase" data-field={field('label')}>
|
|
85
|
-
{props.label}
|
|
86
|
-
</p>
|
|
87
|
-
)}
|
|
88
|
-
<div class="bm-marquee-mask overflow-hidden">
|
|
89
|
-
<ul class="bm-marquee flex w-max items-center">
|
|
90
|
-
{[...props.logos, ...props.logos].map((logo, logoIndex) => (
|
|
91
|
-
<li
|
|
92
|
-
class="flex h-9 w-40 shrink-0 items-center justify-center"
|
|
93
|
-
aria-hidden={logoIndex >= props.logos.length ? 'true' : undefined}
|
|
94
|
-
data-field={field(`logos.${logoIndex % props.logos.length}.alt`)}
|
|
95
|
-
>
|
|
96
|
-
{showImage(logo.src) ? (
|
|
97
|
-
<Image src={logo.src} alt={logoIndex >= props.logos.length ? '' : logo.alt} class="h-9 w-auto" widths={[120, 240]} sizes="120px" />
|
|
98
|
-
) : (
|
|
99
|
-
<span class="font-mono text-[0.75rem] tracking-[0.08em] text-muted uppercase">
|
|
100
|
-
{logo.alt}
|
|
101
|
-
</span>
|
|
102
|
-
)}
|
|
103
|
-
</li>
|
|
104
|
-
))}
|
|
105
|
-
</ul>
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
</SectionShell>
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { sectionArgTypes } from '../../../stories/options'
|
|
2
|
-
import { sectionEntry } from '../../../stories/sample'
|
|
3
|
-
import LogoStrip from './LogoStrip.astro'
|
|
4
|
-
|
|
5
|
-
const entry = sectionEntry('logoStrip')
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Sections/LogoStrip',
|
|
9
|
-
component: LogoStrip,
|
|
10
|
-
parameters: { layout: 'fullscreen' },
|
|
11
|
-
argTypes: sectionArgTypes('logoStrip'),
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const Home = {
|
|
15
|
-
args: {
|
|
16
|
-
section: entry.section,
|
|
17
|
-
index: entry.index,
|
|
18
|
-
motion: false,
|
|
19
|
-
},
|
|
20
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { defineSection, imageSchema, textSchema } from 'bearminion'
|
|
3
|
-
import { logoStripWireframe } from './wireframe'
|
|
4
|
-
|
|
5
|
-
export const logoStripVariants = ['row', 'grid', 'marquee'] as const
|
|
6
|
-
|
|
7
|
-
export const logoStripSchema = z
|
|
8
|
-
.object({
|
|
9
|
-
label: textSchema.optional(),
|
|
10
|
-
logos: z.array(imageSchema).min(1),
|
|
11
|
-
})
|
|
12
|
-
.strict()
|
|
13
|
-
|
|
14
|
-
export type LogoStripProps = z.infer<typeof logoStripSchema>
|
|
15
|
-
|
|
16
|
-
export const logoStrip = defineSection({
|
|
17
|
-
type: 'logoStrip',
|
|
18
|
-
label: 'Logo strip',
|
|
19
|
-
description: 'A row of customer or partner logos.',
|
|
20
|
-
schema: logoStripSchema,
|
|
21
|
-
defaults: {
|
|
22
|
-
label: 'Trusted by teams like yours',
|
|
23
|
-
logos: [1, 2, 3, 4, 5, 6].map((n) => ({ src: 'placeholder', alt: `Partner logo ${n}` })),
|
|
24
|
-
},
|
|
25
|
-
variants: logoStripVariants,
|
|
26
|
-
defaultVariant: 'row',
|
|
27
|
-
optional: { props: ['label'] },
|
|
28
|
-
counts: { logos: { recommended: 6 } },
|
|
29
|
-
wireframe: logoStripWireframe,
|
|
30
|
-
})
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { defineWireframe } from 'bearminion'
|
|
2
|
-
|
|
3
|
-
/** Add section picker thumbnail: [left %, top %, width %, height %, kind]. */
|
|
4
|
-
export const logoStripWireframe = defineWireframe([
|
|
5
|
-
[20, 22, 60, 5, 'text'],
|
|
6
|
-
[6, 46, 14, 14, 'block'],
|
|
7
|
-
[24, 46, 14, 14, 'block'],
|
|
8
|
-
[42, 46, 14, 14, 'block'],
|
|
9
|
-
[60, 46, 14, 14, 'block'],
|
|
10
|
-
[78, 46, 14, 14, 'block'],
|
|
11
|
-
])
|