跳至正文
获取 Pro
东方雅集E.01

宋窑釉面容器

FreeRegistry
components/linyi/ru-kiln-surface.tsx
motion
"use client";
 
import * as React from "react";
import { motion, useMotionValue, useTransform } from "motion/react";
import { cn } from "@/lib/cn";
import { SPRING_SMOOTH, SPRING_SNAPPY } from "@/lib/motion";
 
export type SongKilnPreset = "ru" | "guan" | "ge" | "jian" | "ding";
 
export interface RuKilnSurfaceProps {
kiln?: SongKilnPreset;
onKilnChange?: (kiln: SongKilnPreset) => void;
sheen?: number;
mineral?: number;
showSelector?: boolean;
compact?: boolean;
children?: React.ReactNode;
className?: string;
}
 
interface KilnStyleSpec {
label: string;
era: string;
hex: string;
note: string;
surfaceBg: string;
edgeRim: string;
innerGlow: string;
sheenColor: string;
fg: string;
fgSub: string;
pillBg: string;
}
 
const KILN_SPECS: Record<SongKilnPreset, KilnStyleSpec> = {
ru: {
label: "汝窑 · 天青",
era: "北宋",
hex: "#BACCC9", // verify-registry: allow-hex 界面展示的釉色色号文本,属内容数据
note: "似玉非玉,温润天青釉下透微暖玛瑙脂光。",
surfaceBg:
"radial-gradient(120% 95% at 24% 14%, rgba(235, 245, 243, 0.92) 0%, rgba(190, 210, 207, 0.96) 52%, rgba(154, 178, 175, 1) 100%)",
edgeRim: "inset 0 0 0 1px rgba(74, 62, 50, 0.24), inset 0 2px 6px rgba(255, 255, 255, 0.62), inset 0 -10px 22px rgba(72, 60, 48, 0.16)",
innerGlow: "radial-gradient(85% 65% at 75% 86%, rgba(114, 92, 74, 0.14), transparent 72%)",
sheenColor: "rgba(255, 254, 249, 0.56)",
fg: "var(--oriental-ru-kiln-ru-fg, #1D2B29)",
fgSub: "rgba(29, 43, 41, 0.72)",
pillBg: "var(--oriental-ru-kiln-ru-pill-bg, #B6C9C6)",
},
guan: {
label: "官窑 · 粉青",
era: "南宋",
hex: "#CFDAD6", // verify-registry: allow-hex 界面展示的釉色色号文本,属内容数据
note: "紫口铁足,厚釉如凝脂,色介粉青月白之间。",
surfaceBg:
"radial-gradient(120% 95% at 26% 12%, rgba(244, 248, 246, 0.94) 0%, rgba(209, 221, 217, 0.96) 55%, rgba(178, 193, 189, 1) 100%)",
edgeRim: "inset 0 0 0 1px rgba(82, 68, 56, 0.26), inset 0 2px 6px rgba(255, 255, 255, 0.7), inset 0 -12px 24px rgba(68, 54, 44, 0.18)",
innerGlow: "radial-gradient(80% 60% at 80% 90%, rgba(92, 76, 62, 0.16), transparent 70%)",
sheenColor: "rgba(255, 255, 255, 0.62)",
fg: "var(--oriental-ru-kiln-guan-fg, #202A27)",
fgSub: "rgba(32, 42, 39, 0.72)",
pillBg: "var(--oriental-ru-kiln-guan-pill-bg, #CEDAD6)",
},
ge: {
label: "哥窑 · 米黄",
era: "宋",
hex: "#DED5C3", // verify-registry: allow-hex 界面展示的釉色色号文本,属内容数据
note: "酥油润泽,暖米黄釉面隐现柔和窑变玉晕。",
surfaceBg:
"radial-gradient(120% 95% at 22% 16%, rgba(248, 243, 232, 0.95) 0%, rgba(224, 214, 194, 0.96) 56%, rgba(196, 183, 158, 1) 100%)",
edgeRim: "inset 0 0 0 1px rgba(96, 74, 42, 0.28), inset 0 2px 5px rgba(255, 252, 244, 0.72), inset 0 -12px 22px rgba(96, 74, 42, 0.18)",
innerGlow: "radial-gradient(85% 65% at 72% 84%, rgba(132, 98, 52, 0.16), transparent 72%)",
sheenColor: "rgba(255, 250, 238, 0.62)",
fg: "var(--oriental-ru-kiln-ge-fg, #2F261A)",
fgSub: "rgba(47, 38, 26, 0.72)",
pillBg: "var(--oriental-ru-kiln-ge-pill-bg, #DDD3C0)",
},
jian: {
label: "建窑 · 曜变",
era: "宋",
hex: "#191716", // verify-registry: allow-hex 界面展示的釉色色号文本,属内容数据
note: "乌金黑釉含铁结晶,受光处浮现克制靛褐油滴晕。",
surfaceBg:
"radial-gradient(110% 90% at 28% 18%, var(--oriental-ru-kiln-jian-surface-bg-1, #342E28) 0%, var(--oriental-ru-kiln-jian-surface-bg-2, #1B1917) 52%, var(--oriental-ru-kiln-jian-surface-bg-3, #0F0E0D) 100%)",
edgeRim: "inset 0 0 0 1px rgba(212, 182, 128, 0.22), inset 0 1.5px 4px rgba(255, 240, 212, 0.14), inset 0 -12px 24px rgba(0, 0, 0, 0.65)",
innerGlow:
"radial-gradient(circle 120px at 78% 72%, rgba(86, 122, 148, 0.22), rgba(176, 132, 74, 0.12) 48%, transparent 74%)",
sheenColor: "rgba(182, 206, 224, 0.22)",
fg: "var(--oriental-ru-kiln-jian-fg, #F3EDE2)",
fgSub: "rgba(243, 237, 226, 0.68)",
pillBg: "var(--oriental-ru-kiln-jian-pill-bg, #211E1C)",
},
ding: {
label: "定窑 · 牙白",
era: "北宋",
hex: "#F4EFE4", // verify-registry: allow-hex 界面展示的釉色色号文本,属内容数据
note: "温润象牙白釉,薄处泛暖乳黄,触感若素玉。",
surfaceBg:
"radial-gradient(120% 95% at 24% 14%, var(--oriental-ru-kiln-ding-surface-bg-1, #FFFDF9) 0%, var(--oriental-ru-kiln-ding-surface-bg-2, #F4EFE4) 56%, var(--oriental-ru-kiln-ding-surface-bg-3, #E8E0D0) 100%)",
edgeRim: "inset 0 0 0 1px rgba(108, 92, 68, 0.18), inset 0 2px 6px rgba(255, 255, 255, 0.92), inset 0 -10px 20px rgba(112, 94, 66, 0.11)",
innerGlow: "radial-gradient(85% 65% at 76% 88%, rgba(164, 138, 96, 0.12), transparent 72%)",
sheenColor: "rgba(255, 255, 255, 0.78)",
fg: "var(--oriental-ru-kiln-ding-fg, #252019)",
fgSub: "rgba(37, 32, 25, 0.68)",
pillBg: "var(--oriental-ru-kiln-ding-pill-bg, #F4EFE4)",
},
};
 
