形变 · 实验演示
形态接力
让按钮、胶囊和卡片共用一个连续变化的形体。
适用场景
产品状态讲解、交互概念稿、轻量界面演示。
同一个容器先拉长、变圆,再向下展开为卡片。内部文字错开切换,保留形体连续性。
任务提示词
已带入当前预览参数。可交给支持代码生成的工具,生成后在目标项目中检查效果。
请制作一个可复用的「形态接力」网页动效。
用途:让按钮、胶囊和卡片共用一个连续变化的形体。适用于产品状态讲解、交互概念稿、轻量界面演示。
运行环境:React 19 + TypeScript + CSS,现代浏览器;可在 Vite 或支持客户端组件的项目中运行。只使用 React 与浏览器 API,不依赖动效引擎,不连接 AI 或渲染服务。
输入与当前参数:
文字:"开始一个想法"
主色:#2455e8
速度:1 倍(1 倍为基准,2 倍用时减半)
时长:本效果基准总时长 5.6 秒,当前速度下约 5.6 秒;两者都指从起点播放到终态的完整过程。
动作顺序:
1. 以带文字的短按钮开始,稍作停留。
2. 同一容器连续增加宽度与圆角,变为胶囊;原文字淡出,状态文字接上。
3. 胶囊向下展开,圆角收小,形成带标题和内容的卡片,最后停住。
可调整参数:将上述输入暴露为组件属性;内容、颜色和速度改变后立即更新,保留用户的暂停状态。
输出要求:交付完整的 TypeScript 客户端组件、所需 CSS 和调用示例,带齐辅助函数与原创图形素材;不要用静态封面替代动画。提供播放、暂停、重播,演示只在自己的容器内绘制。
检查要点:正常播放到清晰终态;暂停后画面保持,继续播放接上原进度;重播从头开始;参数值与画面一致;中文在手机宽度下不溢出;键盘可操作;离开视口或后台标签页停止动画帧;prefers-reduced-motion 时显示静态终态;避免强闪烁。
本效果边界:这是按钮到卡片的形态演示,内部按钮不触发业务操作。 只演示三种状态,不包含拖拽、真实加载或任意 SVG 路径变形。
这是实现任务说明,生成结果仍需在目标项目运行和检查,不保证不同模型一次生成就能完全复现。实现与复用
同一个 DOM 元素连续插值宽度、高度与圆角;内容层使用独立透明度时间窗。
运行环境:React 19、TypeScript 和现代浏览器。依赖只有 React 与浏览器 API,无需安装动效库。
把下面三个源文件放在同一目录,使用该目录旁的调用示例。组件自带样式,拼贴图形也包含在源码里。
'use client';
import { useCallback, useState } from 'react';
import { MotionDemo } from './motion-demo';
export default function Example() {
const [playing, setPlaying] = useState(false);
const [run, setRun] = useState(0);
const complete = useCallback(() => setPlaying(false), []);
return (
<div>
<MotionDemo
kind="shape-morph"
options={{
"text": "开始一个想法",
"color": "#2455e8",
"speed": 1,
"from": 0,
"to": 128,
"steps": [
"收集想法",
"整理线索",
"做出初稿",
"回看修改"
]
}}
playing={playing}
replayKey={run}
onComplete={complete}
/>
<button onClick={() => setPlaying(value => !value)}>
{playing ? '暂停' : '播放'}
</button>
<button onClick={() => { setRun(value => value + 1); setPlaying(true); }}>
重播
</button>
</div>
);
}
查看完整可复用源码 · 3 个文件
'use client';
import { useEffect, useMemo, useRef, useState } from 'react';
import {
characters,
clamp,
contrastInk,
countAt,
DURATIONS,
ease,
mix,
morphAt,
type MotionKind,
type MotionOptions,
} from './motion-core';
import './motion-demo.css';
export type PlaybackStatus =
| 'playing'
| 'paused'
| 'complete'
| 'reduced'
| 'offscreen';
function Collage({
progress,
text,
color,
}: {
progress: number;
text: string;
color: string;
}) {
const images = useMemo(() => {
const svg = (body: string) =>
`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="280" height="320" viewBox="0 0 280 320">${body}</svg>`)}`;
return [
svg(
`<rect width="280" height="320" fill="#e3e9dd"/><circle cx="192" cy="83" r="46" fill="${color}"/><path d="M0 280L90 136L190 282L244 205L280 255V320H0Z" fill="#18201d"/><path d="M0 302L102 246L208 309L280 273V320H0Z" fill="#fafaf7"/>`,
),
svg(
`<rect width="280" height="320" fill="#f2e883"/><path d="M42 54H238V250H42Z" fill="#fafaf7"/><circle cx="140" cy="152" r="75" fill="${color}"/><path d="M140 77V227M65 152H215" stroke="#f2e883" stroke-width="18"/><path d="M40 283H165" stroke="#18201d" stroke-width="3"/>`,
),
svg(
`<rect width="280" height="320" fill="#fafaf7"/><g fill="none" stroke="${color}" stroke-width="10"><ellipse cx="140" cy="150" rx="95" ry="42" transform="rotate(-36 140 150)"/><ellipse cx="140" cy="150" rx="95" ry="42" transform="rotate(36 140 150)"/></g><circle cx="140" cy="150" r="21" fill="#18201d"/><circle cx="216" cy="100" r="14" fill="#f2e883"/>`,
),
];
}, [color]);
return (
<div className="motion-collage">
{images.map((src, i) => {
const t = ease((progress - i * 0.16) / 0.45);
const angle = [-12, 10, -5][i];
return (
// oxlint-disable-next-line next/no-img-element -- Inline SVGs keep the copied module independent of an image service.
<img
key={i}
src={src}
alt=""
draggable={false}
style={{
opacity: t,
transform: `translate(${(1 - t) * (i % 2 ? 75 : -75)}px, ${(1 - t) * 60}px) rotate(${angle + (1 - t) * 10}deg) scale(${mix(0.8, 1, t)})`,
}}
/>
);
})}
<div
className="motion-collage-title"
style={{
opacity: ease((progress - 0.57) / 0.38),
transform: `translateY(${(1 - ease((progress - 0.57) / 0.38)) * 30}px)`,
}}
>
<span>灵感切片 / 01</span>
<strong>{text}</strong>
</div>
</div>
);
}
type Dot = { x: number; y: number; sx: number; sy: number };
function DotCanvas({
progress,
text,
color,
}: {
progress: number;
text: string;
color: string;
}) {
const canvas = useRef<HTMLCanvasElement>(null);
const fontSizeRef = useRef(25);
const [size, setSize] = useState({ width: 0, height: 0 });
const [dots, setDots] = useState<Dot[]>([]);
useEffect(() => {
const el = canvas.current;
if (!el) return;
const measure = () =>
setSize({
width: Math.round(el.clientWidth),
height: Math.round(el.clientHeight),
});
const observer = new ResizeObserver(([entry]) =>
setSize({
width: Math.round(entry.contentRect.width),
height: Math.round(entry.contentRect.height),
}),
);
observer.observe(el);
// 几何兜底:嵌入 webview 失焦时 RO 可能停摆,先同步量一次并监听 resize。
measure();
window.addEventListener('resize', measure);
return () => {
observer.disconnect();
window.removeEventListener('resize', measure);
};
}, []);
useEffect(() => {
if (!size.width || !size.height) return;
let cancelled = false;
const sample = () => {
if (cancelled) return;
const mask = document.createElement('canvas');
mask.width = size.width;
mask.height = size.height;
const ctx = mask.getContext('2d');
if (!ctx) return;
// R6:按容器选可读字号与必要换行——在 1..4 行内取最大可行字号,窄屏不再单行压小。
const chars = characters(text);
const n = Math.max(chars.length, 1);
let fontSize = 0;
let cols = n;
let rows = 1;
for (let r = 1; r <= Math.min(n, 4); r++) {
const c = Math.ceil(n / r);
const fs = Math.min((size.height * 0.86) / r * 0.8, (size.width * 0.94) / c * 0.98);
if (fs > fontSize) {
fontSize = fs;
cols = c;
rows = r;
}
}
fontSize = Math.max(fontSize, 12);
fontSizeRef.current = fontSize;
const lines: string[] = [];
for (let i = 0; i < n; i += cols) lines.push(chars.slice(i, i + cols).join(''));
ctx.font = `800 ${fontSize}px -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
const lineH = (size.height * 0.86) / rows;
lines.forEach((line, i) => {
ctx.fillText(line, size.width / 2, size.height / 2 + (i - (lines.length - 1) / 2) * lineH);
});
const pixels = ctx.getImageData(0, 0, size.width, size.height).data;
const candidates: Dot[] = [];
const gap = Math.max(3, Math.min(9, Math.round(fontSize / 14)));
for (let y = 0; y < size.height; y += gap)
for (let x = 0; x < size.width; x += gap) {
if (pixels[(y * size.width + x) * 4 + 3] > 120) {
const seed = y * size.width + x + 1;
candidates.push({
x,
y,
sx:
((((Math.sin(seed * 12.9898) * 43758.5453) % 1) + 1) % 1) *
size.width,
sy:
((((Math.sin(seed * 78.233) * 12345.6789) % 1) + 1) % 1) *
size.height,
});
}
}
const stride = Math.max(1, Math.ceil(candidates.length / 1400));
setDots(candidates.filter((_, index) => index % stride === 0));
};
sample();
void document.fonts.ready.then(sample);
document.fonts.addEventListener('loadingdone', sample);
return () => {
cancelled = true;
document.fonts.removeEventListener('loadingdone', sample);
};
}, [size.width, size.height, text]);
useEffect(() => {
const el = canvas.current;
if (!el || !size.width || !size.height) return;
const dpr = Math.min(devicePixelRatio || 1, 2);
const width = Math.round(size.width * dpr),
height = Math.round(size.height * dpr);
if (el.width !== width || el.height !== height) {
el.width = width;
el.height = height;
}
const ctx = el.getContext('2d');
if (!ctx) return;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
ctx.clearRect(0, 0, size.width, size.height);
ctx.fillStyle = color;
const t = ease((progress - 0.08) / 0.84);
ctx.globalAlpha = mix(0.35, 1, t);
const radius = Math.max(1.1, Math.min(Math.max(3, Math.min(9, Math.round(fontSizeRef.current / 14))) * 0.34, 3.2));
for (const dot of dots) {
ctx.beginPath();
ctx.arc(
mix(dot.sx, dot.x, t),
mix(dot.sy, dot.y, t),
radius,
0,
Math.PI * 2,
);
ctx.fill();
}
}, [progress, dots, size.width, size.height, color]);
return (
<canvas ref={canvas} className="motion-dots" data-points={dots.length} />
);
}
export function MotionDemo({
kind,
options,
playing = false,
replayKey = 0,
compact = false,
onComplete,
onStatusChange,
}: {
kind: MotionKind;
options: MotionOptions;
playing?: boolean;
replayKey?: number;
compact?: boolean;
onComplete?: () => void;
onStatusChange?: (status: PlaybackStatus) => void;
}) {
const root = useRef<HTMLElement>(null);
const progress = useRef(1);
const complete = useRef(onComplete);
const lastReplay = useRef(replayKey);
const [frame, setFrame] = useState(1);
const [inView, setInView] = useState(false);
const [hasEntered, setHasEntered] = useState(false);
const [visible, setVisible] = useState(true);
const [reduced, setReduced] = useState(false);
useEffect(() => {
complete.current = onComplete;
}, [onComplete]);
useEffect(() => {
const media = matchMedia('(prefers-reduced-motion: reduce)');
const preference = () => setReduced(media.matches);
const visibility = () => setVisible(!document.hidden);
preference();
visibility();
media.addEventListener('change', preference);
document.addEventListener('visibilitychange', visibility);
const observer = new IntersectionObserver(
([entry]) => {
setInView(entry.isIntersecting);
if (entry.isIntersecting) setHasEntered(true);
},
{ threshold: 0.1 },
);
if (root.current) observer.observe(root.current);
// 几何兜底:部分嵌入 webview 失焦时 IO/rAF 停摆,静止在视口内的舞台也应进入已进入状态。
let fallbackTimer: ReturnType<typeof setInterval> | undefined;
const geometricEnter = () => {
const el = root.current;
if (!el) return;
const rect = el.getBoundingClientRect();
if (rect.top < window.innerHeight && rect.bottom > 0) {
setHasEntered(true);
if (fallbackTimer) clearInterval(fallbackTimer);
window.removeEventListener('scroll', geometricEnter);
}
};
geometricEnter();
if (!fallbackTimer) {
fallbackTimer = setInterval(geometricEnter, 700);
window.addEventListener('scroll', geometricEnter, { passive: true });
}
return () => {
if (fallbackTimer) clearInterval(fallbackTimer);
window.removeEventListener('scroll', geometricEnter);
observer.disconnect();
media.removeEventListener('change', preference);
document.removeEventListener('visibilitychange', visibility);
};
}, []);
useEffect(() => {
if (replayKey !== lastReplay.current) {
progress.current = 0;
lastReplay.current = replayKey;
}
if (!playing || !inView || !visible || reduced) return;
if (progress.current >= 1) progress.current = 0;
let last = performance.now();
let raf = 0;
const tick = (now: number) => {
progress.current = clamp(
progress.current + ((now - last) * options.speed) / DURATIONS[kind],
);
last = now;
setFrame(progress.current);
if (progress.current < 1) raf = requestAnimationFrame(tick);
else complete.current?.();
};
raf = requestAnimationFrame(tick);
return () => cancelAnimationFrame(raf);
}, [playing, inView, visible, reduced, options.speed, kind, replayKey]);
const status: PlaybackStatus = reduced
? 'reduced'
: !inView || !visible
? 'offscreen'
: frame >= 1
? 'complete'
: playing
? 'playing'
: 'paused';
useEffect(() => {
onStatusChange?.(status);
}, [status, onStatusChange]);
const p = reduced ? 1 : frame;
const letters = characters(options.text);
const morph = morphAt(p);
const ink = contrastInk(options.color);
const number = new Intl.NumberFormat('zh-CN', {
maximumFractionDigits: 2,
}).format(countAt(options.from, options.to, p));
const darkCanvas =
ink === '#000000' &&
['word-reveal', 'count-up', 'dot-assembly'].includes(kind);
return (
<figure
ref={root}
className={`motion-stage${compact ? ' motion-stage--compact' : ''}${darkCanvas ? ' motion-stage--dark' : ''}`}
aria-label={`${options.text},动效预览`}
data-motion={kind}
data-progress={p.toFixed(4)}
data-status={status}
style={
{
'--motion-color': options.color,
'--motion-ink': ink,
} as React.CSSProperties
}
>
<div className="motion-art" aria-hidden="true">
{kind === 'word-reveal' ? (
<div className="motion-type">
<span className="motion-art-note">一句话,从节奏开始</span>
<div className="motion-letters">
{letters.map((letter, i) => {
const t = ease(
(p - (i / Math.max(letters.length, 1)) * 0.65) / 0.3,
);
return (
<span
key={i}
style={{
opacity: t,
transform: `translateY(${(1 - t) * 24}px)`,
}}
>
{letter === ' ' ? '\u00a0' : letter}
</span>
);
})}
</div>
<span
className="motion-type-rule"
style={{ transform: `scaleX(${ease(p)})` }}
/>
</div>
) : null}
{kind === 'count-up' ? (
<div className="motion-counter">
<span className="motion-art-note">{options.text}</span>
<strong>{number}</strong>
<span className="motion-counter-track">
<i style={{ transform: `scaleX(${p})` }} />
</span>
<small>演示数字</small>
</div>
) : null}
{kind === 'step-flow' ? (
<ol className="motion-steps">
{options.steps.map((step, i) => {
const t = ease((p - (i * 0.7) / options.steps.length) / 0.23);
const line = ease(
(p - ((i + 0.65) * 0.7) / options.steps.length) / 0.18,
);
return (
<li
key={i}
style={{
opacity: t,
transform: `translateX(${(1 - t) * -20}px)`,
}}
>
<span>{String(i + 1).padStart(2, '0')}</span>
<strong>{step}</strong>
{i < options.steps.length - 1 ? (
<i style={{ transform: `scaleY(${line})` }} />
) : null}
</li>
);
})}
</ol>
) : null}
{kind === 'shape-morph' ? (
<div
className="motion-morph-shape"
style={{
width: `${morph.width}%`,
height: morph.height * (compact ? 0.8 : 1),
borderRadius: morph.radius,
color: ink,
}}
>
<div
className="motion-morph-button"
style={{ opacity: 1 - clamp((p - 0.18) / 0.12) }}
>
<strong>{options.text}</strong>
<span>↗</span>
</div>
<div
className="motion-morph-capsule"
style={{
opacity:
clamp((p - 0.3) / 0.12) * (1 - clamp((p - 0.57) / 0.1)),
}}
>
<i />
<span>想法展开中</span>
</div>
<div
className="motion-morph-card"
style={{ opacity: clamp((p - 0.74) / 0.2) }}
>
<small>一张想法卡片</small>
<strong>{options.text}</strong>
<span>从一个动作,展开一段内容。</span>
</div>
</div>
) : null}
{kind === 'layered-collage' ? (
<Collage progress={p} text={options.text} color={options.color} />
) : null}
{kind === 'dot-assembly' && hasEntered ? (
<DotCanvas progress={p} text={options.text} color={options.color} />
) : null}
</div>
</figure>
);
}
export type MotionKind =
| 'word-reveal'
| 'count-up'
| 'step-flow'
| 'shape-morph'
| 'layered-collage'
| 'dot-assembly';
/** 参数面板可展示的输入种类:主文字、数值区间、步骤列表。 */
export type MotionField = 'text' | 'numbers' | 'steps';
export type MotionOptions = {
text: string;
color: string;
speed: number;
from: number;
to: number;
steps: string[];
/** 只供两条配方案例使用的显式 typed 输入;普通步骤仍由 steps 承载。 */
recipe?: RecipeItemData[];
};
/** 配方数据共享于站点预览与可复制引擎,不依赖 case-timeline。 */
export interface RecipeItemData {
id: string;
t: 'liquid' | 'ice' | 'stir' | 'garnish';
name: string;
amount?: number;
unit?: '份';
color?: string;
off?: boolean;
}
export type RecipeType = RecipeItemData['t'];
export const RECIPE_TYPES: RecipeType[] = ['liquid', 'ice', 'stir', 'garnish'];
export const RECIPE_TYPE_LABEL: Record<RecipeType, string> = {
liquid: '液体', ice: '加冰动作', stir: '搅拌动作', garnish: '装饰动作',
};
export const RECIPE_DEFAULT_COLOR = '#d97706';
/** 严格解析固定身份的配方:统一「份」;不接受符号/单位猜测或混量纲。 */
export function parseRecipe(input: unknown): RecipeItemData[] | undefined {
if (!Array.isArray(input) || input.length === 0) return undefined;
const out: RecipeItemData[] = [];
const ids = new Set<string>();
for (const raw of input) {
if (typeof raw !== 'object' || raw === null) return undefined;
const it = raw as Record<string, unknown>;
if (typeof it.id !== 'string' || !it.id.trim() || ids.has(it.id.trim())) return undefined;
ids.add(it.id.trim());
if (typeof it.t !== 'string' || !RECIPE_TYPES.includes(it.t as RecipeType)) return undefined;
const isOff = it.off === true;
const name = typeof it.name === 'string' ? it.name.trim() : '';
if (!isOff && (!name || Array.from(name).length > 12)) return undefined;
const item: RecipeItemData = { id: it.id.trim(), t: it.t as RecipeType, name };
if (isOff) item.off = true;
if (isOff) { out.push(item); continue; }
if (item.t === 'liquid') {
if (typeof it.amount !== 'number' || !Number.isFinite(it.amount) || it.amount < 0 || it.unit !== '份') return undefined;
item.amount = it.amount;
item.unit = '份';
item.color = typeof it.color === 'string' && /^#[\da-f]{6}$/i.test(it.color) ? it.color : RECIPE_DEFAULT_COLOR;
}
out.push(item);
}
return out.some((item) => item.off !== true) ? out : undefined;
}
export function activeRecipe(items: RecipeItemData[]): RecipeItemData[] {
return items.filter((item) => item.off !== true);
}
/** 无效 override 回退完整默认配方;调用 UI 必须同步显示回退提示。 */
export function effectiveRecipe(items: RecipeItemData[], override?: unknown): RecipeItemData[] {
return activeRecipe(parseRecipe(override) ?? parseRecipe(items) ?? []);
}
/** 将液体总量按杯内高度归一化;因此不溢杯,零量贡献为零。 */
export function liquidLevels(items: RecipeItemData[]) {
const liquids = activeRecipe(items).filter((item) => item.t === 'liquid');
const maxAmount = liquids.reduce((max, item) => Math.max(max, item.amount ?? 0), 0);
const totalScaled = maxAmount > 0
? liquids.reduce((sum, item) => sum + (item.amount ?? 0) / maxAmount, 0)
: 0;
let accumulated = 0;
return liquids.map((item) => {
const amount = item.amount ?? 0;
const scaled = maxAmount > 0 ? amount / maxAmount : 0;
const cumRatio = totalScaled > 0 ? accumulated / totalScaled : 0;
const ratio = totalScaled > 0 ? scaled / totalScaled : 0;
accumulated += scaled;
return { item, cumRatio, ratio };
});
}
/** 每种效果 1 倍速度的基准时长(毫秒)。提示词与播放器共用这一份数值。 */
export const DURATIONS: Record<MotionKind, number> = {
'word-reveal': 2800,
'count-up': 2600,
'step-flow': 4200,
'shape-morph': 5600,
'layered-collage': 3600,
'dot-assembly': 4000,
};
export const clamp = (n: number, min = 0, max = 1) =>
Math.min(max, Math.max(min, n));
export const mix = (a: number, b: number, t: number) => a + (b - a) * t;
export const ease = (t: number) => 1 - (1 - clamp(t)) ** 3;
export function characters(text: string) {
return Array.from(
new Intl.Segmenter('zh-CN', { granularity: 'grapheme' }).segment(text),
(part) => part.segment,
);
}
export function normalizeOptions(
input: Partial<MotionOptions>,
defaults: MotionOptions,
maxText: number,
): MotionOptions {
const finite = (
n: number | undefined,
fallback: number,
min: number,
max: number,
) => (n !== undefined && Number.isFinite(n) ? clamp(n, min, max) : fallback);
const text = characters(input.text?.trim() || defaults.text)
.slice(0, maxText)
.join('');
const steps = (input.steps ?? defaults.steps)
.map((step) => characters(step.trim()).slice(0, 12).join(''))
.filter(Boolean)
.slice(0, 5);
const recipe = input.recipe === undefined ? undefined : parseRecipe(input.recipe);
return {
text,
color: /^#[\da-f]{6}$/i.test(input.color ?? '')
? input.color!
: defaults.color,
speed: finite(input.speed, defaults.speed, 0.5, 2),
from: finite(input.from, defaults.from, -999999, 999999),
to: finite(input.to, defaults.to, -999999, 999999),
steps: steps.length >= 3 ? steps : defaults.steps,
...(recipe ? { recipe } : {}),
};
}
export function countAt(from: number, to: number, progress: number) {
return Math.round(mix(from, to, ease(progress)) * 100) / 100;
}
export function morphAt(progress: number) {
const p = clamp(progress);
const first = p < 0.45;
const t = ease(first ? (p - 0.12) / 0.28 : (p - 0.55) / 0.3);
return {
width: first ? mix(42, 65, t) : mix(65, 82, t),
height: first ? mix(48, 64, t) : mix(64, 176, t),
radius: first ? mix(8, 32, t) : mix(32, 12, t),
};
}
export function contrastInk(hex: string) {
const rgb = [1, 3, 5].map((index) => {
const n = parseInt(hex.slice(index, index + 2), 16) / 255;
return n <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4;
});
const luminance = 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2];
return 1.05 / (luminance + 0.05) >= 4.5 ? '#ffffff' : '#000000';
}
.motion-stage {
--motion-color: #2455e8;
position: relative;
margin: 0;
isolation: isolate;
width: 100%;
height: 380px;
overflow: hidden;
container-type: inline-size;
background: #f0f2ed;
color: #18201d;
font-family:
-apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei',
sans-serif;
}
.motion-stage--compact {
height: 240px;
}
.motion-stage--dark {
background: #000;
}
.motion-stage--dark .motion-art-note,
.motion-stage--dark .motion-counter small {
color: #b6bdb7;
}
.motion-art {
position: absolute;
inset: 0;
display: grid;
place-items: center;
padding: 28px;
}
.motion-type {
width: 90%;
}
.motion-art-note {
display: block;
color: #60665f;
font:
12px/1.5 -apple-system,
BlinkMacSystemFont,
'PingFang SC',
'Microsoft YaHei',
sans-serif;
letter-spacing: 0.1em;
margin-bottom: 26px;
}
.motion-letters {
color: var(--motion-color);
font:
800 clamp(24px, 7cqi, 54px)/1.5 -apple-system,
BlinkMacSystemFont,
'PingFang SC',
'Microsoft YaHei',
sans-serif;
letter-spacing: -0.03em;
overflow-wrap: anywhere;
}
.motion-letters > span {
display: inline-block;
white-space: pre;
}
.motion-type-rule {
display: block;
width: 60px;
height: 4px;
margin-top: 24px;
background: var(--motion-color);
transform-origin: left;
}
.motion-stage--compact .motion-art {
padding: 22px;
}
.motion-stage--compact .motion-art-note {
font-size: 10px;
margin-bottom: 14px;
}
.motion-counter {
width: 80%;
}
.motion-counter > strong {
display: block;
color: var(--motion-color);
font:
800 clamp(24px, 13cqi, 86px)/1.2 -apple-system,
BlinkMacSystemFont,
'PingFang SC',
'Microsoft YaHei',
sans-serif;
font-variant-numeric: tabular-nums;
letter-spacing: -0.05em;
}
.motion-counter-track {
display: block;
height: 3px;
margin: 24px 0 12px;
background: #d8dcd5;
}
.motion-counter-track i {
display: block;
width: 100%;
height: 100%;
background: var(--motion-color);
transform-origin: left;
}
.motion-counter small {
color: #60665f;
font-size: 11px;
}
.motion-steps {
list-style: none;
margin: 0;
padding: 0;
width: min(85%, 330px);
display: grid;
gap: 16px;
}
.motion-steps li {
display: flex;
position: relative;
align-items: center;
gap: 16px;
min-width: 0;
}
.motion-steps li > span {
flex: 0 0 30px;
width: 30px;
height: 30px;
border: 1px solid var(--motion-color);
color: var(--motion-ink);
display: grid;
place-items: center;
font:
11px/1 ui-monospace,
monospace;
background: var(--motion-color);
z-index: 1;
}
.motion-steps strong {
font-size: clamp(12px, 3cqi, 18px);
font-weight: 600;
overflow-wrap: anywhere;
}
.motion-steps li > i {
position: absolute;
top: 100%;
left: 15px;
height: 16px;
width: 1px;
background: var(--motion-color);
transform-origin: top;
}
.motion-stage--compact .motion-steps {
gap: 9px;
}
.motion-stage--compact .motion-steps li > i {
height: 9px;
}
.motion-stage--compact .motion-steps li > span {
flex-basis: 25px;
width: 25px;
height: 25px;
}
.motion-stage--compact .motion-steps li > i {
left: 12px;
}
.motion-morph-shape {
background: var(--motion-color);
position: relative;
max-width: 380px;
overflow: hidden;
box-shadow: 0 10px 28px #18201d12;
}
.motion-morph-shape > div {
position: absolute;
inset: 0;
}
.motion-morph-button,
.motion-morph-capsule {
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
padding: 0 10px;
font-size: clamp(11px, 2.6cqi, 17px);
font-weight: 600;
white-space: nowrap;
}
.motion-morph-button > span {
font-size: 1.2em;
flex-shrink: 0;
}
.motion-morph-button {
white-space: normal;
}
.motion-morph-button > strong {
min-width: 0;
font-weight: inherit;
line-height: 1.25;
overflow-wrap: anywhere;
}
.motion-morph-capsule > i {
width: 8px;
height: 8px;
border-radius: 50%;
background: currentColor;
}
.motion-morph-card {
display: flex;
flex-direction: column;
justify-content: center;
padding: 22px;
gap: 12px;
}
.motion-morph-card small {
font-size: 10px;
opacity: 0.7;
}
.motion-morph-card strong {
font-size: clamp(17px, 4cqi, 27px);
line-height: 1.4;
overflow-wrap: anywhere;
}
.motion-morph-card > span {
font-size: 11px;
opacity: 0.8;
}
.motion-stage--compact .motion-morph-card {
padding: 15px;
gap: 7px;
}
.motion-stage--compact .motion-morph-card > span {
font-size: 9px;
}
.motion-collage {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.motion-collage > img {
position: absolute;
width: 33%;
height: 70%;
object-fit: cover;
top: 9%;
left: 10%;
border: 5px solid #fff;
box-shadow: 0 5px 15px #18201d16;
}
.motion-collage > img:nth-child(2) {
left: 35%;
top: 12%;
z-index: 1;
}
.motion-collage > img:nth-child(3) {
left: 59%;
top: 8%;
width: 27%;
height: 59%;
z-index: 2;
}
.motion-collage-title {
position: absolute;
z-index: 3;
left: 11%;
right: 9%;
bottom: 12%;
background: #fafaf7;
color: #18201d;
border-left: 4px solid var(--motion-color);
padding: 12px 16px;
}
.motion-collage-title > span {
display: block;
font-size: 9px;
color: #60665f;
margin-bottom: 4px;
letter-spacing: 0.1em;
}
.motion-collage-title strong {
font-size: clamp(18px, 4.8cqi, 34px);
line-height: 1.4;
overflow-wrap: anywhere;
}
.motion-stage--compact .motion-collage-title {
padding: 8px 10px;
}
.motion-stage--compact .motion-collage > img {
border-width: 3px;
}
.motion-dots {
display: block;
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
@media (max-width: 600px) {
.motion-stage {
height: 310px;
}
.motion-stage--compact {
height: 230px;
}
}
参考来源与已知限制
Shape morphing through UI states · @twoclipping
https://prompt-motion.com/twoclipping-5cba86
借鉴同一形体连续变化与内容错峰切换,未复制原界面或时间线。本站演示、图形与任务提示词独立编写,未使用参考视频、音乐或品牌素材。
- 这是按钮到卡片的形态演示,内部按钮不触发业务操作。
- 只演示三种状态,不包含拖拽、真实加载或任意 SVG 路径变形。
- 这些是实验演示,尚无实际项目使用记录;不提供视频、GIF 或跨框架导出。