SiteNook
返回交互配方

行内图标撑开首屏

在个人站首屏大标题行内嵌入零高度 em 图标槽:入场时文字先以普通空格排布,再由单一进度值联动撑开词距并让脱敏圆角图标长进缝隙,随后单槽轮询原地景深交叉淡化。

首屏与简介10 项可调参数React + Tailwind

演示与调参

真正决定手感的三个底层细节:① 图标槽 height: 0 且全用 em 计量,水平居中用 margin-left 而非 translateX,彻底避免撑裂行高或与缩放冲突;② 规避 CSS var() 无法被插值导致的「图标叠字再瞬跳」Bug,改用单一进度 p (0→1) 实时换算像素宽度与 scale = (width - margin) / size;③ 图标轮换时同槽多层绝对定位叠加,新图标延迟 120ms 入场,让两枚图标在半透明模糊态交错融合,绝不同屏出现两枚锐利图标。

Shapingdigitalproductsbuiltto feelhuman.

Independent product designer crafting interfaces, design systems,
and tactile details for teams that care about craft.

Click any icon to swap
参数调节
布局结构
设计师文案语言
图标相对字号0.86em
两侧词距留白0.16em
动效反馈
撑开缓动风格
缝隙撑开时长360ms
单槽轮换间隔2400ms
景深模糊强度6px
表面与质感
画布明暗主题
图标圆角比例24%

复刻提示词

请用 React 为设计师个人网站实现高精度「行内图标撑开首屏(Inline Slot Hero)」组件。

