Repository navigation
Expand file tree
/
Copy pathdeveloper-programs-section.tsx
More file actions
309 lines (292 loc) · 8.38 KB
/
Copy pathdeveloper-programs-section.tsx
File metadata and controls
309 lines (292 loc) · 8.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
import type { ReactNode } from 'react'
import Image from 'next/image'
import type { ProgrammeCards } from '@/lib/programme-cards'
import { ROUTES } from '@/constants/routes'
import type { BuilderHubSettings, MediaRef } from '@repo/content/schemas'
import ContentWidth from '@/components/layout/content-width'
import { LambdaLockup } from '@/components/ui/lambda-lockup'
import { Link } from '@/i18n/navigation'
interface DeveloperProgramsSectionProps {
id: string
index: string
title: string
data: NonNullable<BuilderHubSettings['programs']>
programmeCards: ProgrammeCards
eventNames?: {
prize: string
rfps: string
}
}
export function DeveloperProgramsSection({
id,
index,
title,
data,
programmeCards,
eventNames,
}: DeveloperProgramsSectionProps) {
const { prize, rfps, rfpLinkLabel, noOpenRfps } = programmeCards
return (
<ProgramPanelsSection
id={id}
header={
<h2 className="flex items-baseline gap-3 text-[24px] leading-[1.1] tracking-[-0.24px] whitespace-nowrap">
<span className="font-display text-brand-dark-green/50">{index}</span>
<span className="font-sans text-brand-dark-green">{title}</span>
</h2>
}
>
<ProgramImagePanel
link={{
href: data.prizeHref,
ariaLabel: `${data.prizeTitle}: ${prize?.title ?? data.prizeHeading}`,
eventName: eventNames?.prize,
}}
image={data.prizeImage}
mark={
<LambdaLockup className="relative [--lockup-font-size:24px]">
<span className="text-h4-serif">{data.prizeTitle}</span>
</LambdaLockup>
}
title={data.prizeHeading}
description={data.prizeDescription}
featured={
prize && (
<div className="relative w-full max-w-[338px] rounded-xl border border-brand-off-white/50 px-4 py-3">
<p className="font-mono text-xs">
{prize.id} · {prize.amount}
</p>
<p className="mt-1 text-mono-s">{prize.title}</p>
</div>
)
}
/>
<ProgramOutlinePanel
link={{
href: data.rfpsHref,
ariaLabel: data.rfpsTitle,
eventName: eventNames?.rfps,
}}
title={data.rfpsTitle}
description={data.rfpsDescription}
actions={
rfps.length > 0 ? (
<div className="mt-6 flex w-full gap-3 overflow-x-auto p-1 pb-2">
{rfps.map((rfp) => (
<Link
key={rfp.number}
href={`${ROUTES.rfps}/${rfp.slug}`}
className="flex w-[min(272px,90%)] shrink-0 cursor-pointer flex-col rounded-xl border border-brand-dark-green/50 p-3 text-left focus-visible:outline focus-visible:outline-2 focus-visible:outline-brand-dark-green"
>
<p className="font-mono text-xs">{rfp.number}</p>
<h4 className="mt-1 text-subhead-sans">{rfp.title}</h4>
<div className="mt-2 flex gap-2">
<p className="line-clamp-2 text-mono-s">{rfp.summary}</p>
{rfp.image && (
<Image
src={rfp.image.src}
alt={rfp.image.alt}
width={36}
height={36}
className="h-9 w-9 shrink-0 rounded object-cover"
/>
)}
</div>
<span className="mt-auto pt-2 font-mono text-xs underline underline-offset-3">
{rfpLinkLabel}
</span>
</Link>
))}
</div>
) : undefined
}
>
{rfps.length === 0 && <p className="mt-6 text-mono-s">{noOpenRfps}</p>}
</ProgramOutlinePanel>
</ProgramPanelsSection>
)
}
interface ProgramPanelsSectionProps {
id?: string
header?: ReactNode
children: ReactNode
/** Replaces the section's border and spacing. */
className?: string
}
/** The two-panel strip. Exported so campaign pages can fill it themselves. */
export function ProgramPanelsSection({
id,
header,
children,
className = 'border-t border-brand-dark-green/10 pt-6 pb-25',
}: ProgramPanelsSectionProps) {
return (
<section id={id} className={className}>
<ContentWidth>
{header}
<div className={`grid gap-3 md:grid-cols-2 ${header ? 'mt-10' : ''}`}>
{children}
</div>
</ContentWidth>
</section>
)
}
interface ProgramPanelLink {
href: string
ariaLabel: string
eventName?: string
}
const PANEL_FOCUS_CLASSNAME =
'cursor-pointer focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand-dark-green'
/** External URLs open in a new tab and skip the locale prefix, as the app
* Button does. */
function PanelLink({
link,
className,
children,
}: {
link: ProgramPanelLink
className: string
children?: ReactNode
}) {
if (/^https?:\/\//.test(link.href)) {
return (
<a
href={link.href}
target="_blank"
rel="noopener noreferrer"
aria-label={link.ariaLabel}
data-umami-event-name={link.eventName}
className={className}
>
{children}
</a>
)
}
return (
<Link
href={link.href}
aria-label={link.ariaLabel}
data-umami-event-name={link.eventName}
className={className}
>
{children}
</Link>
)
}
function ProgramPanel({
link,
overlay = false,
className,
children,
}: {
link?: ProgramPanelLink
/**
* Lays the link over the panel instead of wrapping it, so links inside the
* panel stay clickable (links cannot nest).
*/
overlay?: boolean
className: string
children: ReactNode
}) {
if (!link) {
return <div className={className}>{children}</div>
}
if (overlay) {
return (
<div className={`relative ${className}`}>
<PanelLink
link={link}
className={`absolute inset-0 z-[1] rounded-[inherit] ${PANEL_FOCUS_CLASSNAME}`}
/>
{children}
</div>
)
}
return (
<PanelLink link={link} className={`${className} ${PANEL_FOCUS_CLASSNAME}`}>
{children}
</PanelLink>
)
}
interface ProgramImagePanelProps {
link?: ProgramPanelLink
image: MediaRef
/** Brand mark above the title. */
mark: ReactNode
title: string
description: string
featured?: ReactNode
}
export function ProgramImagePanel({
link,
image,
mark,
title,
description,
featured,
}: ProgramImagePanelProps) {
return (
<ProgramPanel
link={link}
className={`relative flex h-[370px] flex-col items-center justify-center overflow-hidden rounded-xl px-4 py-10 text-center text-brand-off-white ${featured ? 'gap-5' : 'gap-10'}`}
>
<Image
src={image.src}
alt={image.alt}
fill
sizes="50vw"
className="object-cover"
/>
<div className="absolute inset-0 bg-black/50" />
{mark}
<div className="relative flex flex-col items-center gap-3">
<h3 className="text-subhead-sans">{title}</h3>
<p className="w-full max-w-[338px] text-mono-s">{description}</p>
</div>
{featured}
</ProgramPanel>
)
}
interface ProgramOutlinePanelProps {
link?: ProgramPanelLink
/** Shown above the title, e.g. a partner logo. */
mark?: ReactNode
title: string
description: string
/** Shown below the copy. */
children?: ReactNode
/**
* Links under the copy. They sit above the panel link, which then lies over
* the panel rather than wrapping it.
*/
actions?: ReactNode
}
export function ProgramOutlinePanel({
link,
mark,
title,
description,
children,
actions,
}: ProgramOutlinePanelProps) {
return (
<ProgramPanel
link={link}
overlay={Boolean(actions)}
className="flex h-[370px] min-w-0 flex-col items-center justify-center overflow-hidden rounded-xl border border-brand-dark-green px-4 py-10"
>
{mark ? <div className="mb-10">{mark}</div> : null}
<div className="flex w-full min-w-0 flex-col items-center gap-3 text-center">
<h3 className="text-subhead-sans">{title}</h3>
<p className="w-full max-w-[338px] text-mono-s">{description}</p>
{actions ? (
<div className="relative z-[2] w-full min-w-0 text-mono-s">
{actions}
</div>
) : null}
</div>
{children}
</ProgramPanel>
)
}