const KILN_KEYS: SongKilnPreset[] = ["ru", "guan", "ge", "jian", "ding"];
 
export function RuKilnSurface({
kiln,
onKilnChange,
sheen = 0.7,
mineral = 0.18,
showSelector = true,
compact = false,
children,
className,
}: RuKilnSurfaceProps) {
const [internalKiln, setInternalKiln] = React.useState<SongKilnPreset>(kiln ?? "ru");
// 釉面脂光跟随属于逐帧高频数据:用 MotionValue 直驱 transform 与 opacity,
// 同时避免外层 layout 容器在每次指针移动时被重渲染并重新测量布局
const lusterX = useMotionValue(32);
const lusterY = useMotionValue(24);
const lusterOpacity = useMotionValue(sheen * 0.45);
const lusterTx = useTransform(lusterX, (v) => `${v - 50}%`);
const lusterTy = useTransform(lusterY, (v) => `${v - 50}%`);
const filterId = React.useId().replace(/:/g, "");
 
React.useEffect(() => {
if (kiln) setInternalKiln(kiln);
}, [kiln]);
 
React.useEffect(() => {
lusterOpacity.set(sheen * 0.45);
}, [sheen, lusterOpacity]);
 
const activeKiln = kiln ?? internalKiln;
const spec = KILN_SPECS[activeKiln];
 
const selectKiln = (next: SongKilnPreset) => {
setInternalKiln(next);
onKilnChange?.(next);
};
 
const handlePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
const r = e.currentTarget.getBoundingClientRect();
if (!r.width || !r.height) return;
lusterX.set(((e.clientX - r.left) / r.width) * 100);
lusterY.set(((e.clientY - r.top) / r.height) * 100);
lusterOpacity.set(sheen);
};
 
