Case study card
Testimonial, quote and proof
A testimonial that leads with a measured result and a named person and company. No stars, stock avatars or invented quotes.
실제로 돌아가는 부품입니다. 눌러 보고 입력해 보세요.
내 앱에 넣기
아직 npm 패키지가 없어서 Taster 리포를 받아 그 안의 명령을 씁니다. 내 앱 폴더가 들어 있는 폴더에서 한 번만 받습니다.
git clone https://github.com/makim-414/taster.git && npm ci --prefix taster/packages/engine내 앱 폴더에서 이 부품을 넣습니다. 부품 파일과 토큰 파일이
src/components/taster에 들어갑니다.node ../taster/packages/engine/cli.mjs add marketing/case-study-card --from https://taster-six.vercel.app --dir src/components/taster부품은 Tailwind 클래스로 그리고, Taster 프리셋이 그 클래스를 토큰에 연결합니다. Tailwind CSS 를 설치하고,
tokens.css를 앱 루트에서 한 번 불러온 뒤, 앱 루트에 이 설정을 둡니다. 프리셋이 없으면 빌드는 되어도 부품이 스타일 없이 나옵니다.// tailwind.config.cjs module.exports = { presets: [require('./src/components/taster/tailwind-preset.cjs')], content: ['./index.html', './src/**/*.{ts,tsx}'], };Tailwind v3 는 이 파일을 그대로 읽습니다. v4 는 Tailwind 를 불러오는
src/의 스타일시트 맨 위에 이 두 줄을 넣습니다.@import "tailwindcss"; @config "../tailwind.config.cjs";tokens.css는:root에--bg,--text,--border,--accent를 정의합니다. 내 앱의 스타일시트가 같은 이름을 뒤에서 다시 정의하면 그쪽 색이 이깁니다. 새 Vite 앱의 스타터 CSS 처럼 그런 변수가 있으면 지우거나 이름을 바꾸세요.
언제 쓰나요
- Outcome quote cardA testimonial that leads with a measured result and a named person and company. No stars, stock avatars or invented quotes.
- Media tile cardThe result, product or article image is the tile; the caption is thin and sits below or on a bottom scrim. Hub cards and article cards follow the same shape.
대신 없애 주는 AI 티
- Drawn mockup instead of the real thing (AC-17)
- Fake trust signals (CMP-08)
- Stretched image (CMP-12)
- Three icon cards in a row (LAY-02)
정보
코드 보기
import * as React from 'react'
import { cn } from '../blocks/_cn'
import { safeHref } from '../blocks/_url'
// Case study card: a link to one customer story that leads with what changed, measured, and only then
// who it was. A cover image of the real work is optional. The whole card is one link with one focus ring.
// Follows patterns/outcome-quote-card (the result line first, tabular figures, a source period) and
// patterns/media-tile-card (one image ratio for every card in a row). No logo tile, no star row.
// Lay several out with CaseStudyGrid, which keeps cover ratios equal and lets text set the height.
// Original code, MIT.
export interface CaseStudy {
href: string
/** The measured change, for example "Checkout time down from 4 to 2 minutes". */
result: string
/** Where and when it was measured, for example "Median of 1,200 orders, Mar to May". */
measured?: string
/** Who, written out: organization and the kind of team. */
who: string
summary: string
cover?: { src: string; alt: string }
linkLabel?: string
/** Language of this story, for example "ko", when it differs from the page. */
lang?: string
}
export interface CaseStudyCardProps extends React.HTMLAttributes<HTMLElement> {
study: CaseStudy
as?: 'h3' | 'h4'
}
const KEEP = 'break-keep [overflow-wrap:break-word]'
export function CaseStudyCard({ study, as: Heading = 'h3', className, ...props }: CaseStudyCardProps) {
return (
<article lang={study.lang} className={cn('min-w-0', className)} {...props}>
<a
href={safeHref(study.href)}
className="group flex h-full flex-col rounded-xl outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-[color:var(--bg)]"
>
{study.cover ? (
<div className="mb-5 aspect-[16/10] overflow-hidden rounded-xl bg-bg-sunken">
<img src={study.cover.src} alt={study.cover.alt} loading="lazy" className="h-full w-full object-cover" />
</div>
) : null}
<Heading className={cn('text-h2 font-semibold leading-[var(--lh-snug)] tabular-nums text-text text-balance', KEEP)}>{study.result}</Heading>
{study.measured ? <p className={cn('mt-1 text-label text-text-subtle', KEEP)}>{study.measured}</p> : null}
<p className={cn('mt-4 text-body font-medium text-text', KEEP)}>{study.who}</p>
<p className={cn('mt-1 flex-1 text-body text-text-muted', KEEP)}>{study.summary}</p>
<span className="mt-5 inline-flex items-center gap-2 text-body font-medium text-text underline-offset-4 group-hover:underline">
{study.linkLabel ?? 'Read the story'}
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden>
<path d="M5 12h14" />
<path d="m13 6 6 6-6 6" />
</svg>
</span>
</a>
</article>
)
}
export interface CaseStudyGridProps extends React.HTMLAttributes<HTMLDivElement> {
studies: CaseStudy[]
as?: 'h3' | 'h4'
}
export function CaseStudyGrid({ studies, as, className, ...props }: CaseStudyGridProps) {
return (
<div className={cn('grid gap-x-8 gap-y-12 md:grid-cols-2', studies.length >= 3 && 'lg:grid-cols-3', className)} {...props}>
{studies.map((s) => (
<CaseStudyCard key={s.href} study={s} as={as} />
))}
</div>
)
}