dsh-design-studio 2.0.0 → 2.1.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 +2 -1
- package/README.md +2 -1
- package/THIRD_PARTY_NOTICES.md +319 -0
- package/assets/demo.gif +0 -0
- package/assets/hero-sm.jpg +0 -0
- package/assets/motion/ai-capsule.html +4 -2
- package/assets/motion/ai-glow-input.html +4 -2
- package/assets/motion/app-fab.html +130 -0
- package/assets/motion/app-gallery.html +125 -0
- package/assets/motion/app-index.html +138 -0
- package/assets/motion/app-largetitle.html +138 -0
- package/assets/motion/app-onboard.html +141 -0
- package/assets/motion/app-player.html +152 -0
- package/assets/motion/app-popover.html +133 -0
- package/assets/motion/app-rings.html +143 -0
- package/assets/motion/app-searchhist.html +131 -0
- package/assets/motion/app-tabbar.html +148 -0
- package/assets/motion/app-tabs.html +150 -0
- package/assets/motion/app-video.html +136 -0
- package/assets/motion/balance-odometer.html +4 -2
- package/assets/motion/bottom-sheet.html +4 -2
- package/assets/motion/brightness-pill.html +4 -2
- package/assets/motion/chart-area.html +111 -0
- package/assets/motion/chart-bar.html +100 -0
- package/assets/motion/chart-donut.html +145 -0
- package/assets/motion/chart-funnel.html +120 -0
- package/assets/motion/chart-gantt.html +140 -0
- package/assets/motion/chart-gauge.html +126 -0
- package/assets/motion/chart-heat.html +121 -0
- package/assets/motion/chart-kpi.html +110 -0
- package/assets/motion/chart-line.html +154 -0
- package/assets/motion/chart-radar.html +153 -0
- package/assets/motion/chart-rank.html +112 -0
- package/assets/motion/chart-stack.html +107 -0
- package/assets/motion/comet-ring.html +4 -2
- package/assets/motion/copy-morph.html +4 -2
- package/assets/motion/cube-grid.html +4 -2
- package/assets/motion/day-night.html +4 -2
- package/assets/motion/dial-knob.html +4 -2
- package/assets/motion/dock-magnify.html +4 -2
- package/assets/motion/download-ring.html +4 -2
- package/assets/motion/expand-card.html +4 -2
- package/assets/motion/flip-card.html +4 -2
- package/assets/motion/hold-pay.html +4 -2
- package/assets/motion/holo-card.html +4 -2
- package/assets/motion/keycap.html +4 -2
- package/assets/motion/like-jelly.html +4 -2
- package/assets/motion/liquid-progress.html +4 -2
- package/assets/motion/liquid-segment.html +4 -2
- package/assets/motion/live-capsule.html +4 -2
- package/assets/motion/m-actionsheet.html +84 -0
- package/assets/motion/m-address.html +113 -0
- package/assets/motion/m-buybar.html +122 -0
- package/assets/motion/m-calendar.html +135 -0
- package/assets/motion/m-capsule-nav.html +97 -0
- package/assets/motion/m-cart.html +162 -0
- package/assets/motion/m-category.html +154 -0
- package/assets/motion/m-chat.html +125 -0
- package/assets/motion/m-coupon.html +84 -0
- package/assets/motion/m-dialog.html +102 -0
- package/assets/motion/m-empty.html +121 -0
- package/assets/motion/m-filter.html +171 -0
- package/assets/motion/m-goods.html +151 -0
- package/assets/motion/m-grid.html +98 -0
- package/assets/motion/m-login.html +127 -0
- package/assets/motion/m-msglist.html +88 -0
- package/assets/motion/m-order.html +111 -0
- package/assets/motion/m-profile.html +110 -0
- package/assets/motion/m-pull.html +199 -0
- package/assets/motion/m-settings.html +81 -0
- package/assets/motion/m-sku.html +114 -0
- package/assets/motion/m-swiper.html +163 -0
- package/assets/motion/m-timeline.html +109 -0
- package/assets/motion/m-wheel.html +182 -0
- package/assets/motion/marker-highlight.html +4 -2
- package/assets/motion/marquee-logos.html +4 -2
- package/assets/motion/mp-cartbar.html +158 -0
- package/assets/motion/mp-checkin.html +121 -0
- package/assets/motion/mp-form.html +128 -0
- package/assets/motion/mp-group.html +148 -0
- package/assets/motion/mp-invite.html +119 -0
- package/assets/motion/mp-points.html +143 -0
- package/assets/motion/mp-queue.html +136 -0
- package/assets/motion/mp-rate.html +166 -0
- package/assets/motion/mp-seckill.html +140 -0
- package/assets/motion/mp-store.html +137 -0
- package/assets/motion/mp-vip.html +126 -0
- package/assets/motion/mp-wizard.html +174 -0
- package/assets/motion/otp-code.html +7 -4
- package/assets/motion/password-eye.html +4 -2
- package/assets/motion/ruler-slider.html +4 -2
- package/assets/motion/search-expand.html +4 -2
- package/assets/motion/send-fly.html +4 -2
- package/assets/motion/skeleton-shine.html +4 -2
- package/assets/motion/star-rate.html +4 -2
- package/assets/motion/success-check.html +4 -2
- package/assets/motion/suggest-chips.html +4 -2
- package/assets/motion/swipe-row.html +4 -2
- package/assets/motion/tabbar-bounce.html +4 -2
- package/assets/motion/tactile-controls.html +4 -2
- package/assets/motion/text-scramble.html +4 -2
- package/assets/motion/toast-stack.html +4 -2
- package/assets/motion/token-stream.html +4 -2
- package/assets/motion/um-bell.html +106 -0
- package/assets/motion/um-chips.html +132 -0
- package/assets/motion/um-coin.html +119 -0
- package/assets/motion/um-hue.html +128 -0
- package/assets/motion/um-ink-switch.html +129 -0
- package/assets/motion/um-leaf-tabs.html +138 -0
- package/assets/motion/um-plan.html +110 -0
- package/assets/motion/um-radial.html +104 -0
- package/assets/motion/um-stroke-check.html +86 -0
- package/assets/motion/um-swipe-confirm.html +182 -0
- package/assets/motion/um-tide.html +180 -0
- package/assets/motion/voice-orb.html +4 -2
- package/assets/motion/web-404.html +95 -0
- package/assets/motion/web-cmdk.html +167 -0
- package/assets/motion/web-dropdown.html +94 -0
- package/assets/motion/web-faq.html +84 -0
- package/assets/motion/web-footer.html +109 -0
- package/assets/motion/web-hero.html +98 -0
- package/assets/motion/web-navbar.html +149 -0
- package/assets/motion/web-newsletter.html +124 -0
- package/assets/motion/web-pagination.html +132 -0
- package/assets/motion/web-pricing.html +110 -0
- package/assets/motion/web-testimonial.html +129 -0
- package/assets/motion/web-upload.html +160 -0
- package/lib/client.js +76 -17
- package/lib/index.js +6 -2
- package/lib/motion.js +11 -2
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
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":"um-ink-switch","zh":"墨滴开关","en":"Ink Switch","cat":"input","desc":"拨动开关时墨滴从滑钮里散开,圆面晕染整条轨道并溅出三颗墨点","desc_en":"Toggling floods the track with a circular ink spread and three tiny splashes","needs":"js","play":"press","hint":"点一下","hint_en":"Tap to toggle","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/index.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"墨滴开关:84×46 圆角 23px 胶囊轨道,内嵌 36×36 圆形滑钮(距边 5px,滑距 38px)。关闭时滑钮中央有一滴水滴形墨点;开启后滑钮带挤压拉长(520ms)弹到右侧,同时主色圆面用 clip-path 从左端扩张到半径 80px 晕染全轨(640ms),三颗 5px 墨点按 -60°/0°/60° 溅出淡出(460ms);关闭时圆面从右端收拢(460ms),墨点重新弹回滑钮中央。颜色读 --color-surface / --color-text / --color-line / --color-primary,减少动效直接切态。","prompt_en":"Ink switch: 84x46 track (23px radius) with a 36x36 knob (5px inset, 38px travel). Off shows an ink teardrop inside the knob. On springs the knob across (520ms) as a --color-primary circle clip-path floods to 80px (640ms) and three 5px drops splash at -60/0/60 deg (460ms); off contracts it (460ms). Reads --color-surface / --color-text / --color-line / --color-primary; reduced motion snaps."}</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
|
+
/* 墨滴开关:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/index.html(#ink-switch):保留 84×46 尺寸、clip-path 圆形扩散、三颗墨点飞溅与滑钮形变数值,改接设计变量并适配舞台。
|
|
18
|
+
读 --color-surface / --color-text / --color-line / --color-primary */
|
|
19
|
+
.c-um-ink-switch{--is-acc:var(--color-primary,#0a84ff);--is-rail:color-mix(in srgb,var(--color-text,#141413) 13%,transparent);--is-sp:cubic-bezier(.3,1.45,.5,1);position:relative;box-sizing:border-box;width:84px;height:46px;padding:0;border:0;border-radius:23px;background:var(--is-rail);box-shadow:inset 0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),inset 0 1px 3px rgba(0,0,0,.08);overflow:hidden;isolation:isolate;cursor:pointer;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent}
|
|
20
|
+
.c-um-ink-switch:focus-visible{outline:2px solid var(--is-acc);outline-offset:4px}
|
|
21
|
+
.c-um-ink-switch .is-fill{position:absolute;inset:0;background:var(--is-acc);clip-path:circle(0 at 23px 50%)}
|
|
22
|
+
.c-um-ink-switch[aria-checked="true"] .is-fill{clip-path:circle(80px at 61px 50%)}
|
|
23
|
+
.c-um-ink-switch .is-knob{position:absolute;top:5px;left:5px;width:36px;height:36px;border-radius:18px;background:var(--color-surface,#fff);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),0 1px 2px rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.12);transition:translate .52s var(--is-sp),scale .12s,box-shadow .25s}
|
|
24
|
+
.c-um-ink-switch .is-knob::after{content:"";position:absolute;inset:12px;border-radius:50% 50% 50% 50%/58% 58% 42% 42%;background:var(--is-acc);transition:scale .42s var(--is-sp) .26s}
|
|
25
|
+
.c-um-ink-switch[aria-checked="true"] .is-knob{translate:38px 0}
|
|
26
|
+
.c-um-ink-switch[aria-checked="true"] .is-knob::after{scale:0;transition-delay:0s;transition-duration:.22s}
|
|
27
|
+
.c-um-ink-switch .is-splash i{position:absolute;top:50%;left:23px;width:5px;height:5px;margin:-2.5px;border-radius:50%;background:var(--is-acc);opacity:0;pointer-events:none}
|
|
28
|
+
.c-um-ink-switch:hover .is-knob{box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),0 1px 2px rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.12),0 0 0 4px color-mix(in srgb,var(--is-acc) 16%,transparent)}
|
|
29
|
+
.c-um-ink-switch:active .is-knob{scale:.92}
|
|
30
|
+
@media (prefers-reduced-motion:reduce){.c-um-ink-switch,.c-um-ink-switch *,.c-um-ink-switch *::after{transition-duration:0s!important;transition-delay:0s!important}}
|
|
31
|
+
</style>
|
|
32
|
+
</head>
|
|
33
|
+
<body>
|
|
34
|
+
<div class="stage-fit">
|
|
35
|
+
<button class="c-um-ink-switch" data-comp="um-ink-switch" type="button" role="switch" aria-checked="true" aria-label="墨滴开关">
|
|
36
|
+
<span class="is-fill" aria-hidden="true"></span>
|
|
37
|
+
<span class="is-splash" aria-hidden="true"><i></i><i></i><i></i></span>
|
|
38
|
+
<span class="is-knob" aria-hidden="true"></span>
|
|
39
|
+
</button>
|
|
40
|
+
</div>
|
|
41
|
+
<script data-comp>
|
|
42
|
+
/* 墨滴开关逻辑:点击切换开关,驱动滑钮挤压回弹、墨色圆形扩散与三颗墨点飞溅 */
|
|
43
|
+
(() => {
|
|
44
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
45
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
46
|
+
document.querySelectorAll('.c-um-ink-switch').forEach((el) => {
|
|
47
|
+
const fill = el.querySelector('.is-fill')
|
|
48
|
+
const knob = el.querySelector('.is-knob')
|
|
49
|
+
const splash = [...el.querySelectorAll('.is-splash i')]
|
|
50
|
+
let motions = []
|
|
51
|
+
const cancel = () => { motions.forEach((m) => m.cancel()); motions = [] }
|
|
52
|
+
rm.addEventListener('change', cancel)
|
|
53
|
+
el.isSet = (on, anim = true) => {
|
|
54
|
+
el.setAttribute('aria-checked', String(on))
|
|
55
|
+
el.dataset.on = on ? '1' : '0'
|
|
56
|
+
cancel()
|
|
57
|
+
if (!anim || !ok()) return
|
|
58
|
+
motions.push(knob.animate(
|
|
59
|
+
[{ scale: '1 1' }, { scale: '1.3 .84', offset: .32 }, { scale: '.94 1.06', offset: .68 }, { scale: '1 1' }],
|
|
60
|
+
{ duration: 520, easing: 'cubic-bezier(.3,.7,.4,1)' }
|
|
61
|
+
))
|
|
62
|
+
if (on) {
|
|
63
|
+
motions.push(fill.animate(
|
|
64
|
+
[{ clipPath: 'circle(0px at 23px 50%)' }, { clipPath: 'circle(14px at 23px 50%)', offset: .18 }, { clipPath: 'circle(80px at 23px 50%)' }],
|
|
65
|
+
{ duration: 640, easing: 'cubic-bezier(.2,.75,.25,1)' }
|
|
66
|
+
))
|
|
67
|
+
splash.forEach((drop, i) => {
|
|
68
|
+
const a = (-60 + i * 60) * Math.PI / 180
|
|
69
|
+
const x = Math.cos(a) * (22 + i * 4), y = Math.sin(a) * 14
|
|
70
|
+
motions.push(drop.animate([
|
|
71
|
+
{ opacity: 1, transform: 'translate(0,0) scale(1)' },
|
|
72
|
+
{ opacity: 1, transform: `translate(${x}px,${y}px) scale(.9)`, offset: .55 },
|
|
73
|
+
{ opacity: 0, transform: `translate(${x * 1.25}px,${y * 1.25}px) scale(0)` },
|
|
74
|
+
], { duration: 460, delay: 40 + i * 30, easing: 'cubic-bezier(.2,.8,.3,1)' }))
|
|
75
|
+
})
|
|
76
|
+
} else {
|
|
77
|
+
motions.push(fill.animate(
|
|
78
|
+
[{ clipPath: 'circle(80px at 61px 50%)' }, { clipPath: 'circle(18px at 61px 50%)', offset: .7 }, { clipPath: 'circle(0px at 61px 50%)' }],
|
|
79
|
+
{ duration: 460, easing: 'cubic-bezier(.5,0,.3,1)' }
|
|
80
|
+
))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
el.isStop = cancel
|
|
84
|
+
el.addEventListener('click', () => {
|
|
85
|
+
el.isSet(el.getAttribute('aria-checked') !== 'true', true)
|
|
86
|
+
el.dispatchEvent(new Event('change', { bubbles: true }))
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
})()
|
|
90
|
+
</script>
|
|
91
|
+
<script data-stage>
|
|
92
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
93
|
+
(() => {
|
|
94
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
95
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
96
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
97
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
98
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
99
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
100
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
101
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
102
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
103
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
104
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
105
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
106
|
+
// ===== 只改这一段 =====
|
|
107
|
+
const DEMO = {
|
|
108
|
+
settle () { el.isSet(true, false) },
|
|
109
|
+
loop (later) {
|
|
110
|
+
later(() => el.isSet(false, true), 500)
|
|
111
|
+
later(() => el.isSet(true, true), 2100)
|
|
112
|
+
later(() => DEMO.loop(later), 3500)
|
|
113
|
+
},
|
|
114
|
+
stop () { el.isStop() },
|
|
115
|
+
}
|
|
116
|
+
// =====================
|
|
117
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
118
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
119
|
+
addEventListener('message', (e) => {
|
|
120
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
121
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
122
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
123
|
+
})
|
|
124
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
125
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
126
|
+
})()
|
|
127
|
+
</script>
|
|
128
|
+
</body>
|
|
129
|
+
</html>
|
|
@@ -0,0 +1,138 @@
|
|
|
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":"um-leaf-tabs","zh":"叶片页签","en":"Leaf Tabs","cat":"nav","desc":"切换周期时,页签底片像树叶一样在空中翻转 180 度落位,下方柱图错拍伸缩","desc_en":"The active pill flips 180 degrees in 3D like a leaf while seven bars spring to the new range","needs":"js","play":"press","hint":"点页签","hint_en":"Switch tab","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/index.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"叶片页签:上方 4 列等宽(每格 52×34、圆角 12px 槽底、260px 透视)放置「日、周、月、年」页签;切换时高亮滑片按方向在 460ms 内沿 Y 轴翻转 ±180° 并轻浮(translateZ 14px、scaleY 1.08、亮度压暗至 0.82)落到新项。下方 7 根 14px 宽趋势柱按 28ms 错拍弹性(550ms)切换高度,最高柱以满饱和主色突出。支持键盘左右键切换。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary,减少动效直接切位。","prompt_en":"Leaf tabs: four 52x34 tabs (day, week, month, year) inside a 12px-radius track with 260px perspective. Switching flips the surface pill +/-180 deg along Y over 460ms with a 14px Z lift, 1.08 scaleY, and .82 brightness midpoint. Below, seven 14px trend bars spring to new heights (550ms, 28ms stagger), highlighting the peak at 100% --color-primary. Supports arrow keys. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary; reduced motion snaps."}</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
|
+
/* 叶片页签:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/index.html(#leaf-tabs):保留 260px 透视 180° 翻转叶片与 7 柱 28ms 错拍弹簧数值,改为中文周期并接设计变量。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
19
|
+
.c-um-leaf-tabs{--lt-acc:var(--color-primary,#0a84ff);--lt-rail:color-mix(in srgb,var(--color-text,#141413) 11%,transparent);--lt-sp:cubic-bezier(.3,1.45,.5,1);display:grid;gap:14px;justify-items:center;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-um-leaf-tabs .lt-tabs{position:relative;display:grid;grid-template-columns:repeat(4,52px);padding:3px;border-radius:12px;background:var(--lt-rail);box-shadow:inset 0 0 0 .5px var(--color-line,rgba(0,0,0,.08));perspective:260px}
|
|
21
|
+
.c-um-leaf-tabs .lt-leaf{position:absolute;top:3px;left:3px;width:52px;height:34px;border-radius:9px;background:var(--color-surface,#fff);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),0 1px 2px rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.12);transform:translateX(calc(var(--lt-i,1) * 52px));backface-visibility:visible;pointer-events:none}
|
|
22
|
+
.c-um-leaf-tabs [role="tab"]{position:relative;height:34px;padding:0;border:0;border-radius:9px;background:none;color:var(--color-muted,#76756f);font:560 13px/1 var(--font-sans,system-ui);cursor:pointer;transition:color .25s .08s,transform .12s}
|
|
23
|
+
.c-um-leaf-tabs [role="tab"]:active{transform:scale(.93)}
|
|
24
|
+
.c-um-leaf-tabs [role="tab"][aria-selected="true"]{color:var(--color-text,#141413);font-weight:650}
|
|
25
|
+
.c-um-leaf-tabs [role="tab"]:focus-visible{outline:2px solid var(--lt-acc);outline-offset:-2px}
|
|
26
|
+
.c-um-leaf-tabs .lt-bars{display:flex;align-items:flex-end;gap:8px;height:60px}
|
|
27
|
+
.c-um-leaf-tabs .lt-bars i{width:14px;height:var(--h,20px);border-radius:4px 4px 2px 2px;background:color-mix(in srgb,var(--lt-acc) var(--tone,45%),transparent);transition:height .55s var(--lt-sp),background .4s;transition-delay:calc(var(--i) * 28ms)}
|
|
28
|
+
@media (prefers-reduced-motion:reduce){.c-um-leaf-tabs *{transition-duration:0s!important;transition-delay:0s!important}}
|
|
29
|
+
</style>
|
|
30
|
+
</head>
|
|
31
|
+
<body>
|
|
32
|
+
<div class="stage-fit">
|
|
33
|
+
<div class="c-um-leaf-tabs" data-comp="um-leaf-tabs" data-idx="1">
|
|
34
|
+
<div class="lt-tabs" role="tablist" aria-label="周期趋势">
|
|
35
|
+
<span class="lt-leaf" style="--lt-i:1" aria-hidden="true"></span>
|
|
36
|
+
<button type="button" role="tab" data-i="0" aria-selected="false" tabindex="-1">日</button>
|
|
37
|
+
<button type="button" role="tab" data-i="1" aria-selected="true" tabindex="0">周</button>
|
|
38
|
+
<button type="button" role="tab" data-i="2" aria-selected="false" tabindex="-1">月</button>
|
|
39
|
+
<button type="button" role="tab" data-i="3" aria-selected="false" tabindex="-1">年</button>
|
|
40
|
+
</div>
|
|
41
|
+
<div class="lt-bars" role="tabpanel" aria-label="本周趋势"><i style="--i:0;--h:28px;--tone:50%"></i><i style="--i:1;--h:39px;--tone:58%"></i><i style="--i:2;--h:34px;--tone:54%"></i><i style="--i:3;--h:45px;--tone:62%"></i><i style="--i:4;--h:39px;--tone:58%"></i><i style="--i:5;--h:50px;--tone:100%"></i><i style="--i:6;--h:34px;--tone:54%"></i></div>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<script data-comp>
|
|
45
|
+
/* 叶片页签逻辑:切换周期驱动 3D 翻叶动画与 7 根柱状图错拍弹性更新 */
|
|
46
|
+
(() => {
|
|
47
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
48
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
49
|
+
const DATA = [[2,4,3,6,5,3,4],[5,7,6,8,7,9,6],[3,5,8,6,9,7,10],[4,6,5,7,8,9,10]]
|
|
50
|
+
const NAMES = ['当日趋势', '本周趋势', '本月趋势', '年度趋势']
|
|
51
|
+
document.querySelectorAll('.c-um-leaf-tabs').forEach((el) => {
|
|
52
|
+
const tabs = el.querySelector('.lt-tabs')
|
|
53
|
+
const leaf = el.querySelector('.lt-leaf')
|
|
54
|
+
const panel = el.querySelector('.lt-bars')
|
|
55
|
+
const btns = [...el.querySelectorAll('[role="tab"]')]
|
|
56
|
+
const bars = [...panel.children]
|
|
57
|
+
let idx = 1, flip = null
|
|
58
|
+
const paint = () => {
|
|
59
|
+
const s = DATA[idx], peak = Math.max(...s)
|
|
60
|
+
bars.forEach((b, i) => {
|
|
61
|
+
b.style.setProperty('--h', Math.round(s[i] / 10 * 56) + 'px')
|
|
62
|
+
b.style.setProperty('--tone', s[i] === peak ? '100%' : `${30 + s[i] * 4}%`)
|
|
63
|
+
})
|
|
64
|
+
panel.setAttribute('aria-label', NAMES[idx])
|
|
65
|
+
}
|
|
66
|
+
el.ltGo = (next, anim = true, focus = false) => {
|
|
67
|
+
next = ((next % btns.length) + btns.length) % btns.length
|
|
68
|
+
const prev = idx
|
|
69
|
+
btns.forEach((b, i) => { b.setAttribute('aria-selected', String(i === next)); b.tabIndex = i === next ? 0 : -1 })
|
|
70
|
+
if (focus) btns[next].focus()
|
|
71
|
+
idx = next; el.dataset.idx = String(next)
|
|
72
|
+
leaf.style.setProperty('--lt-i', next)
|
|
73
|
+
flip?.cancel()
|
|
74
|
+
if (anim && prev !== next && ok()) {
|
|
75
|
+
const w = btns[0].offsetWidth || 52, from = prev * w, to = next * w, turn = next > prev ? -180 : 180
|
|
76
|
+
flip = leaf.animate([
|
|
77
|
+
{ transform: `translateX(${from}px) rotateY(0deg)`, filter: 'brightness(1)' },
|
|
78
|
+
{ transform: `translateX(${(from + to) / 2}px) translateZ(14px) rotateY(${turn / 2}deg) scaleY(1.08)`, filter: 'brightness(.82)', offset: .5 },
|
|
79
|
+
{ transform: `translateX(${to}px) rotateY(${turn}deg)`, filter: 'brightness(1)' },
|
|
80
|
+
], { duration: 460, easing: 'cubic-bezier(.45,.05,.25,1)' })
|
|
81
|
+
}
|
|
82
|
+
paint()
|
|
83
|
+
}
|
|
84
|
+
el.ltStop = () => { flip?.cancel() }
|
|
85
|
+
tabs.addEventListener('click', (e) => {
|
|
86
|
+
const b = e.target.closest('[role="tab"]')
|
|
87
|
+
if (b) el.ltGo(btns.indexOf(b), true)
|
|
88
|
+
})
|
|
89
|
+
tabs.addEventListener('keydown', (e) => {
|
|
90
|
+
const next = { ArrowRight: idx + 1, ArrowLeft: idx - 1, Home: 0, End: btns.length - 1 }[e.key]
|
|
91
|
+
if (next === undefined) return
|
|
92
|
+
e.preventDefault()
|
|
93
|
+
el.ltGo(next, true, true)
|
|
94
|
+
})
|
|
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
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
107
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
108
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
109
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
110
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
111
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
112
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
113
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
114
|
+
// ===== 只改这一段 =====
|
|
115
|
+
const DEMO = {
|
|
116
|
+
settle () { el.ltGo(1, false) },
|
|
117
|
+
loop (later) {
|
|
118
|
+
later(() => el.ltGo(3, true), 700)
|
|
119
|
+
later(() => el.ltGo(0, true), 2300)
|
|
120
|
+
later(() => el.ltGo(1, true), 3900)
|
|
121
|
+
later(() => DEMO.loop(later), 4700)
|
|
122
|
+
},
|
|
123
|
+
stop () { el.ltStop() },
|
|
124
|
+
}
|
|
125
|
+
// =====================
|
|
126
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
127
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
128
|
+
addEventListener('message', (e) => {
|
|
129
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
130
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
131
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
132
|
+
})
|
|
133
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
134
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
135
|
+
})()
|
|
136
|
+
</script>
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
|
@@ -0,0 +1,110 @@
|
|
|
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":"um-plan","zh":"套餐单选","en":"Plan Picker","cat":"input","desc":"三档套餐并排展示,切换时高亮边框带微扁挤压弹簧滑移并带着右上对勾落位","desc_en":"Three plan cards with a shared selection ring that squashes slightly and springs to the chosen tier","needs":"js","play":"press","hint":"点卡片切换","hint_en":"Pick a plan","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/inputs.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"套餐单选卡片:宽 256px 三列等宽卡片(高 86px、间距 8px、圆角 14px,--color-surface 底面),展示「基础版 免费」「专业版 ¥28/月」「团队版 ¥88/月」。未选卡悬停上浮 2px,公用 2px --color-primary 边框环右上角带 20px 圆形对勾角标;切换单选项时边框环以 500ms 弹簧滑到目标格,并叠加中途微微拉扁(scale 1.08, 0.94)的挤压回弹。多实例各自独立分组。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary,减少动效直接切位。","prompt_en":"Plan picker: 256px three-column grid (86px tall, 8px gap, 14px radius --color-surface cards) for Basic, Pro, and Team tiers. Unselected cards lift 2px on hover; a shared 2px --color-primary ring with a 20px check badge slides across with a 500ms spring and mid-flight squash (scale 1.08, .94). Multiple instances isolate radio groups automatically. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary; reduced motion snaps."}</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
|
+
/* 套餐单选:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/inputs.html(#plan-picker):保留三列 86px 卡片、公用高亮框 500ms 弹簧滑移与 1.08×0.94 挤压回弹,改中文虚构档位并支持同页多实例。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
19
|
+
.c-um-plan{--pl-acc:var(--color-primary,#0a84ff);--pl-sp:cubic-bezier(.3,1.45,.5,1);--pl-ea:cubic-bezier(.16,1,.3,1);--pl-gap:8px;--pl-i:1;position:relative;box-sizing:border-box;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--pl-gap);width:256px;margin:0;padding:0;border:0;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-um-plan label{position:relative;display:grid;align-content:center;gap:3px;height:86px;padding:0 10px;box-sizing:border-box;border:1px solid var(--color-line,rgba(0,0,0,.09));border-radius:14px;background:var(--color-surface,#fff);box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 2px 6px rgba(0,0,0,.05);cursor:pointer;transition:translate .3s var(--pl-sp),scale .12s}
|
|
21
|
+
.c-um-plan label:hover:not(:has(input:checked)){translate:0 -2px}
|
|
22
|
+
.c-um-plan label:active{scale:.97}
|
|
23
|
+
.c-um-plan input{position:absolute;opacity:0;pointer-events:none}
|
|
24
|
+
.c-um-plan b{font-size:13.5px;font-weight:650;line-height:1.25}
|
|
25
|
+
.c-um-plan small{font-size:12px;color:var(--color-muted,#76756f);font-variant-numeric:tabular-nums;transition:color .25s}
|
|
26
|
+
.c-um-plan input:checked~small{color:var(--pl-acc);font-weight:600}
|
|
27
|
+
.c-um-plan input:focus-visible~b{text-decoration:underline;text-underline-offset:3px}
|
|
28
|
+
.c-um-plan .pl-ring{position:absolute;top:0;left:0;box-sizing:border-box;width:calc((100% - 2 * var(--pl-gap)) / 3);height:100%;border:2px solid var(--pl-acc);border-radius:14px;pointer-events:none;z-index:1;translate:calc(var(--pl-i,1) * (100% + var(--pl-gap))) 0;transition:translate .5s var(--pl-sp)}
|
|
29
|
+
.c-um-plan .pl-ring::after{content:"✓";position:absolute;top:-8px;right:-8px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;background:var(--pl-acc);color:#fff;font-size:12px;font-weight:700;box-shadow:0 2px 6px color-mix(in srgb,var(--pl-acc) 45%,rgba(0,0,0,.2))}
|
|
30
|
+
.c-um-plan .pl-ring[data-move]{animation:um-plan-squash .5s var(--pl-ea)}
|
|
31
|
+
@keyframes um-plan-squash{40%{scale:1.08 .94}}
|
|
32
|
+
@media (prefers-reduced-motion:reduce){.c-um-plan *{animation:none!important;transition-duration:0s!important}}
|
|
33
|
+
</style>
|
|
34
|
+
</head>
|
|
35
|
+
<body>
|
|
36
|
+
<div class="stage-fit">
|
|
37
|
+
<fieldset class="c-um-plan" data-comp="um-plan" style="--pl-i:1">
|
|
38
|
+
<span class="pl-ring" aria-hidden="true"></span>
|
|
39
|
+
<label><input type="radio" name="um-plan" value="basic"><b>基础版</b><small>免费</small></label>
|
|
40
|
+
<label><input type="radio" name="um-plan" value="pro" checked><b>专业版</b><small>¥28/月</small></label>
|
|
41
|
+
<label><input type="radio" name="um-plan" value="team"><b>团队版</b><small>¥88/月</small></label>
|
|
42
|
+
</fieldset>
|
|
43
|
+
</div>
|
|
44
|
+
<script data-comp>
|
|
45
|
+
/* 套餐单选逻辑:隔离每实例单选组,切换时滑移高亮框并触发 1.08×0.94 挤压动画 */
|
|
46
|
+
(() => {
|
|
47
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
48
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
49
|
+
document.querySelectorAll('.c-um-plan').forEach((el, gid) => {
|
|
50
|
+
const ring = el.querySelector('.pl-ring')
|
|
51
|
+
const labels = [...el.querySelectorAll('label')]
|
|
52
|
+
const inputs = labels.map((l) => l.querySelector('input'))
|
|
53
|
+
inputs.forEach((inp) => { inp.name = 'um-plan-' + gid })
|
|
54
|
+
const place = (anim) => {
|
|
55
|
+
const idx = Math.max(0, inputs.findIndex((i) => i.checked))
|
|
56
|
+
el.style.setProperty('--pl-i', idx); el.dataset.idx = String(idx)
|
|
57
|
+
if (!anim || !ok()) return
|
|
58
|
+
ring.removeAttribute('data-move'); void ring.offsetWidth; ring.dataset.move = ''
|
|
59
|
+
}
|
|
60
|
+
el.plGo = (idx, anim = true) => {
|
|
61
|
+
inputs[idx].checked = true
|
|
62
|
+
place(anim)
|
|
63
|
+
}
|
|
64
|
+
el.addEventListener('change', () => place(true))
|
|
65
|
+
ring.style.transition = 'none'; place(false)
|
|
66
|
+
requestAnimationFrame(() => requestAnimationFrame(() => { ring.style.transition = '' }))
|
|
67
|
+
})
|
|
68
|
+
})()
|
|
69
|
+
</script>
|
|
70
|
+
<script data-stage>
|
|
71
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
72
|
+
(() => {
|
|
73
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
74
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
75
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
76
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
77
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
78
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
79
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
80
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
81
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
82
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
83
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
84
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
85
|
+
// ===== 只改这一段 =====
|
|
86
|
+
const DEMO = {
|
|
87
|
+
settle () { el.plGo(1, false) },
|
|
88
|
+
loop (later) {
|
|
89
|
+
el.plGo(1, false)
|
|
90
|
+
later(() => el.plGo(2, true), 1000)
|
|
91
|
+
later(() => el.plGo(0, true), 2400)
|
|
92
|
+
later(() => el.plGo(1, true), 3800)
|
|
93
|
+
later(() => DEMO.loop(later), 4800)
|
|
94
|
+
},
|
|
95
|
+
stop () {},
|
|
96
|
+
}
|
|
97
|
+
// =====================
|
|
98
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
99
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
100
|
+
addEventListener('message', (e) => {
|
|
101
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
102
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
103
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
104
|
+
})
|
|
105
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
106
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
107
|
+
})()
|
|
108
|
+
</script>
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|
|
@@ -0,0 +1,104 @@
|
|
|
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":"um-radial","zh":"扇形菜单","en":"Radial Menu","cat":"nav","desc":"点开底部加号,四枚圆形动作按钮沿扇形圆弧错拍弹出,再点或按 Esc 收拢","desc_en":"Tapping the plus button fans four round action buttons out along an arc with staggered spring timing","needs":"js","play":"press","hint":"点加号展开","hint_en":"Tap to fan out","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/gestures.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"扇形菜单:184×136 容器底部居中 52×52 主色圆形主按钮,内置加号图标展开时旋转 45°(400ms 弹簧)。四枚 40×40 的 --color-surface 圆形动作按钮(喜欢、收藏、分享、删除)沿 200° 起步、间隔 46.7°、半径 66px 的圆弧排列;展开按 45ms 顺序错拍弹放(450ms 弹簧),收拢按 30ms 倒序缩回原点,点击任一动作项或按 Esc 自动收起。颜色读 --color-surface / --color-text / --color-line / --color-primary,减少动效直接切位。","prompt_en":"Radial menu: 184x136 area with a 52x52 --color-primary FAB whose plus rotates 45 deg on open (400ms spring). Four 40x40 --color-surface round buttons (like, save, share, delete) fan out along a 66px arc from 200 deg at 46.7 deg intervals with 45ms stagger (450ms spring) and fold back in reverse with 30ms stagger; clicking an item or pressing Escape closes it. Reads --color-surface / --color-text / --color-line / --color-primary; reduced motion snaps."}</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
|
+
/* 扇形菜单:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/gestures.html(#radial-menu):保留 52px 主钮、40px 子钮、200°+46.7° 半径 66px 弧线与 45ms/30ms 错拍弹簧,微调弧高防贴边并接设计变量。
|
|
18
|
+
读 --color-surface / --color-text / --color-line / --color-primary */
|
|
19
|
+
.c-um-radial{--rd-acc:var(--color-primary,#0a84ff);--rd-sp:cubic-bezier(.3,1.45,.5,1);position:relative;display:grid;place-items:center;width:184px;height:136px;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-um-radial .rd-main{position:absolute;bottom:14px;display:grid;place-items:center;width:52px;height:52px;padding:0;border:0;border-radius:50%;background:var(--rd-acc);color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.32),0 4px 12px -2px color-mix(in srgb,var(--rd-acc) 55%,rgba(0,0,0,.25));z-index:2;cursor:pointer;transition:scale .2s var(--rd-sp)}
|
|
21
|
+
.c-um-radial .rd-main:active{scale:.92}
|
|
22
|
+
.c-um-radial .rd-main:focus-visible{outline:2px solid var(--rd-acc);outline-offset:4px}
|
|
23
|
+
.c-um-radial .rd-main svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;transition:rotate .4s var(--rd-sp)}
|
|
24
|
+
.c-um-radial .rd-main[aria-expanded="true"] svg{rotate:45deg}
|
|
25
|
+
.c-um-radial .rd-items button{position:absolute;bottom:20px;left:calc(50% - 20px);display:grid;place-items:center;width:40px;height:40px;padding:0;border:1px solid var(--color-line,rgba(0,0,0,.09));border-radius:50%;background:var(--color-surface,#fff);color:var(--color-text,#141413);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),0 1px 2px rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.12);transform:translate(0,0) scale(.2);opacity:0;cursor:pointer;transition:transform .45s var(--rd-sp) calc((3 - var(--n)) * 30ms),opacity .2s,color .2s,border-color .2s}
|
|
26
|
+
.c-um-radial .rd-items[data-open] button{transform:translate(var(--dx),var(--dy)) scale(1);opacity:1;transition-delay:calc(var(--n) * 45ms)}
|
|
27
|
+
.c-um-radial .rd-items button:hover{color:var(--rd-acc);border-color:color-mix(in srgb,var(--rd-acc) 40%,transparent)}
|
|
28
|
+
.c-um-radial .rd-items button:active{transform:translate(var(--dx),var(--dy)) scale(.9)}
|
|
29
|
+
.c-um-radial .rd-items button:focus-visible{outline:2px solid var(--rd-acc);outline-offset:3px}
|
|
30
|
+
.c-um-radial .rd-items svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linejoin:round;stroke-linecap:round}
|
|
31
|
+
@media (prefers-reduced-motion:reduce){.c-um-radial *{transition-duration:0s!important;transition-delay:0s!important}}
|
|
32
|
+
</style>
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<div class="stage-fit">
|
|
36
|
+
<div class="c-um-radial" data-comp="um-radial" data-open="1">
|
|
37
|
+
<div class="rd-items" data-open>
|
|
38
|
+
<button type="button" aria-label="喜欢" style="--n:0;--dx:-62.0px;--dy:-12.6px"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 16.5s-6-3.7-6-8.2A3.4 3.4 0 0 1 10 6a3.4 3.4 0 0 1 6 2.3c0 4.5-6 8.2-6 8.2Z"/></svg></button>
|
|
39
|
+
<button type="button" aria-label="收藏" style="--n:1;--dx:-26.1px;--dy:-50.6px"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M5.5 3.5h9v13l-4.5-3-4.5 3z"/></svg></button>
|
|
40
|
+
<button type="button" aria-label="分享" style="--n:2;--dx:26.2px;--dy:-50.6px"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 12.5V3.5m0 0-3.5 3.5M10 3.5l3.5 3.5M4.5 10.5v5h11v-5"/></svg></button>
|
|
41
|
+
<button type="button" aria-label="删除" style="--n:3;--dx:62.1px;--dy:-12.5px"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4.5 6h11M8 6V4h4v2M6 6l.7 10h6.6L14 6"/></svg></button>
|
|
42
|
+
</div>
|
|
43
|
+
<button class="rd-main" type="button" aria-expanded="true" aria-label="扇形菜单"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 4v12M4 10h12"/></svg></button>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<script data-comp>
|
|
47
|
+
/* 扇形菜单逻辑:点主按钮展开或收拢扇形弧面,点子项或按 Esc 收起 */
|
|
48
|
+
(() => {
|
|
49
|
+
document.querySelectorAll('.c-um-radial').forEach((el) => {
|
|
50
|
+
const main = el.querySelector('.rd-main')
|
|
51
|
+
const group = el.querySelector('.rd-items')
|
|
52
|
+
const btns = [...group.querySelectorAll('button')]
|
|
53
|
+
el.rdSet = (open, focus = false) => {
|
|
54
|
+
main.setAttribute('aria-expanded', String(open))
|
|
55
|
+
group.toggleAttribute('data-open', open)
|
|
56
|
+
el.dataset.open = open ? '1' : '0'
|
|
57
|
+
group.inert = !open
|
|
58
|
+
if (focus) (open ? btns[0] : main).focus({ preventScroll: true })
|
|
59
|
+
}
|
|
60
|
+
btns.forEach((b) => b.addEventListener('click', () => el.rdSet(false, true)))
|
|
61
|
+
main.addEventListener('click', () => el.rdSet(main.getAttribute('aria-expanded') !== 'true', false))
|
|
62
|
+
el.addEventListener('keydown', (e) => { if (e.key === 'Escape' && el.dataset.open === '1') el.rdSet(false, true) })
|
|
63
|
+
})
|
|
64
|
+
})()
|
|
65
|
+
</script>
|
|
66
|
+
<script data-stage>
|
|
67
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
68
|
+
(() => {
|
|
69
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
70
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
71
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
72
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
73
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
74
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
75
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
76
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
77
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
78
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
79
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
80
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
81
|
+
// ===== 只改这一段 =====
|
|
82
|
+
const DEMO = {
|
|
83
|
+
settle () { el.rdSet(true) },
|
|
84
|
+
loop (later) {
|
|
85
|
+
later(() => el.rdSet(false), 900)
|
|
86
|
+
later(() => el.rdSet(true), 2300)
|
|
87
|
+
later(() => DEMO.loop(later), 3800)
|
|
88
|
+
},
|
|
89
|
+
stop () {},
|
|
90
|
+
}
|
|
91
|
+
// =====================
|
|
92
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
93
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
94
|
+
addEventListener('message', (e) => {
|
|
95
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
96
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
97
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
98
|
+
})
|
|
99
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
100
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
101
|
+
})()
|
|
102
|
+
</script>
|
|
103
|
+
</body>
|
|
104
|
+
</html>
|
|
@@ -0,0 +1,86 @@
|
|
|
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":"um-stroke-check","zh":"划线清单","en":"Stroke Checklist","cat":"input","desc":"勾选待办时方框弹跳填满并一笔画出对勾,文字随之从左到右划出删除线","desc_en":"Checking an item pops the box, draws a tick stroke, and sweeps a strikethrough left to right","needs":"css","play":"press","hint":"勾选任务","hint_en":"Check an item","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/inputs.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"划线清单:纯 CSS(原生 checkbox + :checked)三行待办卡片,宽 216px、圆角 16px、--color-surface 底面配发丝边。每行左侧 20×20 圆角 6px 复选框,勾选时弹跳(scale 0.7 到 1.15 回 1,400ms)填满 --color-primary,内部白色对勾沿路径描出(300ms、延迟 50ms);右侧文字变 --color-muted 并从左向右拉出 1.6px 删除线(380ms、延迟 120ms)。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary,减少动效直接切态。","prompt_en":"Stroke checklist: pure CSS (native checkbox + :checked) three-item list in a 216px --color-surface card (16px radius). Checking pops the 20x20 box (scale .7 to 1.15 to 1, 400ms) in --color-primary, strokes a white checkmark (300ms, 50ms delay), dims the label to --color-muted, and sweeps a 1.6px strikethrough left to right (380ms, 120ms delay). Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary; reduced motion snaps."}</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
|
+
/* 划线清单:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/inputs.html(#stroke-checklist):纯 CSS 复选框弹跳、对勾路径描边与从左到右删除线,改中文任务并配卡片底面与设计变量。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
19
|
+
.c-um-stroke-check{--sc-acc:var(--color-primary,#0a84ff);--sc-sp:cubic-bezier(.3,1.45,.5,1);--sc-ea:cubic-bezier(.16,1,.3,1);box-sizing:border-box;display:grid;gap:2px;width:216px;margin:0;padding:8px;border:0;border-radius:16px;background:var(--color-surface,#fff);box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),0 1px 2px rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.12);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-um-stroke-check label{position:relative;display:flex;align-items:center;gap:11px;padding:8px 10px;border-radius:10px;cursor:pointer;transition:background-color .2s}
|
|
21
|
+
.c-um-stroke-check label:hover{background:color-mix(in srgb,var(--sc-acc) 8%,transparent)}
|
|
22
|
+
.c-um-stroke-check input{position:absolute;opacity:0;pointer-events:none}
|
|
23
|
+
.c-um-stroke-check .sc-box{display:grid;place-items:center;flex:none;width:20px;height:20px;box-sizing:border-box;border:1.6px solid var(--color-muted,#76756f);border-radius:6px;transition:background-color .25s,border-color .25s,transform .12s}
|
|
24
|
+
.c-um-stroke-check label:active .sc-box{transform:scale(.88)}
|
|
25
|
+
.c-um-stroke-check .sc-box svg{width:14px;height:14px;fill:none;stroke:#fff;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round;stroke-dasharray:18;stroke-dashoffset:18;transition:stroke-dashoffset .3s var(--sc-ea) .05s}
|
|
26
|
+
.c-um-stroke-check .sc-txt{position:relative;font-size:14px;line-height:1.35;transition:color .3s}
|
|
27
|
+
.c-um-stroke-check .sc-txt::after{content:"";position:absolute;left:-2px;right:-2px;top:52%;height:1.6px;border-radius:2px;background:currentColor;transform:scaleX(0);transform-origin:left;transition:transform .38s var(--sc-ea) .12s}
|
|
28
|
+
.c-um-stroke-check input:checked+.sc-box{background:var(--sc-acc);border-color:var(--sc-acc);animation:um-stroke-check-pop .4s var(--sc-sp)}
|
|
29
|
+
.c-um-stroke-check input:checked+.sc-box svg{stroke-dashoffset:0}
|
|
30
|
+
.c-um-stroke-check input:checked~.sc-txt{color:var(--color-muted,#76756f)}
|
|
31
|
+
.c-um-stroke-check input:checked~.sc-txt::after{transform:scaleX(1)}
|
|
32
|
+
.c-um-stroke-check input:focus-visible+.sc-box{outline:2px solid var(--sc-acc);outline-offset:3px}
|
|
33
|
+
@keyframes um-stroke-check-pop{0%{scale:.7}60%{scale:1.15}100%{scale:1}}
|
|
34
|
+
@media (prefers-reduced-motion:reduce){.c-um-stroke-check *,.c-um-stroke-check *::after{animation:none!important;transition-duration:0s!important;transition-delay:0s!important}}
|
|
35
|
+
</style>
|
|
36
|
+
</head>
|
|
37
|
+
<body>
|
|
38
|
+
<div class="stage-fit">
|
|
39
|
+
<div class="c-um-stroke-check" data-comp="um-stroke-check" role="group" aria-label="今日清单">
|
|
40
|
+
<label><input type="checkbox"><span class="sc-box"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg></span><span class="sc-txt">确认页面需求</span></label>
|
|
41
|
+
<label><input type="checkbox" checked><span class="sc-box"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg></span><span class="sc-txt">绘制交互线框</span></label>
|
|
42
|
+
<label><input type="checkbox"><span class="sc-box"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8.5l3 3 6-7"/></svg></span><span class="sc-txt">整理设计交付</span></label>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
<script data-stage>
|
|
46
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
47
|
+
(() => {
|
|
48
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
49
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
50
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
51
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
52
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
53
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
54
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
55
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
56
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
57
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
58
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
59
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
60
|
+
// ===== 只改这一段 =====
|
|
61
|
+
const boxes = [...el.querySelectorAll('input')]
|
|
62
|
+
const DEMO = {
|
|
63
|
+
settle () { boxes.forEach((b, i) => { b.checked = i === 1 }) },
|
|
64
|
+
loop (later) {
|
|
65
|
+
DEMO.settle()
|
|
66
|
+
later(() => { boxes[0].checked = true }, 700)
|
|
67
|
+
later(() => { boxes[2].checked = true }, 1900)
|
|
68
|
+
later(() => { boxes[0].checked = false; boxes[2].checked = false }, 3300)
|
|
69
|
+
later(() => DEMO.loop(later), 4200)
|
|
70
|
+
},
|
|
71
|
+
stop () {},
|
|
72
|
+
}
|
|
73
|
+
// =====================
|
|
74
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
75
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
76
|
+
addEventListener('message', (e) => {
|
|
77
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
78
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
79
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
80
|
+
})
|
|
81
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
82
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
83
|
+
})()
|
|
84
|
+
</script>
|
|
85
|
+
</body>
|
|
86
|
+
</html>
|