Coupon Wrapper 1
The dashed clip-this frame with a scissors glyph on the left edge and an optional red corner tag, wrapping a Johnson box, bonus or discount line.
Use it in a prompt
Use offer/coupon-wrapper-1 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/offer/coupon-wrapper-1.tsx. - Import it and pass your copy and images (Props tab):
import { CouponWrapper1 } from "@/components/funneldna/offer/coupon-wrapper-1"
It restyles from the theme tokens on any wrapper (Theme tab). The specimen source is a complete working example.
pieces/offer/coupon-wrapper-1/component.tsx 280 lines
// Hands the buyer a coupon code they can copy in one tap and paste at checkout.
"use client"
import * as React from "react"
import { Scissors, Copy, Check, MousePointerClick } from "lucide-react"
export type CouponWrapper1Props = {
/** The coupon code the visitor copies. */
code?: string
/** The real deal in big type, e.g. "$50" or "40%". Omit it and the amount block is hidden. */
amount?: string
/** Word under the amount, e.g. "Off". */
unit?: string
/** What the coupon is for, e.g. the product name. */
title?: React.ReactNode
/** Price after the coupon. */
price?: string
/** Regular price, shown struck through. */
regularPrice?: string
/** One short line under the code. */
hint?: React.ReactNode
/** Line shown once the code is copied. */
copiedHint?: React.ReactNode
copyLabel?: string
copiedLabel?: string
/** Corner label set into the cut line, e.g. "Clip & save". */
tag?: string
/** Studio preview state: "hover" | "active" | "success". */
state?: "default" | "hover" | "active" | "success"
/** Called only after the code is copied successfully. */
onAction?: (code: string) => void
/** Legacy alias for onAction. */
onCopy?: (code: string) => void
/** Optional extra line (a bonus or a Johnson box line) under the code. */
children?: React.ReactNode
manualHint?: React.ReactNode
priceLabel?: string
insteadOfLabel?: string
/** Accessible templates use {code}, or {amount} and {unit}. */
copyLabelTemplate?: string
valueLabelTemplate?: string
className?: string
}
export function CouponWrapper1({
code = "SAVE50",
amount,
unit = "Off",
title,
price,
regularPrice,
hint = "Tap the code to copy it, then paste it at checkout.",
copiedHint = "Copied! Paste it at checkout.",
copyLabel = "Copy",
copiedLabel = "Copied",
tag,
state,
onCopy,
onAction = onCopy,
children,
manualHint = "Code selected. Press Ctrl+C (⌘C on Mac) to copy it.",
priceLabel = "Pay",
insteadOfLabel = " instead of ",
copyLabelTemplate = "Copy coupon code {code}",
valueLabelTemplate = "{amount} {unit}",
className,
}: CouponWrapper1Props) {
const [status, setStatus] = React.useState<Status>("idle")
const codeRef = React.useRef<HTMLSpanElement>(null)
const cutRef = React.useRef<HTMLDivElement>(null)
const tagRef = React.useRef<HTMLSpanElement>(null)
const timer = React.useRef<number | undefined>(undefined)
const alive = React.useRef(true)
React.useEffect(() => {
alive.current = true
return () => { alive.current = false; window.clearTimeout(timer.current) }
}, [])
// Measure the tag so the dashed line opens exactly around it (no white patch).
useIsoLayoutEffect(() => {
const cut = cutRef.current
const node = tagRef.current
if (!cut || !node) return
const apply = () => cut.style.setProperty("--cw1-tag-w", `${node.offsetWidth}px`)
apply()
if (typeof ResizeObserver === "undefined") return
const ro = new ResizeObserver(apply)
ro.observe(node)
return () => ro.disconnect()
}, [tag])
const shown: Status = state === "success" ? "copied" : status
const copied = shown === "copied"
const selectCode = () => {
const node = codeRef.current
if (!node || typeof window === "undefined") return
const sel = window.getSelection()
const range = document.createRange()
range.selectNodeContents(node)
sel?.removeAllRanges()
sel?.addRange(range)
}
const handleCopy = async (e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault()
let ok = false
try {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(code)
ok = true
}
} catch {
ok = false
}
if (!alive.current) return
window.clearTimeout(timer.current)
if (ok) {
setStatus("copied")
onAction?.(code)
timer.current = window.setTimeout(() => setStatus("idle"), 2600)
} else {
selectCode()
setStatus("manual")
}
}
const hintText =
shown === "copied"
? copiedHint
: shown === "manual"
? manualHint
: hint
return (
<div
className={["cw1 cf-coupon-wrapper-1", tag && "cw1--tagged", className].filter(Boolean).join(" ")}
data-state={state}
data-copied={copied ? "" : undefined}
>
<style>{CSS}</style>
<div
className="cw1-cut"
ref={cutRef}
style={
tag
? ({ "--cw1-tag-w": `${(tag.length * 0.7 + 1.9).toFixed(2)}rem` } as React.CSSProperties)
: undefined
}
>
{tag && (
<span className="cw1-tag" ref={tagRef}>
<span>{tag}</span>
</span>
)}
<span aria-hidden className="cw1-snip">
<Scissors size={19} strokeWidth={2.25} />
</span>
<div className="cw1-paper">
{amount && (
<div className="cw1-value" aria-label={valueLabelTemplate.replaceAll("{amount}", () => amount).replaceAll("{unit}", () => unit ?? "").trim()}>
<span className="cw1-amount" aria-hidden>
{amount}
</span>
{unit && (
<span className="cw1-unit" aria-hidden>
{unit}
</span>
)}
</div>
)}
<div className="cw1-body">
{title && <p className="cw1-title">{title}</p>}
{(price || regularPrice) && (
<p className="cw1-price">
{price && (
<>
{priceLabel}{" "}<strong>{price}</strong>
</>
)}
{price && regularPrice && insteadOfLabel}
{regularPrice && <s>{regularPrice}</s>}
</p>
)}
<button
type="button"
className="cw1-code"
onClick={handleCopy}
aria-label={copyLabelTemplate.replaceAll("{code}", () => code)}
>
<span className="cw1-code-text" ref={codeRef}>
<span>{code}</span>
</span>
<span className="cw1-code-act" aria-hidden>
{copied ? (
<Check key="ok" size={19} strokeWidth={3} />
) : (
<Copy key="copy" size={18} strokeWidth={2.5} />
)}
<span>{copied ? copiedLabel : copyLabel}</span>
</span>
</button>
<p className="cw1-hint" aria-live="polite">
{copied ? (
<Check size={16} strokeWidth={3} aria-hidden />
) : (
<MousePointerClick size={16} strokeWidth={2.25} aria-hidden />
)}
<span>{hintText}</span>
</p>
{children && <div className="cw1-extra">{children}</div>}
</div>
</div>
</div>
</div>
)
}
export default CouponWrapper1
const CSS = `
.cf-coupon-wrapper-1{--cw1-muted:var(--muted);--cw1-ink:var(--ink);--cw1-paper:color-mix(in oklch, var(--ink) 4%, var(--card));--cw1-rule:color-mix(in oklch, var(--ink) 20%, var(--card));--cw1-line:oklch(from var(--cw1-ink) l c h / 0.46);--cw1-ok:var(--success);--cw1-tag-x:1.75rem;position:relative;width:100%;max-width:40rem;margin-inline:auto;container-type:inline-size;font-family:var(--font-body,Arial,sans-serif);color:var(--cw1-ink)}
:where(.cf-coupon-wrapper-1).cw1--tagged{padding-top:0.85rem}
:where(.cf-coupon-wrapper-1) .cw1-cut{position:relative;padding:12px;border-radius:calc(var(--radius,12px) + 10px)}
:where(.cf-coupon-wrapper-1) .cw1-cut::before{content:"";position:absolute;inset:0;border:2px dashed var(--cw1-line);border-radius:inherit;pointer-events:none;
-webkit-mask-image:linear-gradient(var(--ink),var(--ink)),linear-gradient(var(--ink),var(--ink));-webkit-mask-position:0 0,0 50%;-webkit-mask-size:100% 100%,10px 40px;-webkit-mask-repeat:no-repeat;-webkit-mask-composite:xor;
mask-image:linear-gradient(var(--ink),var(--ink)),linear-gradient(var(--ink),var(--ink));mask-position:0 0,0 50%;mask-size:100% 100%,10px 40px;mask-repeat:no-repeat;mask-composite:exclude}
:where(.cf-coupon-wrapper-1).cw1--tagged .cw1-cut::before{
-webkit-mask-image:linear-gradient(var(--ink),var(--ink)),linear-gradient(var(--ink),var(--ink)),linear-gradient(var(--ink),var(--ink));-webkit-mask-position:0 0,0 50%,calc(var(--cw1-tag-x) - 7px) 0;-webkit-mask-size:100% 100%,10px 40px,calc(var(--cw1-tag-w,9rem) + 14px) 10px;
mask-image:linear-gradient(var(--ink),var(--ink)),linear-gradient(var(--ink),var(--ink)),linear-gradient(var(--ink),var(--ink));mask-position:0 0,0 50%,calc(var(--cw1-tag-x) - 7px) 0;mask-size:100% 100%,10px 40px,calc(var(--cw1-tag-w,9rem) + 14px) 10px}
:where(.cf-coupon-wrapper-1) .cw1-tag{position:absolute;top:0;left:var(--cw1-tag-x);transform:translateY(-50%);z-index:2;display:inline-flex;align-items:center;padding:0.45rem 0.95rem 0.42rem;border-radius:999px;background:var(--warning-soft);color:var(--warning);font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight, 800);font-size:0.8125rem;line-height:1;letter-spacing:0.12em;text-transform:uppercase;white-space:nowrap;box-shadow:inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / 0.3),inset 0 -1px 0 oklch(from var(--surface) min(0.24, calc(l - 0.12)) c h / 0.18),0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-coupon-wrapper-1) .cw1-tag span{margin-right:-0.12em}
:where(.cf-coupon-wrapper-1) .cw1-snip{position:absolute;top:50%;left:1px;z-index:2;display:grid;place-items:center;width:22px;height:22px;color:oklch(from var(--cw1-ink) l c h / 0.72);transform:translate(-50%,-50%)}
:where(.cf-coupon-wrapper-1) .cw1-snip svg{transform:rotate(-90deg);transform-origin:50% 50%}
.cf-coupon-wrapper-1:hover .cw1-snip svg,.cf-coupon-wrapper-1[data-state="hover"] .cw1-snip svg{animation:cw1-snip 0.6s ease-in-out 1}
:where(.cf-coupon-wrapper-1) .cw1-paper{position:relative;display:grid;gap:1rem;padding:1rem;border-radius:var(--card-radius, var(--radius,12px));background:var(--cw1-paper);border:1px solid var(--card-border, var(--cw1-rule));box-shadow:var(--card-shadow, inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / 0.75),0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35))}
:where(.cf-coupon-wrapper-1) .cw1-value{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:1.25rem 1.25rem 1.1rem;border-radius:calc(var(--radius,12px) - 4px);background:var(--success-soft);color:var(--success);box-shadow:inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / 0.12),0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-coupon-wrapper-1) .cw1-amount{font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight, 900);font-size:clamp(3rem,14cqi,4.5rem);line-height:0.9;letter-spacing:var(--display-tracking, -0.04em);font-variant-numeric:tabular-nums;white-space:nowrap;text-transform:var(--display-case, none)}
:where(.cf-coupon-wrapper-1) .cw1-unit{margin-top:0.7rem;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight, 800);font-size:1rem;line-height:1;letter-spacing:0.24em;margin-right:-0.24em;text-transform:uppercase;color:var(--success)}
:where(.cf-coupon-wrapper-1) .cw1-body{display:flex;flex-direction:column;justify-content:center;gap:0.8rem;min-width:0;text-align:center}
:where(.cf-coupon-wrapper-1) .cw1-title{margin:0;font-family:var(--font-display,Arial,sans-serif);font-weight:var(--display-weight, 900);font-size:clamp(1.3rem,3.6cqi + 0.55rem,1.75rem);line-height:1.1;letter-spacing:var(--display-tracking, -0.02em);text-wrap:balance;text-transform:var(--display-case, none)}
:where(.cf-coupon-wrapper-1) .cw1-price{margin:-0.25rem 0 0.15rem;font-size:1.0625rem;line-height:1.4;font-weight:600;color:var(--cw1-muted);text-wrap:pretty}
:where(.cf-coupon-wrapper-1) .cw1-price strong{color:var(--cw1-ink);font-weight:800}
:where(.cf-coupon-wrapper-1) .cw1-price s{color:var(--danger);text-decoration-color:var(--danger);text-decoration-thickness:2px}
:where(.cf-coupon-wrapper-1) .cw1-code{display:flex;align-items:stretch;gap:0.375rem;width:100%;min-height:3.5rem;margin:0;padding:5px;border:1px solid oklch(from var(--cw1-ink) l c h / 0.2);border-radius:var(--button-radius, calc(var(--radius,12px) - 2px));background:var(--button-2-bg, var(--card));color:var(--button-2-ink, var(--cw1-ink));font:inherit;text-align:left;cursor:pointer;box-shadow:var(--button-shadow, 0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35));transition:transform 0.15s ease,box-shadow 0.15s ease,border-color 0.15s ease;border-color:var(--button-2-border, oklch(from var(--ink) l c h / 0.2));text-transform:var(--button-case, none);font-family:var(--button-font, var(--font-body));border-color:var(--button-2-border, transparent);border-radius:var(--button-radius, var(--radius));box-shadow:var(--button-shadow, none)}
:where(.cf-coupon-wrapper-1) .cw1-code-text{flex:1;min-width:0;display:flex;align-items:center;justify-content:center;padding:0.35rem 0.75rem;border-radius:max(4px,calc(var(--radius,12px) - 6px));font-family:var(--font-body);font-weight:800;font-size:clamp(1.1rem,2.6cqi + 0.7rem,1.4rem);line-height:1;letter-spacing:0.14em;white-space:nowrap;overflow:hidden;user-select:all;-webkit-user-select:all;transition:background-color 0.2s ease}
:where(.cf-coupon-wrapper-1) .cw1-code-text span{margin-right:-0.14em;overflow:hidden;text-overflow:ellipsis}
:where(.cf-coupon-wrapper-1) .cw1-code-act{flextext-shadow:var(--button-text-shadow, 0 1px 0 oklch(from var(--button-bg, var(--cta)) calc(l - 0.2) c h / 0.75));:none;display:inline-flex;align-items:center;justify-content:center;gap:0.45rem;min-width:6.5rem;padding:0 1rem;border-radius:var(--button-radius, max(4px,calc(var(--radius,12px) - 6px)));background:linear-gradient(180deg,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,#ffffff));font-family:var(--button-font, var(--font-display,Arial,sans-serif));font-weight:var(--button-weight, 800);font-size:1.0625rem;line-height:1;box-shadow:var(--button-shadow, inset 0 1px 0 oklch(from var(--card) calc(l + 0.04) c h / 0.3),inset 0 -2px 0 oklch(from var(--surface) min(0.24, calc(l - 0.12)) c h / 0.16),0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35));transition:background 0.2s ease,box-shadow 0.15s ease;text-transform:var(--button-case, none)}
:where(.cf-coupon-wrapper-1) .cw1-code-act svg{flex:none}
:where(.cf-coupon-wrapper-1) .cw1-code:hover,.cf-coupon-wrapper-1[data-state="hover"] .cw1-code{transform:translateY(-1px);border-color:oklch(from var(--cw1-ink) l c h / 0.34);box-shadow:0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-coupon-wrapper-1) .cw1-code:hover .cw1-code-text,.cf-coupon-wrapper-1[data-state="hover"] .cw1-code-text{background:var(--card)}
:where(.cf-coupon-wrapper-1) .cw1-code:active,.cf-coupon-wrapper-1[data-state="active"] .cw1-code{transform:translateY(1px);box-shadow:0 2px 3px oklch(from var(--shadow, oklch(0.22 0.03 260)) l c h / 0.35)}
:where(.cf-coupon-wrapper-1) .cw1-code:active .cw1-code-act,.cf-coupon-wrapper-1[data-state="active"] .cw1-code-act{box-shadow:var(--button-shadow, inset 0 2px 5px oklch(from var(--surface) min(0.24, calc(l - 0.12)) c h / 0.28))}
:where(.cf-coupon-wrapper-1) .cw1-code:focus-visible{outline:3px solid var(--accent,#0f5fc2);outline-offset:3px}
.cf-coupon-wrapper-1[data-copied] .cw1-code{border-color:var(--cw1-ok)}
.cf-coupon-wrapper-1[data-copied] .cw1-code-act{background:var(--success-soft);color:var(--cw1-ok)}
.cf-coupon-wrapper-1[data-copied] .cw1-code-text{background:var(--success-soft)}
.cf-coupon-wrapper-1[data-copied] .cw1-code-act svg{animation:cw1-pop 0.32s cubic-bezier(.2,1.4,.4,1)}
:where(.cf-coupon-wrapper-1) .cw1-hint{display:inline-flex;align-items:center;justify-content:center;gap:0.4rem;margin:0;font-size:0.875rem;line-height:1.35;font-weight:600;color:var(--cw1-muted);text-wrap:pretty}
:where(.cf-coupon-wrapper-1) .cw1-hint .lucide-check{color:var(--success)}
:where(.cf-coupon-wrapper-1) .cw1-hint svg{flex:none;color:var(--accent,#0f5fc2)}
.cf-coupon-wrapper-1[data-copied] .cw1-hint{color:var(--cw1-ok)}
.cf-coupon-wrapper-1[data-copied] .cw1-hint svg{color:var(--cw1-ok)}
:where(.cf-coupon-wrapper-1) .cw1-extra{margin-top:0.2rem}
@keyframes cw1-pop{0%{transform:scale(0.4)}100%{transform:scale(1)}}
@keyframes cw1-snip{0%,100%{transform:rotate(-90deg)}25%{transform:rotate(-80deg)}50%{transform:rotate(-90deg)}75%{transform:rotate(-80deg)}}
@container (min-width:34rem){
:where(.cf-coupon-wrapper-1) .cw1-paper{grid-template-columns:minmax(10.5rem,13rem) 1fr;align-items:stretch;gap:1.5rem;padding:1.1rem}
:where(.cf-coupon-wrapper-1) .cw1-paper:not(:has(> .cw1-value)){grid-template-columns:1fr}
:where(.cf-coupon-wrapper-1) .cw1-amount{font-size:clamp(3rem,9cqi,4.25rem);text-transform:var(--display-case, none)}
:where(.cf-coupon-wrapper-1) .cw1-body{text-align:left;padding:0.35rem 0.4rem 0.35rem 0}
:where(.cf-coupon-wrapper-1) .cw1-hint{justify-content:flex-start}
}
@media (prefers-reduced-motion: reduce){:where(.cf-coupon-wrapper-1) .cw1-code,:where(.cf-coupon-wrapper-1) .cw1-code-text,:where(.cf-coupon-wrapper-1) .cw1-code-act{transition:none}:where(.cf-coupon-wrapper-1) .cw1-code:hover,:where(.cf-coupon-wrapper-1) .cw1-code:active,.cf-coupon-wrapper-1[data-state="hover"] .cw1-code,.cf-coupon-wrapper-1[data-state="active"] .cw1-code{transform:none}.cf-coupon-wrapper-1:hover .cw1-snip svg,.cf-coupon-wrapper-1[data-state="hover"] .cw1-snip svg,.cf-coupon-wrapper-1[data-copied] .cw1-code-act svg{animation:none}}
`
type Status = "idle" | "copied" | "manual"
const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect
pieces/offer/coupon-wrapper-1/specimen.tsx 29 lines
import * as React from "react"
import { CouponWrapper1 } from "../coupon-wrapper-1"
import defaults from "../../studio-defaults.json"
export const states = ["default", "hover", "active", "success"]
const toNumber = (v: string) => Number(String(v).replace(/[^0-9.]/g, ""))
export default function CouponWrapper1Specimen({ state = "default" }: { state?: string }) {
const s = defaults.sample
const save = toNumber(s.regularPrice) - toNumber(s.price)
return (
<div>
<CouponWrapper1
tag="Clip & save"
amount={`$${save}`}
unit="Off"
title={s.name}
price={s.price}
regularPrice={s.regularPrice}
code="STARTER50"
hint="Tap to copy, then paste it at checkout."
state={state === "hover" || state === "active" || state === "success" ? state : undefined}
/>
</div>
)
}
| Name | Type | Details |
|---|---|---|
code OptionalCouponWrapper1 |
string |
Default "SAVE50"
|
amount OptionalCouponWrapper1 |
string |
|
unit OptionalCouponWrapper1 |
string |
Default "Off"
|
title OptionalCouponWrapper1 |
React.ReactNode |
|
price OptionalCouponWrapper1 |
string |
|
regularPrice OptionalCouponWrapper1 |
string |
|
hint OptionalCouponWrapper1 |
React.ReactNode |
Default "Tap the code to copy it, then paste it at checkout."
|
copiedHint OptionalCouponWrapper1 |
React.ReactNode |
Default "Copied! Paste it at checkout."
|
copyLabel OptionalCouponWrapper1 |
string |
Default "Copy"
|
copiedLabel OptionalCouponWrapper1 |
string |
Default "Copied"
|
tag OptionalCouponWrapper1 |
string |
|
state OptionalCouponWrapper1 |
"default" | "hover" | "active" | "success" |
|
onAction OptionalCouponWrapper1 |
(code: string) => void |
Default onCopy
|
onCopy OptionalCouponWrapper1 |
(code: string) => void |
|
children OptionalCouponWrapper1 |
React.ReactNode |
|
manualHint OptionalCouponWrapper1 |
React.ReactNode |
Default "Code selected. Press Ctrl+C (⌘C on Mac) to copy it."
|
priceLabel OptionalCouponWrapper1 |
string |
Default "Pay"
|
insteadOfLabel OptionalCouponWrapper1 |
string |
Default " instead of "
|
copyLabelTemplate OptionalCouponWrapper1 |
string |
Default "Copy coupon code {code}"
|
valueLabelTemplate OptionalCouponWrapper1 |
string |
Default "{amount} {unit}"
|
className OptionalCouponWrapper1 |
string |
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.
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