const handlePointerLeave = () => {
lusterOpacity.set(sheen * 0.45);
};
 
return (
<div className={cn("w-full space-y-2.5", compact ? "max-w-[272px]" : "max-w-[440px]", className)}>
<motion.div
layout
transition={SPRING_SMOOTH}
onPointerMove={handlePointerMove}
onPointerLeave={handlePointerLeave}
className={cn(
"relative overflow-hidden rounded-[18px] transition-[background,box-shadow,color] duration-500 ease-out select-none",
compact ? "p-4 min-h-[146px]" : "p-6 min-h-[208px]",
"flex flex-col justify-between"
)}
style={{
background: spec.surfaceBg,
boxShadow: `${spec.edgeRim}, 0 14px 32px -18px rgba(34, 28, 20, 0.34)`,
color: spec.fg,
}}
>
{/* Subsurface kiln-pooling warmth */}
<div className="pointer-events-none absolute inset-0" style={{ background: spec.innerGlow }} />
 
{/* Organic fired ceramic mineral micro-speckle (non-linear texture) */}
<svg
aria-hidden="true"
className="pointer-events-none absolute inset-0 h-full w-full"
style={{
opacity: mineral,
mixBlendMode: activeKiln === "jian" ? "screen" : "multiply",
}}
>
<filter id={`kiln-grain-${filterId}`}>
<feTurbulence
type="fractalNoise"
baseFrequency="0.72"
numOctaves="3"
seed={activeKiln === "jian" ? 11 : 4}
stitchTiles="stitch"
/>
<feColorMatrix type="saturate" values="0.22" />
</filter>
<rect width="100%" height="100%" filter={`url(#kiln-grain-${filterId})`} />
</svg>
 
{/* Pointer-following glazed jade-fat luster */}
<motion.div
aria-hidden="true"
className="pointer-events-none absolute inset-0 transition-opacity duration-300"
style={{
x: lusterTx,
y: lusterTy,
opacity: lusterOpacity,
background: `radial-gradient(circle ${compact ? 110 : 170}px at 50% 50%, ${spec.sheenColor} 0%, transparent 72%)`,
}}
/>
 
{children ?? (
<>
<div className="relative z-10 flex items-center justify-between gap-2">
<div className="flex items-center gap-2">
<span className="font-serif text-sm font-medium tracking-wide">{spec.label}</span>
<span
className="rounded-full px-2 py-0.5 text-[10px] font-serif"
style={{
background:
activeKiln === "jian" ? "rgba(255,255,255,0.09)" : "rgba(30,26,20,0.07)",
}}
>
{spec.era}
</span>
</div>
<span className="font-mono-num text-[11px]" style={{ color: spec.fgSub }}>
{spec.hex}
</span>
</div>
 
<div className="relative z-10 space-y-2 pt-4">
<p
className={cn("font-serif leading-relaxed", compact ? "text-xs" : "text-[13px]")}
style={{ color: spec.fgSub }}
>
{spec.note}
</p>
{!compact && (
<div className="flex items-center justify-between text-[10px] font-mono-num pt-2" style={{ color: spec.fgSub }}>
<span>GLAZE SHEEN {Math.round(sheen * 100)}%</span>
<span>SUBSURFACE · 窑变脂光</span>
</div>
)}
</div>
</>
)}
</motion.div>
 
{showSelector && (
<div className="flex items-center justify-between gap-1.5 rounded-pill border border-line bg-surface px-2 py-1.5">
<div className="flex items-center gap-1">
{KILN_KEYS.map((key) => {
const item = KILN_SPECS[key];
const active = activeKiln === key;
return (
<button
key={key}
type="button"
onClick={() => selectKiln(key)}
aria-pressed={active}
className={cn(
"relative inline-flex items-center gap-1.5 rounded-pill px-2.5 py-1 text-[11px] font-medium cursor-pointer transition-colors",
active ? "text-fg" : "text-fg-secondary hover:text-fg"
)}
>
{active && (
<motion.span
layoutId={`ru-kiln-pill-${filterId}`}
transition={SPRING_SNAPPY}
className="absolute inset-0 rounded-pill bg-well"
/>
)}
<span
className="relative z-10 h-2.5 w-2.5 rounded-full border border-black/15 flex-shrink-0"
style={{ background: item.pillBg }}
/>
<span className="relative z-10">{item.label.slice(0, 1)}</span>
</button>
);
})}
</div>
{!compact && (
<span className="font-mono-num text-[10px] pr-1.5 text-fg-muted">
切换釉面质感
</span>
)}
</div>
)}
</div>
);
}