Commitment Pledge 1
Gets the registrant to tick and sign a pledge to show up for every day of the challenge.
Use it in a prompt
Use forms/commitment-pledge from the FunnelDNA library. Follow the skill and theme contract. Ask me for the copy, images, and brand details you need; do not invent proof.
Paste into Claude or ChatGPT with FunnelDNA connected (MCP setup), or alongside the skill.
Use it in code
- Save
component.tsx(Code tab) ascomponents/funneldna/forms/commitment-pledge.tsx. - Import it and pass your copy and images (Props tab):
import { CommitmentPledge } from "@/components/funneldna/forms/commitment-pledge"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/forms/commitment-pledge/component.tsx 425 lines
// Gets the registrant to tick and sign a pledge to show up for every day of the challenge.
"use client"
import * as React from "react"
import { AlertCircle, Check, Clock3, Loader2, Lock, PenLine } from "lucide-react"
export type CommitmentPledgeProps = {
/** Copy templates accept {count}, {eventName}, {event}, {dayOne} and {firstName} as text. */
copy?: Partial<typeof defaultCopy>
/** Validated pledge; takes precedence over onCommit. A returned promise shows the loading label. */
onSubmit?: (pledge: { name: string }) => void | Promise<void>
/** @deprecated No longer rendered: the builder wires what happens after submit. */
href?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
onAction?: () => void
/** @deprecated No longer rendered: the builder wires what happens after submit. */
sealGuaranteeImage?: string
/** Name of the challenge or event, used in the pledge sentence. */
eventName?: string
/** One label per day. The count drives the copy ("all 5 days"). */
days?: string[]
headline?: React.ReactNode
lead?: string
pledge?: string
nameLabel?: string
namePlaceholder?: string
label?: string
loadingLabel?: string
reassurance?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
successLead?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
nextStepTitle?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
joinLabel?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
joinHref?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
calendarLabel?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
calendarHref?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
editLabel?: string
disabledNote?: string
defaultName?: string
/** @deprecated No longer rendered: the builder wires what happens after submit. */
sealImage?: string
disabled?: boolean
/** "success" is accepted for older callers and renders as default. */
state?: CommitmentPledgeState
/** Legacy alias for onSubmit. */
onCommit?: (pledge: { name: string }) => void | Promise<void>
/** @deprecated No longer rendered: the builder wires what happens after submit. */
onJoin?: () => void
/** @deprecated No longer rendered: the builder wires what happens after submit. */
onAddToCalendar?: () => void
className?: string
style?: React.CSSProperties
}
export function CommitmentPledge({
copy: copyOverrides,
onSubmit,
eventName,
days = ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5"],
headline,
lead,
pledge,
nameLabel = "Sign with your full name",
namePlaceholder = "Type your name",
label = "Yes! Sign My Pledge",
loadingLabel = "Signing your pledge",
reassurance = "Free to sign. Takes about 10 seconds.",
disabledNote = "Pledges open as soon as your registration is confirmed.",
defaultName = "",
disabled = false,
state = "default",
onCommit,
className,
style,
}: CommitmentPledgeProps) {
const copy = { ...defaultCopy, ...copyOverrides }
const submitValue = onSubmit === undefined ? onCommit : onSubmit
const uid = React.useId()
const n = days.length
const dayOne = days[0] || copy.dayOne
const pledgeText = pledge ?? text(copy.pledge, { count: n, event: eventName ? text(copy.event, { eventName }) : copy.challenge })
const leadText = lead ?? text(copy.lead, { dayOne })
const isDisabled = disabled || state === "disabled"
const [checked, setChecked] = React.useState(false)
const [name, setName] = React.useState(defaultName)
const [phase, setPhase] = React.useState<"idle" | "loading">("idle")
const [tried, setTried] = React.useState(state === "error")
const [today, setToday] = React.useState("")
const checkRef = React.useRef<HTMLInputElement | null>(null)
const nameRef = React.useRef<HTMLInputElement | null>(null)
const mounted = React.useRef(true)
React.useEffect(() => {
setChecked(false)
setName(defaultName)
setPhase("idle")
setTried(state === "error")
}, [state, defaultName])
React.useEffect(() => {
mounted.current = true
setToday(new Date().toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" }))
return () => {
mounted.current = false
}
}, [])
const trimmed = name.trim()
const nameOk = trimmed.length >= 2
const checkErr = tried && !checked
const nameErr = tried && !nameOk
const loading = phase === "loading"
const force = state === "hover" || state === "active" ? state : undefined
async function submit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
if (isDisabled || phase !== "idle") return
setTried(true)
if (!checked) {
checkRef.current?.focus()
return
}
if (!nameOk) {
nameRef.current?.focus()
return
}
const result = submitValue?.({ name: trimmed })
if (!result) return
setPhase("loading")
try {
await result
} catch {
// No failure UI in this piece; the caller reports errors.
} finally {
if (mounted.current) setPhase("idle")
}
}
const rootStyle = { "--n": n, ...style } as React.CSSProperties
return (
<section
className={["cf-commitment-pledge cpl", className].filter(Boolean).join(" ")}
data-force={force}
style={rootStyle}
aria-labelledby={uid + "-h"}
>
<link rel="stylesheet" href={SIGNATURE_FONT} />
<style dangerouslySetInnerHTML={{ __html: CSS }} />
<div className="cpl-card">
<header className="cpl-head">
<h2 id={uid + "-h"} className="cpl-title">
{headline ?? (
<>
<span className="cpl-line">{copy.headline}</span>{" "}
<span className="cpl-line">
{copy.headlineLead}{" "}
<span className="cpl-nw">
<span className="cpl-hl">{text(copy.headlineDays, { count: n })}</span>{copy.headlineEnd}
</span>
</span>
</>
)}
</h2>
<p className="cpl-lead">{leadText}</p>
</header>
<div className="cpl-track">
<div className="cpl-days-wrap">
<span className="cpl-rail" aria-hidden="true">
<i />
</span>
<ol className="cpl-days" aria-label={text(copy.daysLabel, { count: n })}>
{days.map((day, i) => (
<li key={day + i} className="cpl-day" style={{ "--i": i } as React.CSSProperties}>
<span className="cpl-pip" aria-hidden="true">
<b>{i + 1}</b>
<Check strokeWidth={3.25} />
</span>
<span className="cpl-day-label">{day}</span>
</li>
))}
</ol>
</div>
<p className="cpl-track-note">{copy.trackNote}</p>
</div>
<form className="cpl-form" onSubmit={submit} noValidate aria-busy={loading || undefined}>
<fieldset className="cpl-fs" disabled={isDisabled || loading}>
<legend className="cpl-sr">{copy.legend}</legend>
<div>
<label className={"cpl-pledge" + (checked ? " is-on" : "") + (checkErr ? " is-err" : "")}>
<input
ref={checkRef}
type="checkbox"
className="cpl-sr"
checked={checked}
onChange={(event) => setChecked(event.target.checked)}
aria-invalid={checkErr || undefined}
aria-describedby={checkErr ? uid + "-ce" : undefined}
/>
<span className="cpl-box" aria-hidden="true">
<Check strokeWidth={3.25} />
</span>
<span className="cpl-pledge-text">{pledgeText}</span>
</label>
{checkErr ? (
<p id={uid + "-ce"} className="cpl-err">
<AlertCircle aria-hidden="true" strokeWidth={2.5} />
{copy.checkError}
</p>
) : null}
</div>
<div>
<label htmlFor={uid + "-n"} className="cpl-label">
{nameLabel}
</label>
<div className="cpl-input-wrap">
<PenLine className="cpl-input-icon" aria-hidden="true" strokeWidth={2.25} />
<input
ref={nameRef}
id={uid + "-n"}
name="name"
type="text"
autoComplete="name"
maxLength={48}
required
className="cpl-input"
placeholder={namePlaceholder}
value={name}
onChange={(event) => setName(event.target.value)}
aria-invalid={nameErr || undefined}
aria-describedby={nameErr ? uid + "-ne" : undefined}
/>
</div>
{nameErr ? (
<p id={uid + "-ne"} className="cpl-err">
<AlertCircle aria-hidden="true" strokeWidth={2.5} />
{copy.nameError}
</p>
) : null}
</div>
<Signature copy={copy} text={trimmed || copy.signaturePlaceholder} empty={!trimmed} date={today} />
</fieldset>
<button type="submit" className="cpl-btn" disabled={isDisabled} aria-disabled={loading || undefined}>
<span className="cpl-btn-label">{loading ? loadingLabel : label}</span>
{loading ? (
<span className="cpl-nub" aria-hidden="true">
<Loader2 className="cpl-spin" strokeWidth={2.5} />
</span>
) : null}
</button>
<p className={isDisabled ? "cpl-note is-locked" : "cpl-note"}>
{isDisabled ? <Lock aria-hidden="true" strokeWidth={2.25} /> : <Clock3 aria-hidden="true" strokeWidth={2.25} />}
<span>{isDisabled ? disabledNote : reassurance}</span>
</p>
</form>
</div>
</section>
)
}
/** "success" is accepted for older callers and renders as default. */
export type CommitmentPledgeState = "default" | "hover" | "active" | "disabled" | "error" | "success"
/* Ms Madi: an autograph-style script with real pen weight, so a typed name reads like a signature. */
const SIGNATURE_FONT = "https://fonts.googleapis.com/css2?family=Ms+Madi&display=swap"
const CSS = `
.cf-commitment-pledge{--cpl-r:var(--radius,1.25rem);--cpl-line:oklch(from var(--ink) l c h / 0.14);--cpl-mk:var(--marker,color-mix(in oklch,var(--accent) 12%,var(--card)));display:block;width:100%;max-width:40rem;margin-inline:auto;font-family:var(--font-body,Arial,sans-serif);color:var(--ink,#101828);-webkit-font-smoothing:antialiased;--cpl-paper:var(--card);--cpl-pen-c:var(--signature-ink,var(--ink));--cpl-err:var(--danger);}
.cf-commitment-pledge button{text-transform:var(--button-case,none)}
.cf-commitment-pledge input{accent-color:var(--field-focus,var(--accent))}
.cf-commitment-pledge *,.cf-commitment-pledge *::before,.cf-commitment-pledge *::after{box-sizing:border-box}
.cf-commitment-pledge :where(h2,h3,h4,p,ol,fieldset,legend){margin:0}
:where(.cf-commitment-pledge) .cpl-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);border:0;white-space:normal;clip-path:inset(50%);}
:where(.cf-commitment-pledge) .cpl-card{position:relative;overflow:hidden;border:1px solid var(--cpl-line);padding:clamp(1.5rem,5vw,2.5rem) clamp(1.25rem,4.5vw,2.25rem) clamp(1.25rem,4.5vw,2.25rem);background:var(--card);border-color:var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius));box-shadow:var(--card-shadow,var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));}
:where(.cf-commitment-pledge) .cpl-card::before{content:"";position:absolute;inset:.5rem;border:1px solid oklch(from var(--band,#0f2747) l c h / 0.1);border-radius:calc(var(--cpl-r) - .375rem);pointer-events:none}
:where(.cf-commitment-pledge) .cpl-head{position:relative;text-align:center}
:where(.cf-commitment-pledge) .cpl-title{margin-inline:auto;font-family:var(--font-display,Arial,sans-serif);font-size:clamp(1.875rem,5.4vw,2.625rem);line-height:1.08;color:var(--ink,#101828);text-wrap:balance;font-weight:var(--display-weight,800);letter-spacing:var(--display-tracking,-.022em);text-transform:var(--display-case,none);}
:where(.cf-commitment-pledge) .cpl-line{display:block;text-wrap:balance}
:where(.cf-commitment-pledge) .cpl-nw{white-space:nowrap}
:where(.cf-commitment-pledge) .cpl-hl{background:linear-gradient(176deg in oklch,transparent 0 30%,var(--cpl-mk) 30% 94%,transparent 94%);padding:0 .12em;margin:0 -.02em;border-radius:.35em .55em .45em .3em;-webkit-box-decoration-break:clone;box-decoration-break:clone}
:where(.cf-commitment-pledge) .cpl-lead{margin:.875rem auto 0;max-width:34ch;font-size:clamp(1.0625rem,2.4vw,1.1875rem);font-weight:500;line-height:1.5;color:var(--muted,#4a5565);text-wrap:pretty}
:where(.cf-commitment-pledge) .cpl-track{position:relative;margin-top:1.5rem;background:var(--band,#0f2747);color:var(--band-ink,#fff);border-radius:calc(var(--cpl-r) - .25rem);padding:1.25rem .5rem 1.125rem;box-shadow:inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / 0.6),inset 0 -2px 0 oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35),0 3px 6px -1px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-commitment-pledge) .cpl-days-wrap{position:relative}
:where(.cf-commitment-pledge) .cpl-rail{position:absolute;top:1.25rem;left:calc(50% / var(--n));right:calc(50% / var(--n));height:4px;margin-top:-2px;border-radius:4px;background:oklch(from var(--band-ink,#fff) l c h / 0.24);overflow:hidden}
:where(.cf-commitment-pledge) .cpl-rail i{position:absolute;inset:0;background:var(--cpl-mk);transform:scaleX(0);transform-origin:left center;transition:transform .9s cubic-bezier(.2,.7,.2,1) .1s}
:where(.cf-commitment-pledge) .cpl-days{position:relative;list-style:none;padding:0;display:grid;grid-template-columns:repeat(var(--n),minmax(0,1fr))}
:where(.cf-commitment-pledge) .cpl-day{display:grid;justify-items:center;align-content:start;gap:.5rem;min-width:0}
:where(.cf-commitment-pledge) .cpl-pip{position:relative;display:grid;place-items:center;width:2.5rem;height:2.5rem;border-radius:999px;border:2px solid oklch(from var(--band-ink,#fff) l c h / 0.52);color:var(--band-ink,#fff);font-family:var(--font-display,Arial,sans-serif);font-weight:800;font-size:1.0625rem;line-height:1;box-shadow:0 0 0 3px var(--band,#0f2747),0 3px 6px -1px oklch(from var(--band) calc(l - 0.12) c h / 0.35);transition:background .35s ease,border-color .35s ease,color .35s ease,transform .35s cubic-bezier(.3,1.6,.5,1);transition-delay:calc(var(--i,0) * .14s + .15s);background:var(--band);}
:where(.cf-commitment-pledge) .cpl-day:first-child .cpl-pip{border-color:var(--cpl-mk)}
:where(.cf-commitment-pledge) .cpl-pip b,:where(.cf-commitment-pledge) .cpl-pip svg{grid-area:1/1;font-weight:inherit;transition:opacity .25s ease,transform .3s ease;transition-delay:inherit}
:where(.cf-commitment-pledge) .cpl-pip svg{width:1.25rem;height:1.25rem;opacity:0;transform:scale(.4)}
:where(.cf-commitment-pledge) .cpl-day-label{font-size:.875rem;font-weight:700;line-height:1.2;color:var(--band-ink,#fff);text-align:center;overflow-wrap:anywhere}
:where(.cf-commitment-pledge) .cpl-day:first-child .cpl-day-label{;color:var(--band-ink);}
:where(.cf-commitment-pledge) .cpl-track-note{margin-top:.875rem;padding-inline:.5rem;text-align:center;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--band-ink,#fff);text-wrap:balance}
:where(.cf-commitment-pledge) .cpl-form{position:relative;margin-top:1.5rem}
:where(.cf-commitment-pledge) .cpl-fs{border:0;padding:0;min-width:0;display:grid;gap:1.25rem}
:where(.cf-commitment-pledge) .cpl-pledge{position:relative;display:flex;align-items:flex-start;gap:.875rem;padding:1.125rem;border:2px solid var(--cpl-line);cursor:pointer;transition:border-color .2s ease,background-color .2s ease,box-shadow .2s ease,transform .2s ease;background:var(--card);border-color:var(--card-border,oklch(from var(--ink) l c h / 0.12));border-radius:var(--card-radius,var(--radius));box-shadow:var(--card-shadow,var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));}
:where(.cf-commitment-pledge) .cpl-pledge:hover{border-color:oklch(from var(--ink) l c h / 0.5);box-shadow:0 3px 6px -1px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35);transform:translateY(-1px)}
:where(.cf-commitment-pledge) .cpl-pledge:has(input:focus-visible){outline:3px solid oklch(from var(--accent,#0f5fc2) l c h / 0.55);outline-offset:3px}
:where(.cf-commitment-pledge) .cpl-pledge.is-on{border-color:var(--success);background:var(--card);}
:where(.cf-commitment-pledge) .cpl-pledge.is-err{border-color:var(--cpl-err);background:var(--card);}
:where(.cf-commitment-pledge) .cpl-fs:disabled .cpl-pledge{cursor:not-allowed;box-shadow:none;transform:none;opacity:1;}
:where(.cf-commitment-pledge) .cpl-box{flex:none;display:grid;place-items:center;width:1.875rem;height:1.875rem;border:2px solid oklch(from var(--ink) l c h / 0.34);background:var(--field,#fff);box-shadow:inset 0 2px 3px oklch(from var(--card) calc(l - 0.12) c h / 0.35);transition:background-color .2s ease,border-color .2s ease,transform .25s cubic-bezier(.3,1.6,.5,1);color:var(--field-ink);border-color:var(--field-border,oklch(from var(--ink) l c h / 0.22));border-radius:var(--field-radius,var(--radius));}
:where(.cf-commitment-pledge) .cpl-box svg{width:1.125rem;height:1.125rem;opacity:0;transform:scale(.3) rotate(-12deg);transition:opacity .18s ease,transform .25s cubic-bezier(.3,1.6,.5,1)}
:where(.cf-commitment-pledge) .is-on .cpl-box{transform:scale(1.05);background:var(--success-soft);color:var(--success);border-color:var(--success);box-shadow:var(--card-shadow,inset 0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35));}
:where(.cf-commitment-pledge) .is-on .cpl-box svg{opacity:1;transform:none}
:where(.cf-commitment-pledge) .is-err .cpl-box{border-color:var(--cpl-err)}
:where(.cf-commitment-pledge) .cpl-pledge-text{margin-top:.125rem;font-size:1.0625rem;font-weight:700;line-height:1.42;color:var(--ink,#101828);text-wrap:pretty}
:where(.cf-commitment-pledge) .cpl-label{display:block;margin-bottom:.5rem;font-size:1.0625rem;font-weight:800;line-height:1.3;color:var(--label-ink,var(--ink));}
:where(.cf-commitment-pledge) .cpl-input-wrap{position:relative}
:where(.cf-commitment-pledge) .cpl-input-icon{position:absolute;left:1rem;top:50%;width:1.25rem;height:1.25rem;transform:translateY(-50%);pointer-events:none;color:var(--field-ink);}
:where(.cf-commitment-pledge) .cpl-input{display:block;width:100%;height:3.625rem;margin:0;padding:0 1rem 0 2.875rem;background:var(--field,#fff);color:var(--field-ink,#101828);border:2px solid oklch(from var(--ink) l c h / 0.22);font-family:var(--font-body,Arial,sans-serif);font-size:1.125rem;font-weight:600;line-height:1.2;box-shadow:inset 0 2px 4px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35);transition:border-color .2s ease,box-shadow .2s ease;appearance:none;border-color:var(--field-border,oklch(from var(--ink) l c h / 0.22));border-radius:var(--field-radius,var(--radius));}
:where(.cf-commitment-pledge) .cpl-input::placeholder{opacity:1;font-weight:500;color:color-mix(in oklch, var(--field-ink) 65%, var(--field));}
:where(.cf-commitment-pledge) .cpl-input:hover{border-color:oklch(from var(--ink) l c h / 0.38)}
:where(.cf-commitment-pledge) .cpl-input:focus{outline:none;border-color:var(--field-focus,var(--accent));box-shadow:0 0 0 3px oklch(from var(--field-focus,var(--accent)) l c h / 0.22);}
:where(.cf-commitment-pledge) .cpl-input[aria-invalid=true]{border-color:var(--cpl-err)}
:where(.cf-commitment-pledge) .cpl-input:disabled{cursor:not-allowed;background:var(--field);}
:where(.cf-commitment-pledge) .cpl-err{display:flex;align-items:flex-start;gap:.4375rem;margin-top:.5rem;font-size:.9375rem;font-weight:700;line-height:1.4;color:var(--cpl-err);text-wrap:pretty}
:where(.cf-commitment-pledge) .cpl-err svg{flex:none;width:1.125rem;height:1.125rem;margin-top:.0625rem}
:where(.cf-commitment-pledge) .cpl-sig{position:relative;padding:.875rem 1.125rem 1rem;background:color-mix(in oklch,var(--ink) 4%,var(--card));border-radius:var(--card-radius,var(--radius));box-shadow:none;}
:where(.cf-commitment-pledge) .cpl-sig-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:.25rem 1rem;font-size:.875rem;font-weight:700;line-height:1.3;color:var(--muted,#4a5565)}
:where(.cf-commitment-pledge) .cpl-sig-tag{display:inline-flex;align-items:center;gap:.375rem}
:where(.cf-commitment-pledge) .cpl-sig-tag svg{width:.9375rem;height:.9375rem}
:where(.cf-commitment-pledge) .cpl-sig-name{padding:.375rem .5rem .125rem;font-weight:400;font-size:clamp(2.875rem,10.5vw,3.875rem);line-height:1.2;letter-spacing:.005em;color:var(--cpl-pen-c);text-align:center;overflow-wrap:anywhere;text-wrap:balance;font-family:var(--signature-font,var(--signature-face,var(--font-display)));}
:where(.cf-commitment-pledge) .cpl-sig-name.is-empty{color:var(--muted,#4a5565)}
:where(.cf-commitment-pledge) .cpl-btn{position:relative;display:flex;align-items:center;justify-content:center;width:100%;min-height:4.25rem;margin-top:1.5rem;padding:.875rem 4rem;letter-spacing:.005em;text-align:center;text-decoration:none;cursor:pointer;-webkit-tap-highlight-color:transparent;transition:transform .16s ease,box-shadow .16s ease,filter .16s ease;background:linear-gradient(180deg in oklch,var(--button-bg,var(--cta)),var(--button-bg-2,oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h)));color:var(--button-ink,var(--cta-ink));border-color:var(--button-bg-2,oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h));border-radius:var(--button-radius,var(--radius));font:var(--button-weight,800) clamp(1.125rem,3.6vw,1.375rem)/1.15 var(--button-font,var(--font-display));text-transform:var(--button-case,none);box-shadow:var(--button-shadow,inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.16) c h),var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));border:1px solid var(--button-bg-2,oklch(from var(--button-bg,var(--cta)) calc(l - 0.05) c h));}
:where(.cf-commitment-pledge) .cpl-btn-label{display:block;text-wrap:balance;text-shadow:var(--button-text-shadow, 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.2) c h / 0.75))}
:where(.cf-commitment-pledge) .cpl-nub{position:absolute;right:.75rem;top:50%;display:grid;place-items:center;width:2.5rem;height:2.5rem;margin-top:-1.25rem;border-radius:999px;transition:background-color .16s ease;background:transparent;color:inherit;box-shadow:none;}
:where(.cf-commitment-pledge) .cpl-nub svg{width:1.25rem;height:1.25rem}
:where(.cf-commitment-pledge) .cpl-btn:hover:not(:disabled),.cf-commitment-pledge[data-force=hover] .cpl-btn:not(:disabled){transform:translateY(-2px);filter:none;box-shadow:var(--button-shadow,inset 0 -3px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.16) c h),var(--shadow-md, 0 1px 2px oklch(0.22 0.03 260 / 0.22), 0 4px 10px -2px oklch(0.22 0.03 260 / 0.2)));}
:where(.cf-commitment-pledge) .cpl-btn:active:not(:disabled),.cf-commitment-pledge[data-force=active] .cpl-btn:not(:disabled){transform:translateY(2px);filter:none;box-shadow:var(--button-shadow,inset 0 -1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.16) c h),var(--shadow-sm, 0 1px 1px oklch(0.22 0.03 260 / 0.18), 0 1px 3px oklch(0.22 0.03 260 / 0.14)));}
:where(.cf-commitment-pledge) .cpl-btn:focus-visible{outline:3px solid var(--accent,#0f5fc2);outline-offset:4px}
:where(.cf-commitment-pledge) .cpl-btn:disabled{cursor:not-allowed;filter:none;transform:none;background:var(--button-2-bg,var(--card));color:var(--button-2-ink,var(--ink));border-color:var(--button-2-border,oklch(from var(--ink) l c h / 0.22));border-radius:var(--button-radius,var(--radius));box-shadow:var(--button-shadow,none);}
:where(.cf-commitment-pledge) .cpl-btn:disabled .cpl-btn-label{text-shadow:none}
:where(.cf-commitment-pledge) .cpl-btn:disabled .cpl-nub{box-shadow:none;background:transparent;color:inherit;}
:where(.cf-commitment-pledge) .cpl-btn[aria-disabled=true]{cursor:progress}
:where(.cf-commitment-pledge) .cpl-spin{animation:cpl-spin .8s linear infinite}
:where(.cf-commitment-pledge) .cpl-note{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:1rem;font-size:.9375rem;font-weight:600;line-height:1.4;color:var(--muted,#4a5565);text-align:center;text-wrap:pretty}
:where(.cf-commitment-pledge) .cpl-note svg{flex:none;width:1.0625rem;height:1.0625rem;color:var(--success);}
:where(.cf-commitment-pledge) .cpl-note.is-locked svg{color:var(--muted,#4a5565)}
@keyframes cpl-spin{to{transform:rotate(360deg)}}
@media (max-width:26rem){
:where(.cf-commitment-pledge) .cpl-track{padding-inline:.25rem}
:where(.cf-commitment-pledge) .cpl-pip{width:2.25rem;height:2.25rem;font-size:1rem;box-shadow:0 0 0 3px var(--band,#0f2747),0 3px 6px -1px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-commitment-pledge) .cpl-rail{top:1.125rem}
:where(.cf-commitment-pledge) .cpl-pledge{padding:1rem .875rem}
:where(.cf-commitment-pledge) .cpl-sig{padding-inline:.875rem}
:where(.cf-commitment-pledge) .cpl-btn{padding-inline:2.875rem}
:where(.cf-commitment-pledge) .cpl-nub{right:.5rem;width:2rem;height:2rem;margin-top:-1rem}
:where(.cf-commitment-pledge) .cpl-nub svg{width:1.0625rem;height:1.0625rem}
}
@media (prefers-reduced-motion:reduce){
.cf-commitment-pledge *,.cf-commitment-pledge *::before,.cf-commitment-pledge *::after{transition:none!important;animation:none!important}
:where(.cf-commitment-pledge) .cpl-btn:hover:not(:disabled),:where(.cf-commitment-pledge) .cpl-pledge:hover,.cf-commitment-pledge[data-force=hover] .cpl-btn:not(:disabled){transform:none}
}
`
function Signature({ copy, text, empty, date }: { copy: typeof defaultCopy; text: string; empty?: boolean; date?: string }) {
return (
<div className="cpl-sig" aria-hidden="true">
<div className="cpl-sig-head">
<span className="cpl-sig-tag">
<PenLine aria-hidden="true" strokeWidth={2.25} />
{copy.signature}
</span>
{date ? <span>{date}</span> : null}
</div>
<p className={empty ? "cpl-sig-name is-empty" : "cpl-sig-name"}>{text}</p>
</div>
)
}
const defaultCopy = {
"dayOne": "Day 1",
"event": "the {eventName}",
"challenge": "this challenge",
"pledge": "I commit to showing up for all {count} days of {event}.",
"lead": "Decide now, before {dayOne} starts. One tick and your name is all it takes.",
"headline": "Sign your pledge.",
"headlineLead": "Show up for",
"headlineDays": "all {count} days",
"headlineEnd": ".",
"daysLabel": "The {count} days you are committing to",
"pledged": " (pledged)",
"trackDone": "All {count} days locked in. See you on {dayOne}.",
"trackNote": "Tick the pledge below to lock in every day.",
"friend": "friend",
"successTitle": "You're in, {firstName}!",
"legend": "Your pledge",
"checkError": "Tick the pledge to make it official.",
"nameError": "Type your full name to sign your pledge.",
"signaturePlaceholder": "Your name here",
"signed": "Signed",
"signature": "Your signature"
}
function text(template: string, values: Record<string, string | number>) {
return template.replace(/\{(\w+)\}/g, (match, key: string) => String(values[key] ?? match))
}
export default CommitmentPledge
pieces/forms/commitment-pledge/specimen.tsx 20 lines
import * as React from "react"
import CommitmentPledge from "../commitment-pledge"
import defaults from "../../studio-defaults.json"
export const states = ["default", "hover", "active", "disabled", "error"]
type SpecimenState = "default" | "hover" | "active" | "disabled" | "error"
export default function CommitmentPledgeSpecimen({ state = "default" }: { state?: SpecimenState }) {
const registration = defaults.sample.registration
return (
<div>
<CommitmentPledge
state={state}
eventName={registration.name}
/>
</div>
)
}
| Name | Type | Details |
|---|---|---|
copy OptionalCommitmentPledge |
Partial<typeof defaultCopy> |
|
onSubmit OptionalCommitmentPledge |
(pledge: { name: string }) => void | Promise<void> |
|
href OptionalCommitmentPledge |
string |
|
onAction OptionalCommitmentPledge |
() => void |
|
sealGuaranteeImage OptionalCommitmentPledge |
string |
|
eventName OptionalCommitmentPledge |
string |
|
days OptionalCommitmentPledge |
string[] |
Default ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5"]
|
headline OptionalCommitmentPledge |
React.ReactNode |
|
lead OptionalCommitmentPledge |
string |
|
pledge OptionalCommitmentPledge |
string |
|
nameLabel OptionalCommitmentPledge |
string |
Default "Sign with your full name"
|
namePlaceholder OptionalCommitmentPledge |
string |
Default "Type your name"
|
label OptionalCommitmentPledge |
string |
Default "Yes! Sign My Pledge"
|
loadingLabel OptionalCommitmentPledge |
string |
Default "Signing your pledge"
|
reassurance OptionalCommitmentPledge |
string |
Default "Free to sign. Takes about 10 seconds."
|
successLead OptionalCommitmentPledge |
string |
|
nextStepTitle OptionalCommitmentPledge |
string |
|
joinLabel OptionalCommitmentPledge |
string |
|
joinHref OptionalCommitmentPledge |
string |
|
calendarLabel OptionalCommitmentPledge |
string |
|
calendarHref OptionalCommitmentPledge |
string |
|
editLabel OptionalCommitmentPledge |
string |
|
disabledNote OptionalCommitmentPledge |
string |
Default "Pledges open as soon as your registration is confirmed."
|
defaultName OptionalCommitmentPledge |
string |
Default ""
|
sealImage OptionalCommitmentPledge |
string |
|
disabled OptionalCommitmentPledge |
boolean |
Default false
|
state OptionalCommitmentPledge |
CommitmentPledgeState |
Default "default"
|
onCommit OptionalCommitmentPledge |
(pledge: { name: string }) => void | Promise<void> |
|
onJoin OptionalCommitmentPledge |
() => void |
|
onAddToCalendar OptionalCommitmentPledge |
() => void |
|
className OptionalCommitmentPledge |
string |
|
style OptionalCommitmentPledge |
React.CSSProperties |
Theme roles it reads
Set by the theme bar, a preset or your brand. Colours come from the base tokens (--surface, --ink, --cta…) every piece uses.
--button-bg--button-bg-2--button-case--button-font--button-ink--button-radius--button-shadow--button-text-shadow--button-weight- Main CTA button: background, ink, font, weight, case, radius and shadow.
--button-2-bg--button-2-border--button-2-ink- Secondary button.
--card-border--card-radius--card-shadow- Cards and panels: radius, border and shadow.
--display-case--display-tracking--display-weight- Headlines: weight, letter case and tracking.
--field--field-border--field-focus--field-ink--field-radius- Form inputs: background, ink, border, radius and focus colour.
--marker- The highlighter colour behind key phrases.
Image slots
Filled from the brand’s images; the specimen ships its own defaults.
This piece reads no image slots.
-
b77916eca54aa689.webp
image/webp · 8.32 KB
-
d435db6662febfcf.webp
image/webp · 10 KB
-
f0a5d3e1e61804ba.webp
image/webp · 11.6 KB