dsh-design-studio 1.5.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +6 -5
- package/README.md +7 -6
- package/THIRD_PARTY_NOTICES.md +108 -0
- package/assets/art/README.md +102 -0
- package/assets/art/brand-mark.webp +0 -0
- package/assets/art/check-clean.webp +0 -0
- package/assets/art/coach-markup.webp +0 -0
- package/assets/art/drop-file.webp +0 -0
- package/assets/art/empty-components.webp +0 -0
- package/assets/art/empty-data.webp +0 -0
- package/assets/art/empty-error.webp +0 -0
- package/assets/art/empty-frames.webp +0 -0
- package/assets/art/empty-history.webp +0 -0
- package/assets/art/empty-market.webp +0 -0
- package/assets/art/empty-notes.webp +0 -0
- package/assets/art/empty-search.webp +0 -0
- package/assets/art/empty-tokens.webp +0 -0
- package/assets/art/empty-works.webp +0 -0
- package/assets/art/guide-icon.webp +0 -0
- package/assets/art/kind-app.webp +0 -0
- package/assets/art/kind-desktop.webp +0 -0
- package/assets/art/kind-diagram.webp +0 -0
- package/assets/art/kind-dshplugin.webp +0 -0
- package/assets/art/kind-email.webp +0 -0
- package/assets/art/kind-embedded.webp +0 -0
- package/assets/art/kind-framed.webp +0 -0
- package/assets/art/kind-miniprogram.webp +0 -0
- package/assets/art/kind-poster.webp +0 -0
- package/assets/art/kind-slides.webp +0 -0
- package/assets/art/kind-tablet.webp +0 -0
- package/assets/art/kind-web.webp +0 -0
- package/assets/art/placeholder-inspire-img.webp +0 -0
- package/assets/art/wait-creating.webp +0 -0
- package/assets/motion/ai-capsule.html +124 -0
- package/assets/motion/ai-glow-input.html +112 -0
- package/assets/motion/balance-odometer.html +112 -0
- package/assets/motion/bottom-sheet.html +149 -0
- package/assets/motion/brightness-pill.html +114 -0
- package/assets/motion/comet-ring.html +95 -0
- package/assets/motion/copy-morph.html +116 -0
- package/assets/motion/cube-grid.html +103 -0
- package/assets/motion/day-night.html +120 -0
- package/assets/motion/dial-knob.html +130 -0
- package/assets/motion/dock-magnify.html +118 -0
- package/assets/motion/download-ring.html +135 -0
- package/assets/motion/expand-card.html +137 -0
- package/assets/motion/flip-card.html +100 -0
- package/assets/motion/hold-pay.html +137 -0
- package/assets/motion/holo-card.html +130 -0
- package/assets/motion/keycap.html +92 -0
- package/assets/motion/like-jelly.html +88 -0
- package/assets/motion/liquid-progress.html +113 -0
- package/assets/motion/liquid-segment.html +127 -0
- package/assets/motion/live-capsule.html +144 -0
- package/assets/motion/marker-highlight.html +94 -0
- package/assets/motion/marquee-logos.html +110 -0
- package/assets/motion/otp-code.html +111 -0
- package/assets/motion/password-eye.html +136 -0
- package/assets/motion/ruler-slider.html +140 -0
- package/assets/motion/search-expand.html +81 -0
- package/assets/motion/send-fly.html +121 -0
- package/assets/motion/skeleton-shine.html +124 -0
- package/assets/motion/star-rate.html +98 -0
- package/assets/motion/success-check.html +114 -0
- package/assets/motion/suggest-chips.html +134 -0
- package/assets/motion/swipe-row.html +126 -0
- package/assets/motion/tabbar-bounce.html +92 -0
- package/assets/motion/tactile-controls.html +89 -0
- package/assets/motion/text-scramble.html +173 -0
- package/assets/motion/toast-stack.html +115 -0
- package/assets/motion/token-stream.html +106 -0
- package/assets/motion/voice-orb.html +144 -0
- package/assets/showcase/alley-noodles-1.webp +0 -0
- package/assets/showcase/alley-noodles-2.webp +0 -0
- package/assets/showcase/alley-noodles-3.webp +0 -0
- package/assets/showcase/autumn-sale-1.webp +0 -0
- package/assets/showcase/bold-folio-1.webp +0 -0
- package/assets/showcase/bold-folio-2.webp +0 -0
- package/assets/showcase/book-club-1.webp +0 -0
- package/assets/showcase/book-club-2.webp +0 -0
- package/assets/showcase/book-club-3.webp +0 -0
- package/assets/showcase/flower-order-1.webp +0 -0
- package/assets/showcase/little-painter-1.webp +0 -0
- package/assets/showcase/little-painter-2.webp +0 -0
- package/assets/showcase/moon-fair-1.webp +0 -0
- package/assets/showcase/nail-booking-1.webp +0 -0
- package/assets/showcase/nail-booking-2.webp +0 -0
- package/assets/showcase/nail-booking-3.webp +0 -0
- package/assets/showcase/night-run-1.webp +0 -0
- package/assets/showcase/paw-diary-1.webp +0 -0
- package/assets/showcase/paw-diary-2.webp +0 -0
- package/assets/showcase/paw-diary-3.webp +0 -0
- package/assets/showcase/pixel-planet-1.webp +0 -0
- package/assets/showcase/pixel-planet-2.webp +0 -0
- package/assets/showcase/pixel-planet-3.webp +0 -0
- package/assets/showcase/pocket-ledger-1.webp +0 -0
- package/assets/showcase/pocket-ledger-2.webp +0 -0
- package/assets/showcase/shiftloom-1.webp +0 -0
- package/assets/showcase/shiftloom-2.webp +0 -0
- package/assets/showcase/slow-breath-1.webp +0 -0
- package/assets/showcase/slow-breath-2.webp +0 -0
- package/assets/showcase/slow-breath-3.webp +0 -0
- package/assets/showcase/slow-trip-1.webp +0 -0
- package/assets/showcase/slow-trip-2.webp +0 -0
- package/assets/showcase/slow-trip-3.webp +0 -0
- package/assets/showcase/slow-weekly-1.webp +0 -0
- package/assets/showcase/stay-confirm-1.webp +0 -0
- package/assets/showcase/stove-recipes-1.webp +0 -0
- package/assets/showcase/stove-recipes-2.webp +0 -0
- package/assets/showcase/strobewatch-1.webp +0 -0
- package/assets/showcase/strobewatch-2.webp +0 -0
- package/assets/showcase/tapeworks-1.webp +0 -0
- package/assets/showcase/tapeworks-2.webp +0 -0
- package/assets/showcase/tea-brand-pitch-1.webp +0 -0
- package/assets/showcase/tea-brand-pitch-2.webp +0 -0
- package/assets/showcase/tea-brand-pitch-3.webp +0 -0
- package/assets/showcase/time-bookshop-1.webp +0 -0
- package/assets/showcase/time-bookshop-2.webp +0 -0
- package/assets/showcase/water-journey-1.webp +0 -0
- package/assets/showcase/water-journey-2.webp +0 -0
- package/assets/showcase/water-journey-3.webp +0 -0
- package/assets/showcase/weekend-go-1.webp +0 -0
- package/assets/showcase/weekend-go-2.webp +0 -0
- package/assets/showcase/weekend-go-3.webp +0 -0
- package/assets/showcase/winter-soup-1.webp +0 -0
- package/assets/showcase/year-review-1.webp +0 -0
- package/assets/showcase/year-review-2.webp +0 -0
- package/assets/showcase/year-review-3.webp +0 -0
- package/lib/browser.js +3 -1
- package/lib/bundle.js +8 -3
- package/lib/canvthumb.js +9 -6
- package/lib/client.js +7427 -2624
- package/lib/components.js +4 -2
- package/lib/core.js +762 -132
- package/lib/design-page-settings.js +48 -0
- package/lib/design-scope.js +36 -0
- package/lib/design-transactions.js +259 -0
- package/lib/drop-folder.js +25 -0
- package/lib/edits.js +125 -8
- package/lib/embedded/lvgl_shot.c +133 -0
- package/lib/embedded/qml_shot.py +66 -0
- package/lib/embedded-shot.js +400 -0
- package/lib/embedded-trust.js +76 -0
- package/lib/fonts.js +30 -21
- package/lib/frames.js +23 -23
- package/lib/gallery/css.js +9 -2
- package/lib/gallery/market-routes.js +23 -7
- package/lib/gallery/pack.js +25 -8
- package/lib/gallery/policy.js +6 -4
- package/lib/gallery/routes.js +255 -83
- package/lib/gallery/submit.js +285 -57
- package/lib/gallery/use.js +13 -4
- package/lib/handoff-embedded.js +1182 -0
- package/lib/handoff.js +212 -71
- package/lib/history.js +393 -43
- package/lib/htmlpack.js +34 -13
- package/lib/impl.js +3 -0
- package/lib/index.js +661 -136
- package/lib/inspire.js +73 -26
- package/lib/kinds.js +11 -2
- package/lib/look.js +45 -25
- package/lib/mock.js +41 -4
- package/lib/motion.js +90 -0
- package/lib/page-settings.js +103 -0
- package/lib/picker.js +348 -70
- package/lib/rules.js +85 -0
- package/lib/serve.js +154 -15
- package/lib/showcase.json +22 -0
- package/lib/styles.js +16 -7
- package/lib/system.js +19 -8
- package/lib/tool.js +2 -1
- package/lib/tweaks.js +146 -9
- package/lib/works.js +151 -19
- package/locale/auto/en.json +1 -1
- package/locale/auto/zh.json +1 -1
- package/locale/en.json +1 -1
- package/locale/offline/en.json +1 -1
- package/locale/offline/zh.json +2 -2
- package/locale/zh.json +1 -1
- package/package.json +3 -2
- package/skills/ui-design/SKILL.md +56 -46
- package/skills/ui-design/frames/dsh/frame.json +1 -1
- package/skills/ui-design/references/app.md +29 -2
- package/skills/ui-design/references/components.md +1 -1
- package/skills/ui-design/references/desktop.md +1 -1
- package/skills/ui-design/references/dshplugin.md +12 -12
- package/skills/ui-design/references/embedded.md +40 -0
- package/skills/ui-design/references/frames.md +20 -20
- package/skills/ui-design/references/miniprogram.md +2 -2
- package/skills/ui-design/references/mock.md +16 -0
- package/skills/ui-design/references/poster.md +2 -1
- package/skills/ui-design/references/tweaks.md +17 -0
- package/skills/ui-design/tokens.css +19 -5
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>放大程序坞</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id": "dock-magnify", "zh": "放大程序坞", "en": "Magnify Dock", "cat": "nav", "desc": "鼠标靠近,图标像磁铁一样鼓起来","desc_en":"Icons swell like magnets as the pointer gets close", "needs": "js", "play": "hover", "hint": "鼠标划过","hint_en":"Hover", "source": {"name": "Magic UI Dock", "url": "https://github.com/magicuidesign/magicui/blob/main/apps/www/registry/magicui/dock.tsx", "license": "MIT", "author": "Magic UI"}, "prompt": "放大程序坞:一排圆角图标放在毛玻璃底座上。鼠标在底座上横向移动时,每个图标按与鼠标的水平距离放大(距离 120px 内从 38px 线性插值到 58px),尺寸用弹簧跟随(质量 .1、刚度 150、阻尼 12),所以会微微过冲再落定;底座宽度跟着撑开,图标底部对齐。悬停的图标上方淡入小标签,点一下图标会跳一下,下面亮一个小点。鼠标离开后全部弹回 38px。颜色读 --color-surface / --color-line / --color-text,减少动效时不用弹簧。", "prompt_en": "Magnify dock: icons on a frosted-glass base. Each icon sizes by horizontal pointer distance, 38px to 58px linearly within 120px, via a spring (mass .1, stiffness 150, damping 12) with slight overshoot; the base widens, icons bottom-aligned. Hover fades in a label; click hops the icon and lights a dot. On leave all spring back to 38px. Reads --color-surface / --color-line / --color-text; reduced motion: no spring."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);background-image:radial-gradient(120% 80% at 20% 0%,color-mix(in srgb,#ff9f0a 16%,transparent),transparent 60%),radial-gradient(90% 70% at 100% 100%,color-mix(in srgb,#5e5ce6 18%,transparent),transparent 60%);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
#ghost{position:fixed;left:0;top:0;width:14px;height:14px;margin:-7px 0 0 -7px;border-radius:50%;background:rgba(255,255,255,.9);box-shadow:0 0 0 1px rgba(0,0,0,.12),0 2px 8px rgba(0,0,0,.25);opacity:0;transition:opacity .3s;pointer-events:none;z-index:9}
|
|
16
|
+
</style>
|
|
17
|
+
<style data-comp>
|
|
18
|
+
/* 放大程序坞 · 改写自 Magic UI 的 Dock(MIT,© Magic UI,https://github.com/magicuidesign/magicui/blob/main/apps/www/registry/magicui/dock.tsx)
|
|
19
|
+
原版是 React + framer-motion,这里改成不依赖框架的原生 JS;弹簧参数照原版。 */
|
|
20
|
+
.c-dock-magnify{--dk-size:38px;position:relative;display:flex;align-items:flex-end;gap:7px;height:calc(var(--dk-size) + 16px);padding:0 8px 8px;box-sizing:border-box;border-radius:20px;background:color-mix(in srgb,var(--color-surface,#fff) 62%,transparent);-webkit-backdrop-filter:blur(18px) saturate(1.6);backdrop-filter:blur(18px) saturate(1.6);box-shadow:inset 0 1px 0 rgba(255,255,255,.5),0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 10px 30px -8px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui)}
|
|
21
|
+
.c-dock-magnify .dk-i{position:relative;flex:none;width:var(--dk-size);height:var(--dk-size);padding:0;border:0;border-radius:24%;background:var(--bg);display:grid;place-items:center;cursor:pointer;color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.35),inset 0 -1px 0 rgba(0,0,0,.12),0 2px 6px rgba(0,0,0,.18);will-change:width,height;-webkit-tap-highlight-color:transparent}
|
|
22
|
+
.c-dock-magnify .dk-i svg{width:56%;height:56%;pointer-events:none}
|
|
23
|
+
.c-dock-magnify .dk-i:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:3px}
|
|
24
|
+
.c-dock-magnify .dk-i.hop{animation:dk-hop .5s cubic-bezier(.3,1.6,.5,1)}
|
|
25
|
+
.c-dock-magnify .dk-i.on::after{content:"";position:absolute;left:50%;bottom:-6px;width:4px;height:4px;margin-left:-2px;border-radius:50%;background:var(--color-text,#141413);opacity:.55}
|
|
26
|
+
.c-dock-magnify .dk-tip{position:absolute;left:50%;bottom:calc(100% + 8px);padding:4px 9px;border-radius:8px;white-space:nowrap;font-size:12px;font-weight:600;line-height:1.2;color:var(--color-text,#141413);background:color-mix(in srgb,var(--color-surface,#fff) 88%,transparent);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 4px 12px rgba(0,0,0,.14);opacity:0;transform:translate(-50%,4px) scale(.94);transition:opacity .16s,transform .2s cubic-bezier(.2,.8,.2,1);pointer-events:none}
|
|
27
|
+
.c-dock-magnify .dk-i.hot .dk-tip{opacity:1;transform:translate(-50%,0) scale(1)}
|
|
28
|
+
@keyframes dk-hop{0%,100%{translate:0 0}35%{translate:0 -14px}}
|
|
29
|
+
@media (prefers-reduced-motion:reduce){.c-dock-magnify .dk-i.hop{animation:none}}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<div class="stage-fit">
|
|
34
|
+
<nav class="c-dock-magnify" data-comp="dock-magnify" aria-label="常用">
|
|
35
|
+
<button class="dk-i" style="--bg:linear-gradient(160deg,#5ac8fa,#007aff)" aria-label="消息"><span class="dk-tip">消息</span><svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.5c5 0 9 3.4 9 7.6s-4 7.6-9 7.6c-1 0-2-.1-2.9-.4L4.5 20l1.2-3.6C4 15 3 13.1 3 11.1 3 6.9 7 3.5 12 3.5z"/></svg></button>
|
|
36
|
+
<button class="dk-i" style="--bg:linear-gradient(160deg,#ffd60a,#ff9f0a)" aria-label="便签"><span class="dk-tip">便签</span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M7 8h10M7 12h10M7 16h6"/></svg></button>
|
|
37
|
+
<button class="dk-i on" style="--bg:linear-gradient(160deg,#ff6482,#ff2d55)" aria-label="音乐"><span class="dk-tip">音乐</span><svg viewBox="0 0 24 24" fill="currentColor"><path d="M8 6.6 19 4v11.4h-2V8.3l-7 1.6v7.6H8z"/><circle cx="6.6" cy="17.6" r="2.6"/><circle cx="16.6" cy="15.4" r="2.6"/></svg></button>
|
|
38
|
+
<button class="dk-i" style="--bg:linear-gradient(160deg,#34c759,#248a3d)" aria-label="地图"><span class="dk-tip">地图</span><svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.8a6.6 6.6 0 0 0-6.6 6.6c0 4.8 6.6 11.8 6.6 11.8s6.6-7 6.6-11.8A6.6 6.6 0 0 0 12 2.8zm0 9.2a2.6 2.6 0 1 1 0-5.2 2.6 2.6 0 0 1 0 5.2z"/></svg></button>
|
|
39
|
+
<button class="dk-i" style="--bg:linear-gradient(160deg,#bf5af2,#5e5ce6)" aria-label="相册"><span class="dk-tip">相册</span><svg viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="7" r="3.2" opacity=".95"/><circle cx="17" cy="12" r="3.2" opacity=".8"/><circle cx="12" cy="17" r="3.2" opacity=".65"/><circle cx="7" cy="12" r="3.2" opacity=".8"/></svg></button>
|
|
40
|
+
</nav>
|
|
41
|
+
</div>
|
|
42
|
+
<div id="ghost"></div>
|
|
43
|
+
<script data-comp>
|
|
44
|
+
/* 放大程序坞逻辑:每个 .c-dock-magnify 各自一套;pointer 位置 → 目标尺寸 → 弹簧跟随(照 Magic UI Dock 的参数) */
|
|
45
|
+
(() => {
|
|
46
|
+
const SIZE = 38, MAG = 58, DIST = 120, MASS = 0.1, K = 150, C = 12 // 原版 40/60/140,小卡片里缩了一点
|
|
47
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
48
|
+
document.querySelectorAll('.c-dock-magnify').forEach((dock) => {
|
|
49
|
+
const items = [...dock.querySelectorAll('.dk-i')].map((el) => ({ el, x: SIZE, v: 0, to: SIZE }))
|
|
50
|
+
let mouseX = Infinity, raf = 0, last = 0
|
|
51
|
+
const target = () => items.forEach((it) => {
|
|
52
|
+
const r = it.el.getBoundingClientRect(); const d = Math.abs(mouseX - (r.left + r.width / 2))
|
|
53
|
+
it.to = d >= DIST ? SIZE : MAG - (MAG - SIZE) * (d / DIST)
|
|
54
|
+
})
|
|
55
|
+
const tick = (t) => {
|
|
56
|
+
const dt = Math.min(0.032, (t - (last || t)) / 1000) || 0.016; last = t
|
|
57
|
+
target(); let moving = false
|
|
58
|
+
for (const it of items) {
|
|
59
|
+
if (reduced) { it.x = it.to; it.v = 0 } else for (let s = 0, n = Math.ceil(dt / 0.002), h = dt / n; s < n; s++) { const a = (-K * (it.x - it.to) - C * it.v) / MASS; it.v += a * h; it.x += it.v * h } // 小步积分,帧卡了也不会炸
|
|
60
|
+
if (Math.abs(it.x - it.to) > 0.05 || Math.abs(it.v) > 0.05) moving = true
|
|
61
|
+
it.el.style.width = it.el.style.height = it.x.toFixed(2) + 'px'
|
|
62
|
+
}
|
|
63
|
+
raf = moving ? requestAnimationFrame(tick) : 0; if (!raf) last = 0
|
|
64
|
+
}
|
|
65
|
+
const kick = () => { if (!raf) raf = requestAnimationFrame(tick) }
|
|
66
|
+
dock.addEventListener('pointermove', (e) => { mouseX = e.clientX; items.forEach((it) => it.el.classList.toggle('hot', it.el.contains(e.target) || it.el === e.target)); kick() })
|
|
67
|
+
dock.addEventListener('pointerleave', () => { mouseX = Infinity; items.forEach((it) => it.el.classList.remove('hot')); kick() })
|
|
68
|
+
dock.addEventListener('click', (e) => { const b = e.target.closest('.dk-i'); if (!b) return; b.classList.remove('hop'); void b.offsetWidth; b.classList.add('hop'); b.classList.add('on') })
|
|
69
|
+
dock.addEventListener('animationend', (e) => e.target.classList.remove('hop'))
|
|
70
|
+
dock.dkMove = (x) => { mouseX = x; kick() } // 给演示舞台用
|
|
71
|
+
})
|
|
72
|
+
})()
|
|
73
|
+
</script>
|
|
74
|
+
<script data-stage>
|
|
75
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
76
|
+
(() => {
|
|
77
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
78
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
79
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
80
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
81
|
+
const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
|
|
82
|
+
fit(); addEventListener('resize', fit)
|
|
83
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
84
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
85
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
86
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
87
|
+
// ===== 只改这一段 =====
|
|
88
|
+
const ghost = document.getElementById('ghost'); const items = [...el.querySelectorAll('.dk-i')]; let raf = 0
|
|
89
|
+
const hot = (x) => items.forEach((b) => { const r = b.getBoundingClientRect(); b.classList.toggle('hot', x >= r.left && x <= r.right) })
|
|
90
|
+
const DEMO = {
|
|
91
|
+
settle () { setTimeout(() => { const r = items[2].getBoundingClientRect(); const x = r.left + r.width * 0.8; el.dkMove(x); hot(x) }, 50) }, // 落定状态:停在「音乐」上
|
|
92
|
+
loop () { // 一个看不见的手指:停左边 → 划到右边 → 停 → 划回来
|
|
93
|
+
let t0 = 0
|
|
94
|
+
const f = (t) => {
|
|
95
|
+
t0 = t0 || t; const p = ((t - t0) / 5200) % 1; const r = el.getBoundingClientRect(); const pad = 26 * (+getComputedStyle(root).getPropertyValue('--fit') || 1)
|
|
96
|
+
const s = p < 0.1 ? 0 : p < 0.45 ? (p - 0.1) / 0.35 : p < 0.55 ? 1 : p < 0.9 ? 1 - (p - 0.55) / 0.35 : 0
|
|
97
|
+
const e = s * s * (3 - 2 * s); const x = r.left + pad + (r.width - pad * 2) * e; const y = r.top + r.height / 2 + 4
|
|
98
|
+
ghost.style.transform = `translate(${x}px,${y}px)`; ghost.style.opacity = '1'; el.dkMove(x); hot(x)
|
|
99
|
+
raf = requestAnimationFrame(f)
|
|
100
|
+
}
|
|
101
|
+
raf = requestAnimationFrame(f)
|
|
102
|
+
},
|
|
103
|
+
stop () { cancelAnimationFrame(raf); raf = 0; ghost.style.opacity = '0'; el.dkMove(Infinity); hot(-1) },
|
|
104
|
+
}
|
|
105
|
+
// =====================
|
|
106
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
107
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
108
|
+
addEventListener('message', (e) => {
|
|
109
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
110
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
111
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
112
|
+
})
|
|
113
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
114
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
115
|
+
})()
|
|
116
|
+
</script>
|
|
117
|
+
</body>
|
|
118
|
+
</html>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>进度下载</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"download-ring","zh":"进度下载","en":"Download Ring","cat":"button","desc":"胶囊收圆走满进度环,箭头落下变对勾再舒展回胶囊","desc_en":"The pill shrinks to a circle, fills a progress ring, and the arrow turns into a check","needs":"js","play":"press","hint":"点一下","hint_en":"Tap","source":null,"prompt":"进度下载按钮:144×52 胶囊表面,浅色带双层柔影、深色带发丝边。按下微缩(scale .94,100ms),松手后胶囊用弹簧收成 58×58 圆形(580ms),文字淡出,外圈 SVG 进度环沿顺时针平顺走满 100%(820ms)且中心箭头轻落呼吸;满圈时圆体转成功色并回弹,箭头下沉淡出、一笔画成白色对勾;停 1.18s 后舒展回胶囊。颜色读 --color-surface / --color-text / --color-primary / --color-success / --color-line,减少动效定格在 68% 进度环态。","prompt_en":"Download button: 144×52 pill. Press .94 (100ms); release springs it to a 58×58 circle (580ms), the label fades, an SVG ring fills clockwise (820ms ease-in-out) as the arrow bobs. Full: turns --color-success with a pop, arrow sinks, a white check draws in one stroke; after 1.18s it unfolds back. Reads --color-surface / --color-text / --color-primary / --color-success / --color-line; reduced motion: static 68% ring."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--color-success:#2eb85c;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.12);--color-success:#30d158}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 进度下载 · 胶囊收缩成圆 + 外圈进度环 + 箭头落下变对勾。颜色读设计变量:--color-surface / --color-text / --color-primary / --color-success / --color-line */
|
|
18
|
+
.c-download-ring{--dr-acc:var(--color-primary,#0a84ff);--dr-ok:var(--color-success,#2eb85c);--dr-w:144px;--dr-h:52px;--dr-c:58px;--dr-p:0;--dr-spring:linear(0,.04,.14,.274,.421,.566,.699,.812,.905,.976,1.026,1.059,1.077,1.083,1.082,1.074,1.063,1.051,1.039,1.028,1.018,1.01,1.003,.999,.996,.994,.993,.993,.994,.994,.995,.996,1);position:relative;width:var(--dr-w);height:70px;display:grid;place-items:center;font-family:var(--font-sans,system-ui)}
|
|
19
|
+
.c-download-ring .dr-btn{position:relative;width:var(--dr-w);height:var(--dr-h);padding:0;border:0;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;gap:8px;color:var(--color-text,#141413);background:var(--color-surface,#fff);box-shadow:inset 0 1px 0 rgba(255,255,255,.32),0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.06),0 14px 30px -10px rgba(0,0,0,.28);cursor:pointer;transition:width .58s var(--dr-spring),height .58s var(--dr-spring),transform .58s var(--dr-spring),background-color .32s,color .25s,box-shadow .35s;-webkit-tap-highlight-color:transparent;overflow:visible}
|
|
20
|
+
.c-download-ring .dr-btn::before{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(180deg,color-mix(in srgb,#fff 14%,var(--dr-ok)),var(--dr-ok));box-shadow:inset 0 1px 0 rgba(255,255,255,.35),inset 0 -1px 0 rgba(0,0,0,.1);opacity:0;transition:opacity .28s ease;pointer-events:none}
|
|
21
|
+
.c-download-ring .dr-btn:hover{transform:translateY(-1px)}
|
|
22
|
+
.c-download-ring .dr-btn:active,.c-download-ring.is-press .dr-btn{transform:scale(.94);transition:transform .1s cubic-bezier(.3,0,.5,1)}
|
|
23
|
+
.c-download-ring .dr-btn:focus-visible{outline:2px solid var(--dr-acc);outline-offset:4px}
|
|
24
|
+
.c-download-ring .dr-ring{position:absolute;left:50%;top:50%;width:76px;height:76px;margin:-38px 0 0 -38px;overflow:visible;transform:rotate(-90deg) scale(.84);opacity:0;pointer-events:none;transition:opacity .26s ease,transform .48s var(--dr-spring)}
|
|
25
|
+
.c-download-ring .dr-ring circle{fill:none;stroke-width:3;stroke-linecap:round}
|
|
26
|
+
.c-download-ring .dr-track{stroke:var(--color-line,rgba(0,0,0,.12))}
|
|
27
|
+
.c-download-ring .dr-prog{stroke:var(--dr-acc);stroke-dasharray:194.8;stroke-dashoffset:calc(194.8 * (1 - var(--dr-p)));filter:drop-shadow(0 0 4px color-mix(in srgb,var(--dr-acc) 55%,transparent));transition:stroke .22s}
|
|
28
|
+
.c-download-ring .dr-ico{position:relative;z-index:2;width:22px;height:22px;flex:none;display:grid;place-items:center}
|
|
29
|
+
.c-download-ring .dr-ico svg{width:22px;height:22px;overflow:visible}
|
|
30
|
+
.c-download-ring .dr-arrow{fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transform-box:fill-box;transform-origin:center;transition:transform .26s cubic-bezier(.4,0,.2,1),opacity .18s ease}
|
|
31
|
+
.c-download-ring .dr-tray{fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;transition:opacity .18s ease,transform .22s ease}
|
|
32
|
+
.c-download-ring .dr-check{position:absolute;inset:0;width:22px;height:22px;fill:none;stroke:#fff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:26;stroke-dashoffset:26;opacity:0;transform:scale(.75);transition:opacity .14s,transform .48s var(--dr-spring)}
|
|
33
|
+
.c-download-ring .dr-txt{position:relative;z-index:2;font:600 15px/1 var(--font-sans,system-ui);white-space:nowrap;overflow:hidden;max-width:60px;transition:max-width .34s cubic-bezier(.3,.1,.2,1),opacity .18s ease,margin .34s ease}
|
|
34
|
+
.c-download-ring.is-load .dr-btn,.c-download-ring.is-done .dr-btn{width:var(--dr-c);height:var(--dr-c);gap:0}
|
|
35
|
+
.c-download-ring.is-load .dr-txt,.c-download-ring.is-done .dr-txt{max-width:0;opacity:0}
|
|
36
|
+
.c-download-ring.is-load .dr-ring{opacity:1;transform:rotate(-90deg) scale(1)}
|
|
37
|
+
.c-download-ring.is-load .dr-tray{opacity:0;transform:translateY(4px)}
|
|
38
|
+
.c-download-ring.is-load .dr-arrow{color:var(--dr-acc);animation:dr-bob .9s ease-in-out infinite}
|
|
39
|
+
.c-download-ring.is-done .dr-btn{color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.35),0 2px 5px rgba(0,0,0,.08),0 16px 34px -10px color-mix(in srgb,var(--dr-ok) 72%,transparent);animation:dr-pop .56s var(--dr-spring)}
|
|
40
|
+
.c-download-ring.is-done .dr-btn::before{opacity:1}
|
|
41
|
+
.c-download-ring.is-done .dr-ring{opacity:0;transform:rotate(-90deg) scale(1.2);transition:opacity .38s ease .04s,transform .46s cubic-bezier(.2,.8,.2,1)}
|
|
42
|
+
.c-download-ring.is-done .dr-prog{stroke:var(--dr-ok)}
|
|
43
|
+
.c-download-ring.is-done .dr-arrow{transform:translateY(11px) scale(.55);opacity:0;animation:none}
|
|
44
|
+
.c-download-ring.is-done .dr-tray{opacity:0}
|
|
45
|
+
.c-download-ring.is-done .dr-check{opacity:1;transform:scale(1);stroke-dashoffset:0;transition:opacity .12s .03s,transform .5s var(--dr-spring) .03s,stroke-dashoffset .3s cubic-bezier(.25,.9,.3,1) .04s}
|
|
46
|
+
@keyframes dr-bob{0%,100%{transform:translateY(-1.5px)}50%{transform:translateY(2.5px)}}
|
|
47
|
+
@keyframes dr-pop{0%{transform:scale(.9)}100%{transform:scale(1)}}
|
|
48
|
+
@media (prefers-reduced-motion:reduce){.c-download-ring *{animation:none!important;transition-duration:.01ms!important;transition-delay:0s!important}}
|
|
49
|
+
</style>
|
|
50
|
+
</head>
|
|
51
|
+
<body>
|
|
52
|
+
<div class="stage-fit">
|
|
53
|
+
<div class="c-download-ring" data-comp="download-ring">
|
|
54
|
+
<button class="dr-btn" type="button" aria-label="下载">
|
|
55
|
+
<svg class="dr-ring" viewBox="0 0 76 76" aria-hidden="true">
|
|
56
|
+
<circle class="dr-track" cx="38" cy="38" r="31"/>
|
|
57
|
+
<circle class="dr-prog" cx="38" cy="38" r="31"/>
|
|
58
|
+
</svg>
|
|
59
|
+
<span class="dr-ico" aria-hidden="true">
|
|
60
|
+
<svg viewBox="0 0 24 24">
|
|
61
|
+
<g class="dr-arrow"><path d="M12 4.5v10.5"/><path d="M7.8 11.4 12 15.6l4.2-4.2"/></g>
|
|
62
|
+
<path class="dr-tray" d="M5.5 18.8h13"/>
|
|
63
|
+
</svg>
|
|
64
|
+
<svg class="dr-check" viewBox="0 0 24 24"><path d="M5.2 12.6 9.8 17.2 18.8 7.6"/></svg>
|
|
65
|
+
</span>
|
|
66
|
+
<span class="dr-txt">下载</span>
|
|
67
|
+
</button>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<script data-comp>
|
|
71
|
+
/* 进度下载逻辑:点击收圆并用 rAF 驱动进度环走满 → 转对勾 → 舒展复位。支持一页多个实例。 */
|
|
72
|
+
(() => {
|
|
73
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
74
|
+
document.querySelectorAll('.c-download-ring').forEach((el) => {
|
|
75
|
+
const btn = el.querySelector('.dr-btn'); let raf = 0; let timer = 0; let busy = false
|
|
76
|
+
const stopAll = () => { cancelAnimationFrame(raf); raf = 0; clearTimeout(timer); timer = 0 }
|
|
77
|
+
const setP = (p) => el.style.setProperty('--dr-p', p.toFixed(4))
|
|
78
|
+
el.drReset = () => { stopAll(); busy = false; setP(0); el.classList.remove('is-press', 'is-load', 'is-done'); btn.setAttribute('aria-label', '下载') }
|
|
79
|
+
el.drStatic = (p = 0.68) => { stopAll(); busy = false; el.classList.remove('is-press', 'is-done'); el.classList.add('is-load'); setP(p); btn.setAttribute('aria-label', '下载中') }
|
|
80
|
+
el.drStart = (onReset) => {
|
|
81
|
+
if (busy) return; busy = true; stopAll(); setP(0)
|
|
82
|
+
if (reduced) { el.classList.add('is-done'); setP(1); btn.setAttribute('aria-label', '已完成'); timer = setTimeout(() => { el.drReset(); onReset && onReset() }, 1200); return }
|
|
83
|
+
el.classList.add('is-load'); btn.setAttribute('aria-label', '下载中')
|
|
84
|
+
const dur = 820; const t0 = performance.now()
|
|
85
|
+
const step = () => {
|
|
86
|
+
const u = Math.min(1, (performance.now() - t0) / dur)
|
|
87
|
+
const ease = u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2
|
|
88
|
+
setP(ease)
|
|
89
|
+
if (u < 1) { raf = requestAnimationFrame(step) } else {
|
|
90
|
+
raf = 0; el.classList.remove('is-load'); el.classList.add('is-done'); btn.setAttribute('aria-label', '已完成')
|
|
91
|
+
timer = setTimeout(() => { el.drReset(); onReset && onReset() }, 1180)
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
raf = requestAnimationFrame(step)
|
|
95
|
+
}
|
|
96
|
+
btn.addEventListener('click', () => el.drStart())
|
|
97
|
+
})
|
|
98
|
+
})()
|
|
99
|
+
</script>
|
|
100
|
+
<script data-stage>
|
|
101
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
102
|
+
(() => {
|
|
103
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
104
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
105
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
106
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
107
|
+
const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
|
|
108
|
+
fit(); addEventListener('resize', fit)
|
|
109
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
110
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
111
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
112
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
113
|
+
// ===== 只改这一段 =====
|
|
114
|
+
const DEMO = {
|
|
115
|
+
settle () { el.drStatic(0.68) }, // 落定状态:68% 外圈进度环
|
|
116
|
+
loop (later) {
|
|
117
|
+
el.classList.add('is-press')
|
|
118
|
+
later(() => { el.classList.remove('is-press'); el.drStart(() => later(() => DEMO.loop(later), 950)) }, 130)
|
|
119
|
+
},
|
|
120
|
+
stop () { el.classList.remove('is-press') },
|
|
121
|
+
}
|
|
122
|
+
// =====================
|
|
123
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
124
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
125
|
+
addEventListener('message', (e) => {
|
|
126
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
127
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
128
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
129
|
+
})
|
|
130
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
131
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
132
|
+
})()
|
|
133
|
+
</script>
|
|
134
|
+
</body>
|
|
135
|
+
</html>
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>展开详情卡</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"expand-card","zh":"展开详情卡","en":"Expandable Card","cat":"card","desc":"点一下小卡片,它原地长成详情卡,图和标题平滑挪到新位置","desc_en":"Tap the small card and it grows into a detail card in place","needs":"js","play":"press","hint":"点一下","hint_en":"Tap","source":null,"prompt":"原地展开卡片:同一张卡在两种排版间插值。小:200×68 横条,左侧 48px 方形缩略图、右侧标题和一行小字;大:260×172 详情卡,图铺满顶部 244×92、标题在图下、右下角「预订」按钮、图右上角关闭钮。卡片外形用 clip-path inset() 圆角裁出来,图用「等比缩放 + 两侧 inset 裁成方形」过渡,文字组平移加缩放,全部由一个 0–1 的进度驱动,进度用小步积分弹簧(略过冲)。按下整卡缩到 .97。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning。减少动效时直接切换。","prompt_en":"Expand card, two layouts: 200×68 strip (48px square thumb) to 260×172 detail (244×92 image, book and close buttons). clip-path inset() shapes it; the image scales uniformly, side insets crop it square; text moves and scales. One 0–1 progress on a substepped spring drives all; press .97. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning; reduced motion: instant."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 展开详情卡 · 脚本按进度 p(0 小 → 1 大)写各部分的 transform / clip-path。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning */
|
|
18
|
+
.c-expand-card{--ec-c:var(--color-primary,#0a84ff);position:relative;width:260px;height:172px;outline:none;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent}
|
|
19
|
+
.c-expand-card .ec-wrap{position:absolute;inset:0;filter:drop-shadow(0 0 .5px var(--color-line,rgba(0,0,0,.2))) drop-shadow(0 1px 1.5px rgba(0,0,0,.08)) drop-shadow(0 12px 18px rgba(0,0,0,.16));will-change:transform}
|
|
20
|
+
.c-expand-card .ec-card{position:absolute;inset:0;background:var(--color-surface,#fff);cursor:pointer;clip-path:inset(52px 30px 52px 30px round 18px)}
|
|
21
|
+
.c-expand-card:focus-visible .ec-card{outline:2px solid var(--ec-c);outline-offset:-3px}
|
|
22
|
+
.c-expand-card .ec-img{position:absolute;left:8px;top:8px;width:244px;height:92px;transform-origin:50% 50%}
|
|
23
|
+
.c-expand-card .ec-img svg{display:block;width:100%;height:100%}
|
|
24
|
+
.c-expand-card .ec-sky0{stop-color:color-mix(in srgb,var(--ec-c) 62%,#fff)}
|
|
25
|
+
.c-expand-card .ec-sky1{stop-color:color-mix(in srgb,var(--color-warning,#ffb340) 70%,#fff)}
|
|
26
|
+
.c-expand-card .ec-sun{fill:#fff;opacity:.85}
|
|
27
|
+
.c-expand-card .ec-m1{fill:color-mix(in srgb,var(--ec-c) 45%,#9db4d8)}
|
|
28
|
+
.c-expand-card .ec-m2{fill:color-mix(in srgb,var(--ec-c) 55%,#2c3e5c)}
|
|
29
|
+
.c-expand-card .ec-m3{fill:color-mix(in srgb,var(--ec-c) 30%,#18222f)}
|
|
30
|
+
.c-expand-card .ec-tent{fill:var(--color-warning,#ffb340)}
|
|
31
|
+
.c-expand-card .ec-txt{position:absolute;left:18px;top:112px;transform-origin:0 0}
|
|
32
|
+
.c-expand-card .ec-txt b{display:block;font-size:17px;line-height:22px;font-weight:700;color:var(--color-text,#141413)}
|
|
33
|
+
.c-expand-card .ec-txt span{display:block;margin-top:3px;font-size:12px;color:var(--color-muted,#76756f)}
|
|
34
|
+
.c-expand-card .ec-go{position:absolute;left:198px;top:78px;width:16px;height:16px;color:var(--color-muted,#76756f)}
|
|
35
|
+
.c-expand-card .ec-btn{position:absolute;right:14px;top:120px;height:32px;padding:0 16px;border-radius:16px;display:grid;place-items:center;font-size:13px;font-weight:600;color:#fff;background:var(--ec-c);box-shadow:inset 0 1px 0 rgba(255,255,255,.3),0 4px 12px -4px color-mix(in srgb,var(--ec-c) 70%,transparent)}
|
|
36
|
+
.c-expand-card .ec-x{position:absolute;right:16px;top:16px;width:24px;height:24px;border-radius:50%;display:grid;place-items:center;color:#fff;background:rgba(0,0,0,.28);backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
|
|
37
|
+
.c-expand-card .ec-x svg{width:10px;height:10px}
|
|
38
|
+
@media (prefers-reduced-motion:reduce){.c-expand-card *{transition:none!important}}
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body>
|
|
42
|
+
<div class="stage-fit">
|
|
43
|
+
<div class="c-expand-card" data-comp="expand-card" role="button" tabindex="0" aria-expanded="false" aria-label="雾岭营地,展开详情">
|
|
44
|
+
<div class="ec-wrap"><div class="ec-card">
|
|
45
|
+
<div class="ec-img"><svg viewBox="0 0 244 92" preserveAspectRatio="xMidYMid slice" aria-hidden="true"><defs><linearGradient id="ec-sky" x1="0" y1="0" x2="0" y2="1"><stop class="ec-sky0" offset="0"/><stop class="ec-sky1" offset="1"/></linearGradient></defs><rect width="244" height="92" fill="url(#ec-sky)"/><circle class="ec-sun" cx="160" cy="40" r="13"/><path class="ec-m1" d="M0 62 40 34l26 18 30-26 44 36 34-22 70 34v18H0z"/><path class="ec-m2" d="M0 76 54 50l36 22 34-18 52 26 30-12 38 14v10H0z"/><path class="ec-m3" d="M0 92V82l70-6 60 8 60-6 54 4v10z"/><path class="ec-tent" d="m112 80 10-16 10 16z"/></svg></div>
|
|
46
|
+
<div class="ec-txt"><b>雾岭营地</b><span>周六出发,住 2 晚</span></div>
|
|
47
|
+
<svg class="ec-go" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m6 3.5 4.5 4.5L6 12.5"/></svg>
|
|
48
|
+
<span class="ec-btn">预订</span>
|
|
49
|
+
<span class="ec-x" aria-hidden="true"><svg viewBox="0 0 10 10" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><path d="m1.5 1.5 7 7m0-7-7 7"/></svg></span>
|
|
50
|
+
</div></div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<script data-comp>
|
|
54
|
+
/* 展开详情卡逻辑:一个进度 p 驱动所有部分(同一张卡两种排版插值);p 和按压各用一根小步积分弹簧。一页可放多个。 */
|
|
55
|
+
(() => {
|
|
56
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
57
|
+
const L = (a, b, t) => a + (b - a) * t
|
|
58
|
+
const C01 = (x) => Math.max(0, Math.min(1, x))
|
|
59
|
+
document.querySelectorAll('.c-expand-card').forEach((el) => {
|
|
60
|
+
const $ = (s) => el.querySelector(s); const wrap = $('.ec-wrap'), card = $('.ec-card'), img = $('.ec-img'), txt = $('.ec-txt'), go = $('.ec-go'), btn = $('.ec-btn'), x = $('.ec-x')
|
|
61
|
+
let p = 0, pv = 0, goal = 0, s = 1, sv = 0, sGoal = 1, raf = 0, last = 0
|
|
62
|
+
const paint = () => {
|
|
63
|
+
const q = Math.max(p, -0.05)
|
|
64
|
+
card.style.clipPath = `inset(${L(52, 0, q).toFixed(2)}px ${L(30, 0, q).toFixed(2)}px ${L(52, 0, q).toFixed(2)}px ${L(30, 0, q).toFixed(2)}px round ${L(18, 22, C01(q)).toFixed(2)}px)`
|
|
65
|
+
const k = L(48 / 92, 1, q), ins = Math.max(0, L(76, 0, q)), r = L(12, 15, C01(q)) / k // 图:等比缩放 + 两侧裁成方形
|
|
66
|
+
img.style.transform = `translate(${L(-66, 0, q).toFixed(2)}px,${L(32, 0, q).toFixed(2)}px) scale(${k.toFixed(4)})`
|
|
67
|
+
img.style.clipPath = `inset(0 ${ins.toFixed(2)}px round ${r.toFixed(2)}px)`
|
|
68
|
+
txt.style.transform = `translate(${L(82, 0, q).toFixed(2)}px,${L(-46, 0, q).toFixed(2)}px) scale(${L(0.9, 1, q).toFixed(4)})`
|
|
69
|
+
go.style.opacity = C01(1 - q * 3).toFixed(3); go.style.transform = `translateX(${(q * 14).toFixed(2)}px)`
|
|
70
|
+
const d = C01((q - 0.5) / 0.4)
|
|
71
|
+
btn.style.opacity = x.style.opacity = d.toFixed(3)
|
|
72
|
+
btn.style.transform = `translateY(${((1 - d) * 10).toFixed(2)}px)`; x.style.transform = `scale(${L(0.5, 1, d).toFixed(3)})`
|
|
73
|
+
wrap.style.transform = s === 1 ? '' : `scale(${s.toFixed(4)})`
|
|
74
|
+
el.setAttribute('aria-expanded', goal > 0.5)
|
|
75
|
+
}
|
|
76
|
+
const tick = (t) => {
|
|
77
|
+
const dt = Math.min(0.032, (t - (last || t)) / 1000) || 0.016; last = t
|
|
78
|
+
for (let i = 0, n = Math.ceil(dt / 0.002), h = dt / n; i < n; i++) { pv += (-190 * (p - goal) - 21 * pv) * h; p += pv * h; sv += (-500 * (s - sGoal) - 26 * sv) * h; s += sv * h }
|
|
79
|
+
const rest = Math.abs(p - goal) < 0.0005 && Math.abs(pv) < 0.004 && Math.abs(s - sGoal) < 0.0005 && Math.abs(sv) < 0.004
|
|
80
|
+
if (rest) { p = goal; pv = 0; s = sGoal; sv = 0; raf = 0; last = 0 } else raf = requestAnimationFrame(tick)
|
|
81
|
+
paint()
|
|
82
|
+
}
|
|
83
|
+
const run = () => { if (reduced) { p = goal; s = sGoal; pv = sv = 0; paint() } else if (!raf) raf = requestAnimationFrame(tick) }
|
|
84
|
+
const inCard = (e) => { if (goal > 0.5) return true; const r = el.getBoundingClientRect(), f = r.width / 260, px = (e.clientX - r.left) / f, py = (e.clientY - r.top) / f; return px > 30 && px < 230 && py > 52 && py < 120 }
|
|
85
|
+
const toggle = (open = goal < 0.5) => { goal = open ? 1 : 0; run() }
|
|
86
|
+
let down = false
|
|
87
|
+
el.addEventListener('pointerdown', (e) => { if (!inCard(e)) return; down = true; sGoal = 0.97; run() })
|
|
88
|
+
el.addEventListener('pointerup', () => { if (!down) return; down = false; sGoal = 1; toggle() })
|
|
89
|
+
el.addEventListener('pointerleave', () => { if (down) { down = false; sGoal = 1; run() } })
|
|
90
|
+
el.addEventListener('pointercancel', () => { down = false; sGoal = 1; run() })
|
|
91
|
+
el.addEventListener('keydown', (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggle() } else if (e.key === 'Escape') toggle(false) })
|
|
92
|
+
el.ecPress = (on) => { sGoal = on ? 0.97 : 1; run() } // 给演示舞台用
|
|
93
|
+
el.ecToggle = toggle
|
|
94
|
+
el.ecSet = (open) => { goal = p = open ? 1 : 0; pv = 0; paint() }
|
|
95
|
+
paint()
|
|
96
|
+
})
|
|
97
|
+
})()
|
|
98
|
+
</script>
|
|
99
|
+
<script data-stage>
|
|
100
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
101
|
+
(() => {
|
|
102
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
103
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
104
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
105
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
106
|
+
const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
|
|
107
|
+
fit(); addEventListener('resize', fit)
|
|
108
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
109
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
110
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
111
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
112
|
+
// ===== 只改这一段 =====
|
|
113
|
+
const DEMO = {
|
|
114
|
+
settle () { el.ecSet(true) }, // 落定:展开后的详情卡
|
|
115
|
+
loop (later) {
|
|
116
|
+
later(() => el.ecPress(true), 500)
|
|
117
|
+
later(() => { el.ecPress(false); el.ecToggle(true) }, 640)
|
|
118
|
+
later(() => el.ecPress(true), 2500)
|
|
119
|
+
later(() => { el.ecPress(false); el.ecToggle(false) }, 2640)
|
|
120
|
+
later(() => DEMO.loop(later), 3900)
|
|
121
|
+
},
|
|
122
|
+
stop () { el.ecPress(false) },
|
|
123
|
+
}
|
|
124
|
+
// =====================
|
|
125
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
126
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
127
|
+
addEventListener('message', (e) => {
|
|
128
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
129
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
130
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
131
|
+
})
|
|
132
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
133
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
134
|
+
})()
|
|
135
|
+
</script>
|
|
136
|
+
</body>
|
|
137
|
+
</html>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>翻面票券</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id": "flip-card", "zh": "翻面票券", "en": "Flip Ticket", "cat": "card", "desc": "鼠标放上去整张票 3D 翻到背面的取餐码,移开翻回来;手机上点一下翻","desc_en":"Hover to flip the ticket in 3D to the pickup code; on touch screens, tap", "needs": "css", "play": "press", "hint": "悬停或点击","hint_en":"Hover or tap", "source": null, "prompt": "翻面票券:236×124,正反两面 backface-visibility:hidden 叠在 preserve-3d 翻转层里,外层 perspective 800px。翻转角用 @property 注册的 --fc-r(0–1)做弹簧 linear() 过渡(.95s 略过冲),每面盖一层随 sin(角度) 变深的暗影,地上影子随侧身变窄。正面 --color-surface:店名、品名、撕口票根(mask 挖缺口);背面 --color-primary 底:大号取餐码 + 条纹码。鼠标放上去(hover:hover)翻面并抬起 4px,移开翻回;手机和键盘用隐藏 checkbox。按住缩到 .97。减少动效时只换面。", "prompt_en": "Flip ticket 236×124: backface-visibility:hidden faces in a preserve-3d flipper, perspective 800px. Angle is @property --fc-r (0–1) on a linear() spring (.95s, slight overshoot); faces shade by sin(angle). Front (--color-surface): mask-notched stub; back (--color-primary): pickup code, barcode. Hover (hover:hover) flips, lifts 4px; touch/keyboard: hidden checkbox. Press .97. Reduced motion: instant."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 翻面票券 · 纯 CSS(checkbox + @property 角度过渡)。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
18
|
+
@property --fc-r{syntax:"<number>";inherits:true;initial-value:0}
|
|
19
|
+
.c-flip-card{--fc-r:0;--fc-s:max(0,sin(calc(var(--fc-r)*180deg)));--fc-spring:linear(0,.05,.18,.36,.55,.72,.86,.96,1.03,1.07,1.085,1.08,1.065,1.045,1.025,1.01,.998,.991,.988,.989,.992,.996,1,1.002,1.002,1);--fc-c:var(--color-primary,#0a84ff);position:relative;display:block;width:236px;height:124px;perspective:800px;cursor:pointer;font-family:var(--font-sans,system-ui);transition:--fc-r .95s var(--fc-spring);-webkit-tap-highlight-color:transparent}
|
|
20
|
+
.c-flip-card:has(input:checked){--fc-r:1}
|
|
21
|
+
@media (hover:hover){.c-flip-card:hover{--fc-r:1}}
|
|
22
|
+
.c-flip-card input{position:absolute;opacity:0;pointer-events:none}
|
|
23
|
+
.c-flip-card .fc-shadow{position:absolute;left:8%;right:8%;bottom:-12px;height:24px;border-radius:50%;background:radial-gradient(closest-side,rgba(0,0,0,.34),transparent);filter:blur(6px);transform:scaleX(calc(1 - var(--fc-s)*.62));opacity:calc(.9 - var(--fc-s)*.5);transition:translate .5s var(--fc-spring),scale .5s var(--fc-spring),opacity .4s}
|
|
24
|
+
.c-flip-card .fc-lift{position:absolute;inset:0;transform-style:preserve-3d;transition:transform .7s var(--fc-spring)}
|
|
25
|
+
.c-flip-card:hover .fc-lift,.c-flip-card.is-up .fc-lift{transform:translateY(-4px)}
|
|
26
|
+
.c-flip-card.is-peek .fc-lift{transform:translateY(-4px) rotateY(-12deg) rotateX(4deg)}
|
|
27
|
+
.c-flip-card:hover .fc-shadow,.c-flip-card.is-up .fc-shadow,.c-flip-card.is-peek .fc-shadow{translate:4px 4px;scale:1.06 1.25}
|
|
28
|
+
.c-flip-card:active .fc-lift,.c-flip-card.is-press .fc-lift{transform:translateY(-1px) scale(.97);transition-duration:.14s;transition-timing-function:cubic-bezier(.3,0,.5,1)}
|
|
29
|
+
.c-flip-card .fc-flip{position:absolute;inset:0;transform-style:preserve-3d;transform:rotateY(calc(var(--fc-r)*180deg))}
|
|
30
|
+
.c-flip-card .fc-face{position:absolute;inset:0;display:flex;border-radius:14px;overflow:hidden;backface-visibility:hidden;-webkit-backface-visibility:hidden;-webkit-mask:radial-gradient(circle 8px at var(--fc-x) 0,#0000 97%,#000) top/100% 51% no-repeat,radial-gradient(circle 8px at var(--fc-x) 100%,#0000 97%,#000) bottom/100% 51% no-repeat;mask:radial-gradient(circle 8px at var(--fc-x) 0,#0000 97%,#000) top/100% 51% no-repeat,radial-gradient(circle 8px at var(--fc-x) 100%,#0000 97%,#000) bottom/100% 51% no-repeat}
|
|
31
|
+
.c-flip-card .fc-face::after{content:"";position:absolute;inset:0;background:linear-gradient(100deg,rgba(0,0,0,.5),rgba(0,0,0,.15));opacity:calc(var(--fc-s)*.7);pointer-events:none}
|
|
32
|
+
.c-flip-card .fc-front{--fc-x:170px;color:var(--color-text,#141413);background:linear-gradient(160deg,color-mix(in srgb,var(--color-surface,#fff) 92%,#fff),var(--color-surface,#fff));box-shadow:inset 0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),inset 0 1px 0 rgba(255,255,255,.6)}
|
|
33
|
+
.c-flip-card .fc-main{flex:1;padding:16px 0 0 18px;display:flex;flex-direction:column}
|
|
34
|
+
.c-flip-card .fc-brand{display:flex;align-items:center;gap:6px;font-size:11px;font-weight:600;color:var(--color-muted,#76756f);letter-spacing:.04em}
|
|
35
|
+
.c-flip-card .fc-brand svg{width:16px;height:16px;color:var(--fc-c)}
|
|
36
|
+
.c-flip-card .fc-item{margin-top:auto;font-size:19px;font-weight:700;letter-spacing:-.01em}
|
|
37
|
+
.c-flip-card .fc-sub{margin:4px 0 16px;font-size:12px;color:var(--color-muted,#76756f)}
|
|
38
|
+
.c-flip-card .fc-stub{width:66px;display:grid;place-items:center;border-left:1.5px dashed var(--color-line,rgba(0,0,0,.14));margin:12px 0;font-size:20px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--fc-c)}
|
|
39
|
+
.c-flip-card .fc-stub small{display:block;font-size:10px;font-weight:600;color:var(--color-muted,#76756f);text-align:center}
|
|
40
|
+
.c-flip-card .fc-back{--fc-x:66px;transform:rotateY(180deg);color:#fff;background:radial-gradient(120% 90% at 85% 0%,color-mix(in srgb,var(--fc-c) 70%,#fff),transparent 60%),linear-gradient(160deg,var(--fc-c),color-mix(in srgb,var(--fc-c) 72%,#000));box-shadow:inset 0 1px 0 rgba(255,255,255,.35)}
|
|
41
|
+
.c-flip-card .fc-bar{width:66px;margin:14px 0;border-right:1.5px dashed rgba(255,255,255,.4);background:repeating-linear-gradient(90deg,rgba(255,255,255,.85) 0 2px,transparent 2px 4px,rgba(255,255,255,.85) 4px 5px,transparent 5px 8px,rgba(255,255,255,.85) 8px 11px,transparent 11px 13px) 14px 6px/38px calc(100% - 12px) no-repeat}
|
|
42
|
+
.c-flip-card .fc-code{flex:1;display:grid;place-content:center;justify-items:center;gap:2px}
|
|
43
|
+
.c-flip-card .fc-code small{font-size:11px;font-weight:600;opacity:.75;letter-spacing:.2em}
|
|
44
|
+
.c-flip-card .fc-code b{font-size:46px;line-height:1;font-weight:800;letter-spacing:.02em;font-variant-numeric:tabular-nums;text-shadow:0 2px 10px rgba(0,0,0,.18)}
|
|
45
|
+
.c-flip-card:has(input:focus-visible) .fc-face{outline:2px solid var(--fc-c);outline-offset:-2px}
|
|
46
|
+
@media (prefers-reduced-motion:reduce){.c-flip-card,.c-flip-card *{transition:none!important}}
|
|
47
|
+
</style>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<div class="stage-fit">
|
|
51
|
+
<label class="c-flip-card" data-comp="flip-card">
|
|
52
|
+
<input type="checkbox" aria-label="翻到背面看取餐码">
|
|
53
|
+
<span class="fc-shadow"></span>
|
|
54
|
+
<span class="fc-lift"><span class="fc-flip">
|
|
55
|
+
<span class="fc-face fc-front">
|
|
56
|
+
<span class="fc-main"><span class="fc-brand"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M4 14c0-4 3.6-8 8-8s8 4 8 8"/><path d="M8.5 13.5 10 8m5.5 5.5L14 8M3 14h18l-1.2 3.2a2 2 0 0 1-1.9 1.3H6.1a2 2 0 0 1-1.9-1.3z"/></svg>晨屿烘焙</span><span class="fc-item">燕麦拿铁</span><span class="fc-sub">大杯,少冰,1 份</span></span>
|
|
57
|
+
<span class="fc-stub"><span><small>No.</small>027</span></span>
|
|
58
|
+
</span>
|
|
59
|
+
<span class="fc-face fc-back"><span class="fc-bar"></span><span class="fc-code"><small>取餐码</small><b>A27</b></span></span>
|
|
60
|
+
</span></span>
|
|
61
|
+
</label>
|
|
62
|
+
</div>
|
|
63
|
+
<script data-stage>
|
|
64
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
65
|
+
(() => {
|
|
66
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
67
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
68
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
69
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
70
|
+
const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
|
|
71
|
+
fit(); addEventListener('resize', fit)
|
|
72
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
73
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
74
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
75
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
76
|
+
// ===== 只改这一段 =====
|
|
77
|
+
const box = el.querySelector('input')
|
|
78
|
+
const DEMO = {
|
|
79
|
+
settle () { el.classList.add('is-peek') }, // 落定:正面微微侧过来,看得出是一张有厚度的票
|
|
80
|
+
loop (later) {
|
|
81
|
+
later(() => { el.classList.add('is-up'); box.checked = true }, 700) // 像鼠标放上去:抬起 + 翻到背面
|
|
82
|
+
later(() => { el.classList.remove('is-up'); box.checked = false }, 2700) // 移开:翻回正面
|
|
83
|
+
later(() => DEMO.loop(later), 3900)
|
|
84
|
+
},
|
|
85
|
+
stop () { el.classList.remove('is-press', 'is-peek', 'is-up'); box.checked = false },
|
|
86
|
+
}
|
|
87
|
+
// =====================
|
|
88
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
89
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
90
|
+
addEventListener('message', (e) => {
|
|
91
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
92
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
93
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
94
|
+
})
|
|
95
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
96
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
97
|
+
})()
|
|
98
|
+
</script>
|
|
99
|
+
</body>
|
|
100
|
+
</html>
|