视觉与脱敏文案设定(设计师个人站视角):
- 画布风格:纯净画廊白底(#FFFFFF + #111113 高对比墨黑大字)。
- 三行居中大标题(「Shaping [图标] digital / products [图标] built / to feel [图标] human.」),字重 600,紧凑字距 -0.045em,行高 1.14。
- 标题下方保留两行克制的设计师简介副标题(#6B6B73,14px)。
- 脱敏高质感 App 图标:禁止使用任何第三方商标,原创三组不同材质的 iOS 圆角图标(圆角 24%)在三行间形成质感平衡——第一行高饱和渐变质感、第二行陶瓷纯白/金属质感、第三行深黑曜石配高亮几何图形;每枚图标配顶部 1px 内高光、细腻描边与柔和落影。

必须严格遵守的底层工程与动效物理:
1. 零高度 em 相对单位图标槽:
   - 每个行内槽位设为 `display: inline-block; position: relative; height: 0; vertical-align: baseline;`,CSS 默认宽度为展开态 `calc(0.86em + 0.32em)`,保证首屏 SSR 与 `prefers-reduced-motion` 下直接稳态展示。
   - 图标容器采用 `position: absolute; left: 50%; bottom: -0.1em; width: 0.86em; height: 0.86em; margin-left: calc(0.86em / -2);` 居中,绝不使用 `translateX(-50%)`,防止与缩放 `scale()` 冲突。
2. 两段式入场 + 单进度值联动撑开(规避 CSS var() 宽度跳变 Bug):
   - 第一段:三行文字从 `opacity: 0.12`、`blur(6px)`、`translateY(0.24em)` 逐行错峰上浮显影;此时三个图标槽先收拢为普通空格宽度 `0.194em`。
   - 第二段:实时读取 `getComputedStyle(slot).fontSize` 换算成真实像素(绝不对 CSS `var()` 字符串直接做补间),用单一进度 `p`(0→1,时长 `360ms`,缓动曲线 `expo.out 利落弹开`,三行错峰启动)在每一帧同时驱动:
     `width = closed + (open - closed) * p`;
     `scale = clamp(0.001, 1, (width - margin) / size)`(确保图标物理上永远不会超出正在打开的缝隙、绝不压字);
     透明度和景深模糊 `blur(6px → 0)` 滞后于缩放(`fade = clamp(0, 1, (p - 0.16) / 0.52)`)。动画结束后清空行内 `style.width = ""`,把响应式控制权交还给 CSS `em`。
3. 原地景深交叉淡化 + 单槽轮询:
   - 每个槽位内将多枚图标通过 `position: absolute; inset: 0;` 原地叠放,切换时不滑动。
   - 退场图标用 520ms(`power2.inOut`)缩小至 `0.82` + `blur(6px)` 淡出;进场图标延迟 **120ms** 后用 720ms(`power3.out`)从 `0.82` + 模糊显影归位,两枚图标在半透明模糊态交错融合。
   - 单定时器每 `2400ms` 按 `1 → 2 → 3` 轮询切换一个槽位;鼠标悬停标题自动暂停、切后台(`document.hidden`)暂停、点击任意图标立即提前切换该槽;槽位设 `aria-hidden="true"` 并在 `prefers-reduced-motion: reduce` 下完全关闭动效。

代码

InlineIconHero.tsxReact · Tailwind
"use client";

import React, { useCallback, useEffect, useRef, useState, type CSSProperties } from "react";

const heroParams = {
  "theme": "light",
  "copyLang": "en",
  "iconSizeEm": 0.86,
  "slotGapEm": 0.16,
  "cornerPct": 24,
  "openDurationMs": 360,
  "openCurve": "snap",
  "swapIntervalMs": 2400,
  "blurPx": 6,
  "showSubline": true
};

export interface InlineIconHeroParams {
  theme?: string;
  copyLang?: string;
  iconSizeEm?: number;
  slotGapEm?: number;
  cornerPct?: number;
  openDurationMs?: number;
  openCurve?: string;
  swapIntervalMs?: number;
  blurPx?: number;
  showSubline?: boolean;
}

interface CraftIconDef {
  id: string;
  label: string;
  surface: "vivid" | "light" | "dark";
  bg: string;
  art: React.ReactNode;
}

const SLOT_ICONS: [CraftIconDef[], CraftIconDef[], CraftIconDef[]] = [
  // Slot 1 — Craft & Studio (vivid editorial app tiles)
  [
    {
      id: "atelier-ribbon",
      label: "Atelier Ribbon",
      surface: "vivid",
      bg: "linear-gradient(145deg, #432BFF 0%, #2410B8 100%)",
      art: (
        <>
          <path
            d="M11 25C11 16.5 16.5 10.5 22 10.5C25.5 10.5 27.5 13 27.5 16.5C27.5 22 22 25.5 15.5 27.5"
            fill="none"
            stroke="#73C0FF"
            strokeWidth="4.4"
            strokeLinecap="round"
          />
          <path
            d="M12.5 13.5C17 14 23 19.5 26 26.5"
            fill="none"
            stroke="#FF7082"
            strokeWidth="4.4"
            strokeLinecap="round"
          />
          <circle cx="24.5" cy="12.5" r="2.6" fill="#FFFFFF" />
        </>
      ),
    },
    {
      id: "bezier-bloom",
      label: "Bezier Bloom",
      surface: "vivid",
      bg: "linear-gradient(145deg, #FF5E3A 0%, #D92B1C 100%)",
      art: (
        <>
          <path
            d="M10 24.5C12.5 14 23.5 14 26 24.5"
            fill="none"
            stroke="#FFF5F0"
            strokeWidth="3.2"
            strokeLinecap="round"
          />
          <line
            x1="10"
            y1="14"
            x2="26"
            y2="14"
            stroke="#FFD0C2"
            strokeWidth="1.8"
            strokeLinecap="round"
          />
          <circle cx="10" cy="14" r="2.2" fill="#FFFFFF" />
          <circle cx="26" cy="14" r="2.2" fill="#FFFFFF" />
          <rect x="15.2" y="11.2" width="5.6" height="5.6" rx="1.6" fill="#FFFFFF" />
        </>
      ),
    },
    {
      id: "prism-lens",
      label: "Prism Lens",
      surface: "vivid",
      bg: "linear-gradient(145deg, #6B4CFF 0%, #371CC4 100%)",
      art: (
        <>
          <polygon points="18,7.5 28,18 18,28.5 8,18" fill="rgba(255,255,255,0.22)" />
          <polygon points="18,7.5 28,18 18,21.5" fill="#FFFFFF" opacity="0.92" />
          <polygon points="18,7.5 8,18 18,21.5" fill="#C9BAFF" opacity="0.88" />
          <polygon points="18,21.5 28,18 18,28.5" fill="#8C75FF" />
        </>
      ),
    },
    {
      id: "marigold-grid",
      label: "Marigold Grid",
      surface: "vivid",
      bg: "linear-gradient(145deg, #FFB82E 0%, #EA7C00 100%)",
      art: (
        <>
          <rect x="9.5" y="9.5" width="7.2" height="7.2" rx="2.2" fill="#231607" />
          <rect x="19.3" y="9.5" width="7.2" height="7.2" rx="3.6" fill="#FFF8EB" />
          <rect x="9.5" y="19.3" width="7.2" height="7.2" rx="3.6" fill="#FFF8EB" />
          <rect x="19.3" y="19.3" width="7.2" height="7.2" rx="2.2" fill="#231607" />
        </>
      ),
    },
  ],
  // Slot 2 — Products & Systems (tactile alabaster/silver studio tiles)
  [
    {
      id: "chrome-module",
      label: "Chrome Module",
      surface: "light",
      bg: "linear-gradient(160deg, #FFFFFF 0%, #EFEFF3 100%)",
      art: (
        <>
          <rect x="9.5" y="9.5" width="7.5" height="17" rx="3.2" fill="#18181B" />
          <rect x="11" y="11" width="2.2" height="14" rx="1.1" fill="rgba(255,255,255,0.28)" />
          <path
            d="M19.5 10.5H23.2C25.6 10.5 27.2 12 27.2 14.3C27.2 16.6 25.6 18.1 23.2 18.1H19.5V10.5Z"
            fill="#27272A"
          />
          <path
            d="M19.5 19.6H23.6C25.8 19.6 27.2 21.1 27.2 23.2V26.5H19.5V19.6Z"
            fill="#A1A1AA"
          />
        </>
      ),
    },
    {
      id: "swiss-dial",
      label: "Swiss Dial",
      surface: "light",
      bg: "linear-gradient(160deg, #FAFAFC 0%, #EAECEF 100%)",
      art: (
        <>
          <circle cx="18" cy="18" r="9.5" fill="none" stroke="#18181B" strokeWidth="2.4" />
          <line x1="18" y1="18" x2="23.2" y2="12.8" stroke="#EF4444" strokeWidth="2.4" strokeLinecap="round" />
          <line x1="18" y1="18" x2="13.5" y2="21.5" stroke="#18181B" strokeWidth="2.2" strokeLinecap="round" />
          <circle cx="18" cy="18" r="2" fill="#18181B" />
        </>
      ),
    },
    {
      id: "token-stack",
      label: "Token Stack",
      surface: "light",
      bg: "linear-gradient(160deg, #FFFFFF 0%, #F1F2F6 100%)",
      art: (
        <>
          <rect x="9" y="10" width="18" height="4.8" rx="2.4" fill="#18181B" />
          <rect x="9" y="16.2" width="13.5" height="4.8" rx="2.4" fill="#2563EB" />
          <rect x="9" y="22.4" width="18" height="4.8" rx="2.4" fill="#D4D4D8" />
        </>
      ),
    },
    {
      id: "tactile-toggle",
      label: "Tactile Toggle",
      surface: "light",
      bg: "linear-gradient(160deg, #FFFFFF 0%, #ECEEF2 100%)",
      art: (
        <>
          <rect x="7.5" y="12" width="21" height="12" rx="6" fill="#18181B" />
          <circle cx="22.5" cy="18" r="4.2" fill="#FFFFFF" />
          <circle cx="13.2" cy="18" r="1.6" fill="#22C55E" />
        </>
      ),
    },
  ],
  // Slot 3 — Human & Delight (deep obsidian app tiles with luminous marks)
  [
    {
      id: "obsidian-aperture",
      label: "Obsidian Aperture",
      surface: "dark",
      bg: "linear-gradient(145deg, #222227 0%, #09090B 100%)",
      art: (
        <>
          <rect
            x="8.8"
            y="8.8"
            width="18.4"
            height="18.4"
            rx="6.2"
            fill="none"
            stroke="#FFFFFF"
            strokeWidth="3.2"
          />
          <circle cx="18" cy="18" r="4.4" fill="#FFFFFF" />
        </>
      ),
    },
    {
      id: "emerald-wave",
      label: "Emerald Wave",
      surface: "dark",
      bg: "linear-gradient(145deg, #171A1C 0%, #07090A 100%)",
      art: (
        <g fill="none" stroke="#22E57A" strokeLinecap="round">
          <path d="M9.5 13.8C14.8 11.4 21.4 11.8 26.8 14.6" strokeWidth="2.8" />
          <path d="M11 18.6C15.5 16.8 20.8 17.2 25.2 19.6" strokeWidth="2.6" />
          <path d="M12.6 23.2C16.2 22 20.2 22.3 23.6 24.1" strokeWidth="2.4" />
        </g>
      ),
    },
    {
      id: "orbital-spark",
      label: "Orbital Spark",
      surface: "dark",
      bg: "linear-gradient(145deg, #171C2B 0%, #0A0D16 100%)",
      art: (
        <>
          <ellipse
            cx="18"
            cy="18"
            rx="11"
            ry="5.2"
            transform="rotate(-28 18 18)"
            fill="none"
            stroke="#7DD3FC"
            strokeWidth="2"
          />
          <path
            d="M18 9.2L19.9 16.1L26.8 18L19.9 19.9L18 26.8L16.1 19.9L9.2 18L16.1 16.1Z"
            fill="#FFFFFF"
          />
        </>
      ),
    },
    {
      id: "warm-pebble",
      label: "Warm Pebble",
      surface: "dark",
      bg: "linear-gradient(145deg, #271E1A 0%, #110C0A 100%)",
      art: (
        <>
          <rect x="8.5" y="10" width="19" height="16" rx="8" fill="#FFB088" />
          <circle cx="15" cy="17.2" r="1.9" fill="#181210" />
          <circle cx="21.4" cy="17.2" r="1.9" fill="#181210" />
        </>
      ),
    },
  ],
];

const COPY = {
  en: {
    ariaHeadline: "Shaping digital products built to feel human.",
    lines: [
      { before: "Shaping", after: "digital" },
      { before: "products", after: "built" },
      { before: "to feel", after: "human." },
    ],
    subline1: "Independent product designer crafting interfaces, design systems,",
    subline2: "and tactile details for teams that care about craft.",
    replay: "Replay intro",
    paused: "Paused on hover",
    hint: "Click any icon to swap",
  },
  zh: {
    ariaHeadline: "专注打磨克制而灵动的数字产品体验。",
    lines: [
      { before: "专注", after: "打磨" },
      { before: "克制而", after: "灵动的" },
      { before: "数字", after: "体验。" },
    ],
    subline1: "独立产品设计师,专注界面美学、设计系统,",
    subline2: "以及让产品拥有温度与手感的交互细节。",
    replay: "重播入场",
    paused: "悬停暂停轮换",
    hint: "点击任意图标可切换",
  },
} as const;

function easeExpoOut(t: number): number {
  return t >= 1 ? 1 : 1 - Math.pow(2, -10 * t);
}

function easePower2InOut(t: number): number {
  return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2;
}

function InlineIconHero({
  params,
}: {
  params: Record<string, string | number | boolean>;
}) {
  const theme = String(params.theme ?? "light") === "dark" ? "dark" : "light";
  const copyLang = String(params.copyLang ?? "en") === "zh" ? "zh" : "en";
  const iconSizeEm = Number(params.iconSizeEm ?? 0.86);
  const slotGapEm = Number(params.slotGapEm ?? 0.16);
  const cornerPct = Number(params.cornerPct ?? 24);
  const openDurationMs = Number(params.openDurationMs ?? 360);
  const openCurve =
    String(params.openCurve ?? "snap") === "glide" ? "glide" : "snap";
  const swapIntervalMs = Number(params.swapIntervalMs ?? 2400);
  const blurPx = Number(params.blurPx ?? 6);
  const showSubline = Boolean(params.showSubline ?? true);

  const slotRefs = useRef<(HTMLSpanElement | null)[]>([null, null, null]);
  const iconWrapRefs = useRef<(HTMLButtonElement | null)[]>([null, null, null]);
  const lineRefs = useRef<(HTMLSpanElement | null)[]>([null, null, null]);
  const sublineRef = useRef<HTMLParagraphElement | null>(null);

  const [activeIndices, setActiveIndices] = useState<[number, number, number]>([0, 0, 0]);
  const [replayCount, setReplayCount] = useState(0);
  const [hovered, setHovered] = useState(false);
  const [reducedMotion, setReducedMotion] = useState(false);

  const hoveredRef = useRef(false);
  const turnRef = useRef(0);
  const introDoneRef = useRef(false);
  const layoutRef = useRef({ iconSizeEm, slotGapEm, blurPx });

  useEffect(() => {
    hoveredRef.current = hovered;
  }, [hovered]);

  useEffect(() => {
    layoutRef.current = { iconSizeEm, slotGapEm, blurPx };
  }, [iconSizeEm, slotGapEm, blurPx]);

  useEffect(() => {
    const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
    const sync = () => setReducedMotion(mq.matches);
    sync();
    mq.addEventListener("change", sync);
    return () => mq.removeEventListener("change", sync);
  }, []);

  const swapSlot = useCallback((slotIndex: number) => {
    setActiveIndices((prev) => {
      const next = [...prev] as [number, number, number];
      next[slotIndex] = (prev[slotIndex] + 1) % SLOT_ICONS[slotIndex].length;
      return next;
    });
  }, []);

  // Phase 1 & Phase 2: Line entrance + single-progress-driver hairline-to-open slot physics
  useEffect(() => {
    const slots = slotRefs.current;
    const wraps = iconWrapRefs.current;
    const lines = lineRefs.current;
    const subline = sublineRef.current;

    if (reducedMotion) {
      introDoneRef.current = true;
      for (let i = 0; i < 3; i++) {
        const s = slots[i];
        const w = wraps[i];
        const l = lines[i];
        if (s) s.style.width = "";
        if (w) {
          w.style.transform = "scale(1)";
          w.style.opacity = "1";
          w.style.filter = "blur(0px)";
        }
        if (l) {
          l.style.opacity = "1";
          l.style.filter = "blur(0px)";
          l.style.transform = "translateY(0)";
        }
      }
      if (subline) {
        subline.style.opacity = "1";
        subline.style.transform = "translateY(0)";
      }
      return;
    }

    introDoneRef.current = false;
    let rafId = 0;
    const startTime = performance.now();

    const isGlide = openCurve === "glide";
    const lineDuration = isGlide ? 820 : 620;
    const lineStagger = isGlide ? 85 : 65;
    const slotBaseDelay = isGlide ? 480 : 300;
    const slotStagger = isGlide ? 140 : 95;
    const sublineDelay = slotBaseDelay + slotStagger * 2 + openDurationMs * 0.45;
    const totalIntroMs = Math.max(
      slotBaseDelay + slotStagger * 2 + openDurationMs,
      sublineDelay + 420
    );

    const { iconSizeEm: initIconEm, slotGapEm: initGapEm, blurPx: initBlur } =
      layoutRef.current;

    // Measure live font-size in pixels once per intro to avoid var() width bugs
    const metrics = slots.map((slot) => {
      const font = slot ? parseFloat(getComputedStyle(slot).fontSize) || 48 : 48;
      const closed = 0.194 * font;
      const open = (initIconEm + 2 * initGapEm) * font;
      const size = initIconEm * font;
      const margin = Math.min(open - closed * 0.5, Math.max(0.16, initGapEm * 1.45) * font);
      return { closed, open, size, margin };
    });

    // Lock slots closed before first paint frame
    for (let i = 0; i < 3; i++) {
      const s = slots[i];
      const w = wraps[i];
      const l = lines[i];
      if (s) s.style.width = `${metrics[i].closed}px`;
      if (w) {
        w.style.transform = "scale(0.001)";
        w.style.opacity = "0";
        w.style.filter = `blur(${initBlur}px)`;
      }
      if (l) {
        l.style.opacity = "0.12";
        l.style.filter = `blur(${Math.max(4, initBlur)}px)`;
        l.style.transform = "translateY(0.24em)";
      }
    }
    if (subline) {
      subline.style.opacity = "0";
      subline.style.transform = "translateY(8px)";
    }

    const tick = (now: number) => {
      const elapsed = now - startTime;

      // 1. Staggered line reveal
      for (let i = 0; i < 3; i++) {
        const l = lines[i];
        if (!l) continue;
        const raw = Math.min(1, Math.max(0, (elapsed - i * lineStagger) / lineDuration));
        const eased = easeExpoOut(raw);
        l.style.opacity = String(0.12 + 0.88 * eased);
        l.style.filter = `blur(${(1 - eased) * Math.max(4, initBlur)}px)`;
        l.style.transform = `translateY(${(1 - eased) * 0.24}em)`;
      }

      // 2. Single progress value drives both slot width (px) and icon growth
      let allSlotsOpen = true;
      for (let i = 0; i < 3; i++) {
        const s = slots[i];
        const w = wraps[i];
        if (!s || !w) continue;
        const raw = Math.min(
          1,
          Math.max(0, (elapsed - (slotBaseDelay + i * slotStagger)) / Math.max(120, openDurationMs))
        );
        if (raw < 1) allSlotsOpen = false;
        const p = isGlide ? easePower2InOut(raw) : easeExpoOut(raw);
        const m = metrics[i];
        const width = m.closed + (m.open - m.closed) * p;
        const scale = Math.max(0.001, Math.min(1, (width - m.margin) / m.size));
        const fade = Math.min(1, Math.max(0, (p - 0.16) / 0.52));

        if (raw >= 1) {
          // Clear inline width on completion so CSS em sizing stays responsive
          s.style.width = "";
          w.style.transform = "scale(1)";
          w.style.opacity = "1";
          w.style.filter = "blur(0px)";
        } else {
          s.style.width = `${width.toFixed(2)}px`;
          w.style.transform = `scale(${scale.toFixed(4)})`;
          w.style.opacity = fade.toFixed(3);
          w.style.filter = `blur(${((1 - fade) * initBlur).toFixed(2)}px)`;
        }
      }

      // 3. Quiet subline fade-up
      if (subline) {
        const subRaw = Math.min(1, Math.max(0, (elapsed - sublineDelay) / 420));
        const subEased = easeExpoOut(subRaw);
        subline.style.opacity = subEased.toFixed(3);
        subline.style.transform = `translateY(${((1 - subEased) * 8).toFixed(2)}px)`;
      }

      if (elapsed < totalIntroMs || !allSlotsOpen) {
        rafId = requestAnimationFrame(tick);
      } else {
        introDoneRef.current = true;
      }
    };

    rafId = requestAnimationFrame(tick);
    return () => cancelAnimationFrame(rafId);
  }, [openDurationMs, openCurve, replayCount, reducedMotion, copyLang]);

  // Phase 3: Round-robin one-slot-at-a-time swap timer (pauses on hover & hidden tab)
  useEffect(() => {
    if (reducedMotion) return;
    let timeoutId = 0;

    const schedule = (waitMs: number) => {
      timeoutId = window.setTimeout(() => {
        if (introDoneRef.current && !hoveredRef.current && !document.hidden) {
          const nextSlot = turnRef.current % 3;
          turnRef.current += 1;
          swapSlot(nextSlot);
        }
        schedule(swapIntervalMs);
      }, waitMs);
    };

    // Start first swap gently after intro settles
    schedule(Math.max(1200, swapIntervalMs));
    return () => window.clearTimeout(timeoutId);
  }, [swapIntervalMs, reducedMotion, swapSlot, replayCount]);

  const content = COPY[copyLang];

  const rootVars = {
    "--ish-icon": `${iconSizeEm}em`,
    "--ish-gap": `${slotGapEm}em`,
    "--ish-radius": `${cornerPct}%`,
    "--ish-blur": `${blurPx}px`,
  } as CSSProperties;

  return (
    <div
      className="ish-stage"
      data-theme={theme}
      data-lang={copyLang}
      style={rootVars}
    >
      <style>{`
        .ish-stage {
          container-type: inline-size;
          position: relative;
          box-sizing: border-box;
          width: 100%;
          max-width: 720px;
          margin: 0 auto;
          overflow: hidden;
          border-radius: 16px;
          padding: clamp(40px, 8cqw, 72px) clamp(24px, 5cqw, 40px) clamp(48px, 8cqw, 64px);
          background: #ffffff;
          color: #111113;
          text-align: center;
          box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
          font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", sans-serif;
          transition: background-color 240ms ease, color 240ms ease;
        }

        .ish-stage[data-theme="dark"] {
          background: #0b0b0d;
          color: #f6f6f4;
          box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
          background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
          background-size: 16px 16px;
        }

        .ish-headline {
          margin: 0 auto;
          font-size: clamp(28px, 7.6cqw, 56px);
          font-weight: 600;
          letter-spacing: -0.045em;
          line-height: 1.14;
          color: inherit;
          text-wrap: balance;
          cursor: default;
        }

        .ish-stage[data-lang="zh"] .ish-headline {
          font-size: clamp(26px, 7cqw, 50px);
          letter-spacing: -0.025em;
          line-height: 1.24;
        }

        .ish-line {
          display: block;
          will-change: transform, opacity, filter;
        }

        /* Zero-height em-scaled inline slot — prevents vertical line-height jump */
        .ish-slot {
          --icon-drop: 0.1em;
          --slot-open: calc(var(--ish-icon) + 2 * var(--ish-gap));
          position: relative;
          display: inline-block;
          width: var(--slot-open);
          height: 0;
          vertical-align: baseline;
        }

        .ish-stage[data-lang="zh"] .ish-slot {
          --icon-drop: 0.12em;
        }

        /* Centered with margin-left (never translateX) so scale() never fights centering */
        .ish-icon-btn {
          appearance: none;
          border: 0;
          padding: 0;
          background: none;
          position: absolute;
          left: 50%;
          bottom: calc(-1 * var(--icon-drop));
          width: var(--ish-icon);
          height: var(--ish-icon);
          margin-left: calc(var(--ish-icon) / -2);
          border-radius: var(--ish-radius);
          cursor: pointer;
          touch-action: manipulation;
          transform-origin: center center;
          will-change: transform, opacity, filter;
        }

        .ish-icon-btn:focus-visible {
          outline: 2px solid #2563eb;
          outline-offset: 4px;
        }

        .ish-icon-inner {
          position: relative;
          display: block;
          width: 100%;
          height: 100%;
          border-radius: var(--ish-radius);
          transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
        }

        .ish-icon-btn:hover .ish-icon-inner {
          transform: scale(1.05);
        }

        .ish-icon-btn:active .ish-icon-inner {
          transform: scale(0.94);
        }

        /* Stacked layers inside the slot for blur-crossfade in place */
        .ish-layer {
          position: absolute;
          inset: 0;
          display: grid;
          place-items: center;
          border-radius: var(--ish-radius);
          overflow: hidden;
          opacity: 0;
          transform: scale(0.82);
          filter: blur(var(--ish-blur));
          pointer-events: none;
          will-change: transform, opacity, filter;
          transition:
            opacity 520ms cubic-bezier(0.45, 0, 0.55, 1) 0ms,
            transform 520ms cubic-bezier(0.45, 0, 0.55, 1) 0ms,
            filter 520ms cubic-bezier(0.45, 0, 0.55, 1) 0ms;
        }

        .ish-layer-active {
          opacity: 1;
          transform: scale(1);
          filter: blur(0px);
          z-index: 2;
          /* 120ms incoming delay creates the soft overlap where neither icon is sharp together */
          transition:
            opacity 720ms cubic-bezier(0.22, 1, 0.36, 1) 120ms,
            transform 720ms cubic-bezier(0.22, 1, 0.36, 1) 120ms,
            filter 720ms cubic-bezier(0.22, 1, 0.36, 1) 120ms;
        }

        .ish-layer[data-surface="vivid"] {
          box-shadow:
            inset 0 1px 0.5px rgba(255, 255, 255, 0.28),
            inset 0 0 0 1px rgba(0, 0, 0, 0.08),
            0 4px 12px -3px rgba(0, 0, 0, 0.18),
            0 1px 3px rgba(0, 0, 0, 0.08);
        }

        .ish-layer[data-surface="light"] {
          box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.9),
            inset 0 0 0 1px rgba(0, 0, 0, 0.08),
            0 4px 12px -3px rgba(0, 0, 0, 0.1),
            0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .ish-layer[data-surface="dark"] {
          box-shadow:
            inset 0 1px 0.5px rgba(255, 255, 255, 0.16),
            inset 0 0 0 1px rgba(255, 255, 255, 0.08),
            0 4px 12px -3px rgba(0, 0, 0, 0.24),
            0 1px 3px rgba(0, 0, 0, 0.12);
        }

        .ish-stage[data-theme="dark"] .ish-layer[data-surface="dark"] {
          box-shadow:
            inset 0 1px 0.5px rgba(255, 255, 255, 0.18),
            inset 0 0 0 1px rgba(255, 255, 255, 0.14),
            0 6px 16px -4px rgba(0, 0, 0, 0.55);
        }

        .ish-subline {
          margin: clamp(16px, 3cqw, 24px) auto 0;
          max-width: 440px;
          font-size: clamp(12px, 2cqw, 14px);
          line-height: 1.6;
          color: #6b6b73;
          will-change: transform, opacity;
        }

        .ish-stage[data-theme="dark"] .ish-subline {
          color: #a1a1aa;
        }

        .ish-chrome {
          position: absolute;
          right: 12px;
          bottom: 12px;
          left: 12px;
          display: flex;
          align-items: center;
          justify-content: space-between;
          gap: 8px;
          pointer-events: none;
        }

        .ish-status {
          display: inline-flex;
          align-items: center;
          gap: 8px;
          font-size: 11px;
          line-height: 1;
          color: #8a8a93;
        }

        .ish-stage[data-theme="dark"] .ish-status {
          color: #71717a;
        }

        .ish-dot {
          width: 8px;
          height: 8px;
          border-radius: 999px;
          background: rgba(34, 197, 94, 0.2);
          display: grid;
          place-items: center;
        }

        .ish-dot::after {
          content: "";
          width: 4px;
          height: 4px;
          border-radius: 999px;
          background: #22c55e;
          transition: background-color 180ms ease;
        }

        .ish-dot[data-paused="true"] {
          background: rgba(245, 158, 11, 0.2);
        }

        .ish-dot[data-paused="true"]::after {
          background: #f59e0b;
        }

        .ish-replay {
          pointer-events: auto;
          appearance: none;
          display: inline-flex;
          align-items: center;
          gap: 4px;
          height: 24px;
          padding: 0 12px;
          border-radius: 999px;
          border: 1px solid rgba(0, 0, 0, 0.1);
          background: rgba(255, 255, 255, 0.85);
          color: #52525b;
          font: 500 11px/1 inherit;
          cursor: pointer;
          transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
        }

        .ish-replay:hover {
          background: #f4f4f5;
          color: #111113;
          border-color: rgba(0, 0, 0, 0.18);
        }

        .ish-stage[data-theme="dark"] .ish-replay {
          border-color: rgba(255, 255, 255, 0.14);
          background: rgba(24, 24, 27, 0.85);
          color: #a1a1aa;
        }

        .ish-stage[data-theme="dark"] .ish-replay:hover {
          background: rgba(39, 39, 42, 0.95);
          color: #ffffff;
        }

        @media (prefers-reduced-motion: reduce) {
          .ish-icon-inner,
          .ish-layer,
          .ish-layer-active {
            transition: none;
            filter: none;
            transform: scale(1);
          }
        }
      `}</style>

      <h3
        className="ish-headline"
        aria-label={content.ariaHeadline}
        onMouseEnter={() => setHovered(true)}
        onMouseLeave={() => setHovered(false)}
      >
        {content.lines.map((line, slotIndex) => {
          const icons = SLOT_ICONS[slotIndex];
          const activeIdx = activeIndices[slotIndex];
          return (
            <span
              key={slotIndex}
              ref={(el) => {
                lineRefs.current[slotIndex] = el;
              }}
              className="ish-line"
            >
              <span>{line.before}</span>
              <span
                ref={(el) => {
                  slotRefs.current[slotIndex] = el;
                }}
                className="ish-slot"
                aria-hidden="true"
              >
                <button
                  ref={(el) => {
                    iconWrapRefs.current[slotIndex] = el;
                  }}
                  type="button"
                  tabIndex={-1}
                  aria-label={`Swap icon ${slotIndex + 1}`}
                  onClick={() => swapSlot(slotIndex)}
                  className="ish-icon-btn"
                >
                  <span className="ish-icon-inner">
                    {icons.map((icon, idx) => {
                      const isActive = idx === activeIdx;
                      return (
                        <span
                          key={icon.id}
                          data-surface={icon.surface}
                          className={`ish-layer${isActive ? " ish-layer-active" : ""}`}
                          style={{ background: icon.bg }}
                        >
                          <svg
                            viewBox="0 0 36 36"
                            width="100%"
                            height="100%"
                            aria-hidden="true"
                          >
                            {icon.art}
                          </svg>
                        </span>
                      );
                    })}
                  </span>
                </button>
              </span>
              <span>{line.after}</span>
            </span>
          );
        })}
      </h3>

      {showSubline && (
        <p ref={sublineRef} className="ish-subline">
          {content.subline1}
          <br />
          {content.subline2}
        </p>
      )}

      <div className="ish-chrome">
        <span className="ish-status">
          <span className="ish-dot" data-paused={hovered || reducedMotion} />
          <span>{hovered ? content.paused : content.hint}</span>
        </span>
        <button
          type="button"
          className="ish-replay"
          onClick={() => setReplayCount((c) => c + 1)}
          aria-label={content.replay}
        >
          <svg
            width="11"
            height="11"
            viewBox="0 0 16 16"
            fill="none"
            stroke="currentColor"
            strokeWidth="1.75"
            strokeLinecap="round"
            strokeLinejoin="round"
            aria-hidden="true"
          >
            <path d="M2.5 8a5.5 5.5 0 1 0 1.4-3.7L2.5 5.7" />
            <path d="M2.5 2.5v3.2h3.2" />
          </svg>
          <span>{content.replay}</span>
        </button>
      </div>
    </div>
  );
}

export default function DesignerHero() {
  return <InlineIconHero params={heroParams} />;
}

参数参考

属性默认值当前值说明
copyLang
设计师文案语言
enen在设计师个人站英文版与中文版首屏宣言之间切换。
iconSizeEm
图标相对字号
0.860.86图标边长相对标题字号的比例,缩放屏幕时随字号等比联动。
slotGapEm
两侧词距留白
0.160.16图标槽完全撑开后左右两侧的呼吸留白宽度。
openCurve
撑开缓动风格
snapsnap切换快速干脆的 expo.out 弹开或平稳的 power2.inOut 柔滑推开。
openDurationMs
缝隙撑开时长
360360单个图标槽从 0.194em 空格缝隙平滑撑开到完整宽度的耗时。
swapIntervalMs
单槽轮换间隔
24002400每次仅切换一个槽位(1→2→3 轮询)的节奏间隔,避免三行同时跳动。
blurPx
景深模糊强度
66图标撑开显影与原地交叉淡化时的景深模糊像素。
theme
画布明暗主题
lightlight在纯净白底与暗黑工作室墨底之间切换。
cornerPct
图标圆角比例
2424相对图标边长的圆角百分比(22%–26% 接近 iOS App 图标视觉比例)。
showSubline
副标题简介
truetrue是否在大标题下方显示两行克制的个人简介副标题。