dsh-design-studio 2.0.1 → 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.
Files changed (129) hide show
  1. package/README.en.md +2 -1
  2. package/README.md +2 -1
  3. package/THIRD_PARTY_NOTICES.md +319 -0
  4. package/assets/motion/ai-capsule.html +4 -2
  5. package/assets/motion/ai-glow-input.html +4 -2
  6. package/assets/motion/app-fab.html +130 -0
  7. package/assets/motion/app-gallery.html +125 -0
  8. package/assets/motion/app-index.html +138 -0
  9. package/assets/motion/app-largetitle.html +138 -0
  10. package/assets/motion/app-onboard.html +141 -0
  11. package/assets/motion/app-player.html +152 -0
  12. package/assets/motion/app-popover.html +133 -0
  13. package/assets/motion/app-rings.html +143 -0
  14. package/assets/motion/app-searchhist.html +131 -0
  15. package/assets/motion/app-tabbar.html +148 -0
  16. package/assets/motion/app-tabs.html +150 -0
  17. package/assets/motion/app-video.html +136 -0
  18. package/assets/motion/balance-odometer.html +4 -2
  19. package/assets/motion/bottom-sheet.html +4 -2
  20. package/assets/motion/brightness-pill.html +4 -2
  21. package/assets/motion/chart-area.html +111 -0
  22. package/assets/motion/chart-bar.html +100 -0
  23. package/assets/motion/chart-donut.html +145 -0
  24. package/assets/motion/chart-funnel.html +120 -0
  25. package/assets/motion/chart-gantt.html +140 -0
  26. package/assets/motion/chart-gauge.html +126 -0
  27. package/assets/motion/chart-heat.html +121 -0
  28. package/assets/motion/chart-kpi.html +110 -0
  29. package/assets/motion/chart-line.html +154 -0
  30. package/assets/motion/chart-radar.html +153 -0
  31. package/assets/motion/chart-rank.html +112 -0
  32. package/assets/motion/chart-stack.html +107 -0
  33. package/assets/motion/comet-ring.html +4 -2
  34. package/assets/motion/copy-morph.html +4 -2
  35. package/assets/motion/cube-grid.html +4 -2
  36. package/assets/motion/day-night.html +4 -2
  37. package/assets/motion/dial-knob.html +4 -2
  38. package/assets/motion/dock-magnify.html +4 -2
  39. package/assets/motion/download-ring.html +4 -2
  40. package/assets/motion/expand-card.html +4 -2
  41. package/assets/motion/flip-card.html +4 -2
  42. package/assets/motion/hold-pay.html +4 -2
  43. package/assets/motion/holo-card.html +4 -2
  44. package/assets/motion/keycap.html +4 -2
  45. package/assets/motion/like-jelly.html +4 -2
  46. package/assets/motion/liquid-progress.html +4 -2
  47. package/assets/motion/liquid-segment.html +4 -2
  48. package/assets/motion/live-capsule.html +4 -2
  49. package/assets/motion/m-actionsheet.html +84 -0
  50. package/assets/motion/m-address.html +113 -0
  51. package/assets/motion/m-buybar.html +122 -0
  52. package/assets/motion/m-calendar.html +135 -0
  53. package/assets/motion/m-capsule-nav.html +97 -0
  54. package/assets/motion/m-cart.html +162 -0
  55. package/assets/motion/m-category.html +154 -0
  56. package/assets/motion/m-chat.html +125 -0
  57. package/assets/motion/m-coupon.html +84 -0
  58. package/assets/motion/m-dialog.html +102 -0
  59. package/assets/motion/m-empty.html +121 -0
  60. package/assets/motion/m-filter.html +171 -0
  61. package/assets/motion/m-goods.html +151 -0
  62. package/assets/motion/m-grid.html +98 -0
  63. package/assets/motion/m-login.html +127 -0
  64. package/assets/motion/m-msglist.html +88 -0
  65. package/assets/motion/m-order.html +111 -0
  66. package/assets/motion/m-profile.html +110 -0
  67. package/assets/motion/m-pull.html +199 -0
  68. package/assets/motion/m-settings.html +81 -0
  69. package/assets/motion/m-sku.html +114 -0
  70. package/assets/motion/m-swiper.html +163 -0
  71. package/assets/motion/m-timeline.html +109 -0
  72. package/assets/motion/m-wheel.html +182 -0
  73. package/assets/motion/marker-highlight.html +4 -2
  74. package/assets/motion/marquee-logos.html +4 -2
  75. package/assets/motion/mp-cartbar.html +158 -0
  76. package/assets/motion/mp-checkin.html +121 -0
  77. package/assets/motion/mp-form.html +128 -0
  78. package/assets/motion/mp-group.html +148 -0
  79. package/assets/motion/mp-invite.html +119 -0
  80. package/assets/motion/mp-points.html +143 -0
  81. package/assets/motion/mp-queue.html +136 -0
  82. package/assets/motion/mp-rate.html +166 -0
  83. package/assets/motion/mp-seckill.html +140 -0
  84. package/assets/motion/mp-store.html +137 -0
  85. package/assets/motion/mp-vip.html +126 -0
  86. package/assets/motion/mp-wizard.html +174 -0
  87. package/assets/motion/otp-code.html +7 -4
  88. package/assets/motion/password-eye.html +4 -2
  89. package/assets/motion/ruler-slider.html +4 -2
  90. package/assets/motion/search-expand.html +4 -2
  91. package/assets/motion/send-fly.html +4 -2
  92. package/assets/motion/skeleton-shine.html +4 -2
  93. package/assets/motion/star-rate.html +4 -2
  94. package/assets/motion/success-check.html +4 -2
  95. package/assets/motion/suggest-chips.html +4 -2
  96. package/assets/motion/swipe-row.html +4 -2
  97. package/assets/motion/tabbar-bounce.html +4 -2
  98. package/assets/motion/tactile-controls.html +4 -2
  99. package/assets/motion/text-scramble.html +4 -2
  100. package/assets/motion/toast-stack.html +4 -2
  101. package/assets/motion/token-stream.html +4 -2
  102. package/assets/motion/um-bell.html +106 -0
  103. package/assets/motion/um-chips.html +132 -0
  104. package/assets/motion/um-coin.html +119 -0
  105. package/assets/motion/um-hue.html +128 -0
  106. package/assets/motion/um-ink-switch.html +129 -0
  107. package/assets/motion/um-leaf-tabs.html +138 -0
  108. package/assets/motion/um-plan.html +110 -0
  109. package/assets/motion/um-radial.html +104 -0
  110. package/assets/motion/um-stroke-check.html +86 -0
  111. package/assets/motion/um-swipe-confirm.html +182 -0
  112. package/assets/motion/um-tide.html +180 -0
  113. package/assets/motion/voice-orb.html +4 -2
  114. package/assets/motion/web-404.html +95 -0
  115. package/assets/motion/web-cmdk.html +167 -0
  116. package/assets/motion/web-dropdown.html +94 -0
  117. package/assets/motion/web-faq.html +84 -0
  118. package/assets/motion/web-footer.html +109 -0
  119. package/assets/motion/web-hero.html +98 -0
  120. package/assets/motion/web-navbar.html +149 -0
  121. package/assets/motion/web-newsletter.html +124 -0
  122. package/assets/motion/web-pagination.html +132 -0
  123. package/assets/motion/web-pricing.html +110 -0
  124. package/assets/motion/web-testimonial.html +129 -0
  125. package/assets/motion/web-upload.html +160 -0
  126. package/lib/client.js +72 -14
  127. package/lib/index.js +6 -2
  128. package/lib/motion.js +11 -2
  129. package/package.json +1 -1
@@ -0,0 +1,182 @@
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-swipe-confirm","zh":"滑动确认","en":"Swipe Confirm","cat":"gesture","desc":"按住圆钮向右拖到底确认,临近终点带磁吸阻尼,中途松手弹簧弹回","desc_en":"Drag the knob to the end to confirm; magnetic resistance near the goal, spring return if released early","needs":"js","play":"drag","hint":"向右滑到底","hint_en":"Slide to end","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":"滑动确认条:224×52 圆角 26px 轨道配左侧 44×44 主色圆形拖钮,轨道中央提示「滑动确认」和三枚依次呼吸的右箭头。拖钮跟手右移并同步拉宽浅色底条,终点前 12px 施加磁吸与越界橡皮筋阻尼(上限 20px);拖过 88% 或快速轻甩即触发确认,拖钮变为 --color-success 并切出对勾,1.6 秒后弹簧复位;中途松手则按阻尼弹簧(480ms)弹回并提示「请滑到底」。颜色读 --color-text / --color-muted / --color-line / --color-primary / --color-success,减少动效直接切态。","prompt_en":"Swipe confirm: 224x52 track (26px radius), 44x44 --color-primary knob, three pulsing chevrons. Dragging fills the bar with magnetic pull over the last 12px and 20px rubber-band resistance. Passing 88% or a fast flick confirms in --color-success with a check and resets in 1.6s; early release springs back (480ms). Reads --color-text / --color-muted / --color-line / --color-primary / --color-success; 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(#swipe-confirm)与 interaction.mjs:保留 224×52 轨道、12px 终点磁吸、88% 阈值、橡皮筋与阻尼弹簧方程,改中文文案并接设计变量。
18
+ 读 --color-text / --color-muted / --color-line / --color-primary / --color-success */
19
+ .c-um-swipe-confirm{--sw-acc:var(--color-primary,#0a84ff);--sw-ok:var(--color-success,#30b35a);--sw-rail:color-mix(in srgb,var(--color-text,#141413) 11%,transparent);--sw-sp:cubic-bezier(.3,1.45,.5,1);--x:0;--progress:0;position:relative;box-sizing:border-box;width:224px;height:52px;border-radius:26px;background:var(--sw-rail);box-shadow:inset 0 1px 3px rgba(0,0,0,.08),0 0 0 .5px var(--color-line,rgba(0,0,0,.09));overflow:hidden;touch-action:none;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent}
20
+ .c-um-swipe-confirm::before{content:"";position:absolute;inset:0;border-radius:26px;background:color-mix(in srgb,var(--sw-acc) 16%,transparent);clip-path:inset(0 calc((1 - var(--progress,0)) * (100% - 52px)) 0 0 round 26px);transition:background-color .28s}
21
+ .c-um-swipe-confirm[data-done]::before{background:color-mix(in srgb,var(--sw-ok) 18%,transparent)}
22
+ .c-um-swipe-confirm .sw-hint{position:absolute;inset:0 0 0 56px;display:flex;align-items:center;justify-content:center;gap:3px;color:var(--color-muted,#76756f);opacity:clamp(0,calc(1 - var(--progress,0) * 1.6),1);pointer-events:none}
23
+ .c-um-swipe-confirm[data-done] .sw-hint{opacity:0}
24
+ .c-um-swipe-confirm .sw-hint span{margin-right:5px;font-size:12px;font-weight:570;white-space:nowrap}
25
+ .c-um-swipe-confirm .sw-hint i{width:7px;height:7px;border-right:1.8px solid currentColor;border-top:1.8px solid currentColor;rotate:45deg;animation:um-swipe-confirm-hint 1.6s ease-in-out calc(var(--n) * .16s) infinite}
26
+ .c-um-swipe-confirm[data-drag] .sw-hint i{animation:none;opacity:clamp(.2,calc(.35 + var(--progress,0) * 2 - var(--n) * .38),1)}
27
+ .c-um-swipe-confirm .sw-done-txt{position:absolute;inset:0 52px 0 0;display:grid;place-items:center;font-size:12.5px;font-weight:600;color:var(--sw-ok);opacity:0;transform:translateX(-6px);transition:opacity .08s,transform .15s;pointer-events:none}
28
+ .c-um-swipe-confirm[data-done] .sw-done-txt{opacity:1;transform:none;transition:opacity .22s .06s,transform .3s var(--sw-sp) .04s}
29
+ .c-um-swipe-confirm .sw-knob{position:absolute;top:4px;left:4px;display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:50%;background:var(--sw-acc);color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.32),0 2px 6px rgba(0,0,0,.18);transform:translateX(calc(var(--x,0) * 1px));transition:scale .13s cubic-bezier(.2,.9,.34,1.16),background-color .28s;cursor:grab;touch-action:none}
30
+ .c-um-swipe-confirm[data-drag] .sw-knob{scale:.96;transition:scale 45ms cubic-bezier(.2,.8,.2,1);cursor:grabbing}
31
+ .c-um-swipe-confirm[data-done] .sw-knob{background:var(--sw-ok)}
32
+ .c-um-swipe-confirm .sw-knob:focus-visible{outline:2px solid #fff;outline-offset:-4px}
33
+ .c-um-swipe-confirm .sw-knob svg{grid-area:1/1;width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;transition:opacity .2s,scale .3s var(--sw-sp)}
34
+ .c-um-swipe-confirm .sw-knob .sw-ok{opacity:0;scale:.4}
35
+ .c-um-swipe-confirm[data-done] .sw-knob .sw-go{opacity:0;scale:.4}
36
+ .c-um-swipe-confirm[data-done] .sw-knob .sw-ok{opacity:1;scale:1}
37
+ @keyframes um-swipe-confirm-hint{0%,100%{opacity:.2}40%{opacity:1}}
38
+ @media (prefers-reduced-motion:reduce){.c-um-swipe-confirm *,.c-um-swipe-confirm::before{animation:none!important;transition-duration:0s!important}}
39
+ </style>
40
+ </head>
41
+ <body>
42
+ <div class="stage-fit">
43
+ <div class="c-um-swipe-confirm" data-comp="um-swipe-confirm" style="--x:0;--progress:0">
44
+ <span class="sw-hint" aria-hidden="true"><span class="sw-msg">滑动确认</span><i style="--n:0"></i><i style="--n:1"></i><i style="--n:2"></i></span>
45
+ <span class="sw-done-txt" aria-live="polite">已确认</span>
46
+ <button class="sw-knob" type="button" aria-label="向右滑动确认">
47
+ <svg class="sw-go" viewBox="0 0 20 20" aria-hidden="true"><path d="M4 10h12m-4-4 4 4-4 4"/></svg>
48
+ <svg class="sw-ok" viewBox="0 0 20 20" aria-hidden="true"><path d="M4.5 10.5l3.5 3.5 7.5-8"/></svg>
49
+ </button>
50
+ </div>
51
+ </div>
52
+ <script data-comp>
53
+ /* 滑动确认逻辑:橡皮筋拖拽 + 终点 12px 磁吸 + 阻尼弹簧(exp(-15t) cos/sin 13t)复位 */
54
+ (() => {
55
+ const rm = matchMedia('(prefers-reduced-motion: reduce)')
56
+ const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
57
+ const clamp = (v, a, b) => Math.min(b, Math.max(a, v))
58
+ const rubber = (v, a, b, lim = 20) => { const e = clamp(v, a, b), ex = (v - e) * .35; return e + ex / (1 + Math.abs(ex) / lim) }
59
+ document.querySelectorAll('.c-um-swipe-confirm').forEach((el) => {
60
+ const knob = el.querySelector('.sw-knob'), msg = el.querySelector('.sw-msg')
61
+ const max = () => (el.offsetWidth || 224) - 52
62
+ let x = 0, raf = 0, rstTimer = 0, hintTimer = 0, comp = null, drag = null
63
+ const paint = (nx) => {
64
+ x = nx
65
+ el.style.setProperty('--x', x.toFixed(2))
66
+ el.style.setProperty('--progress', clamp(x / max(), 0, 1).toFixed(3))
67
+ }
68
+ const stopSpr = () => { cancelAnimationFrame(raf); raf = 0 }
69
+ const to = (target, vx = 0) => {
70
+ stopSpr()
71
+ if (!ok()) return paint(target)
72
+ const from = x, t0 = performance.now(), sp = clamp(vx, -1100, 1100)
73
+ const tick = (now) => {
74
+ const t = Math.max(0, now - t0) / 1000
75
+ if (!ok() || t >= .48) return paint(target)
76
+ const d = from - target, dec = Math.exp(-15 * t)
77
+ paint(target + dec * (d * Math.cos(13 * t) + (sp + 15 * d) / 13 * Math.sin(13 * t)))
78
+ raf = requestAnimationFrame(tick)
79
+ }
80
+ raf = requestAnimationFrame(tick)
81
+ }
82
+ const confirm = () => {
83
+ clearTimeout(hintTimer); msg.textContent = '滑动确认'
84
+ to(max()); el.dataset.done = ''
85
+ if (ok()) comp = knob.animate([{ scale: '.96' }, { scale: '1.06' }, { scale: '1' }], { duration: 260, easing: 'cubic-bezier(.2,.9,.34,1.16)' })
86
+ clearTimeout(rstTimer)
87
+ rstTimer = setTimeout(() => { delete el.dataset.done; to(0) }, 1600)
88
+ }
89
+ el.swSet = (nx, done = false) => {
90
+ stopSpr(); clearTimeout(rstTimer); clearTimeout(hintTimer); comp?.cancel()
91
+ msg.textContent = '滑动确认'
92
+ el.toggleAttribute('data-done', done)
93
+ paint(done ? max() : clamp(nx, 0, max()))
94
+ }
95
+ el.swConfirm = confirm
96
+ el.swStop = () => { stopSpr(); clearTimeout(rstTimer); clearTimeout(hintTimer); comp?.cancel() }
97
+ knob.addEventListener('pointerdown', (e) => {
98
+ if (e.button !== 0 || el.hasAttribute('data-done')) return
99
+ stopSpr(); clearTimeout(hintTimer); msg.textContent = '滑动确认'
100
+ const sc = el.getBoundingClientRect().width / (el.offsetWidth || 224) || 1
101
+ drag = { sc, orig: e.clientX / sc - x, samples: [{ x: e.clientX, t: e.timeStamp }] }
102
+ el.dataset.drag = ''; knob.setPointerCapture(e.pointerId)
103
+ })
104
+ knob.addEventListener('pointermove', (e) => {
105
+ if (!drag) return
106
+ drag.samples.push({ x: e.clientX, t: e.timeStamp })
107
+ while (drag.samples.length > 2 && e.timeStamp - drag.samples[1].t >= 100) drag.samples.shift()
108
+ const ext = max(), raw = e.clientX / drag.sc - drag.orig, snap = ext - 12
109
+ paint(rubber(raw > snap && raw < ext ? snap + Math.sqrt((raw - snap) / 12) * 12 : raw, 0, ext, 20))
110
+ })
111
+ const end = (e) => {
112
+ if (!drag) return
113
+ const d = drag; drag = null; delete el.dataset.drag
114
+ const s0 = d.samples[0], s1 = d.samples.at(-1), dt = Math.max(.008, (s1.t - s0.t) / 1000)
115
+ const vx = ((s1.x - s0.x) / dt) / d.sc
116
+ const released = e.type === 'pointerup'
117
+ if (released && (x >= max() * .88 || (x > max() * .32 && vx > 450 && x + vx * .12 >= max()))) {
118
+ confirm()
119
+ } else {
120
+ if (released && x > 24) {
121
+ msg.textContent = '请滑到底'
122
+ clearTimeout(hintTimer); hintTimer = setTimeout(() => { msg.textContent = '滑动确认' }, 1800)
123
+ }
124
+ to(0, vx * .4)
125
+ }
126
+ }
127
+ knob.addEventListener('pointerup', end); knob.addEventListener('pointercancel', end)
128
+ knob.addEventListener('click', (e) => { if (e.detail === 0 && !el.hasAttribute('data-done')) confirm() })
129
+ paint(0)
130
+ })
131
+ })()
132
+ </script>
133
+ <script data-stage>
134
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
135
+ (() => {
136
+ const q = new URLSearchParams(location.search); const root = document.documentElement
137
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
138
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
139
+ const el = document.querySelector('.stage-fit > [data-comp]')
140
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
141
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
142
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
143
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
144
+ let playing = !q.has('still'); let hovering = false; let timers = []
145
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
146
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
147
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
148
+ // ===== 只改这一段 =====
149
+ let raf = 0
150
+ const slide = (ms, done) => {
151
+ const ext = (el.offsetWidth || 224) - 52, t0 = performance.now()
152
+ const step = (t) => {
153
+ const k = Math.min(1, (t - t0) / ms), ease = k * k * (3 - 2 * k)
154
+ el.swSet(ext * ease, false)
155
+ if (k < 1) raf = requestAnimationFrame(step)
156
+ else done()
157
+ }
158
+ raf = requestAnimationFrame(step)
159
+ }
160
+ const DEMO = {
161
+ settle () { cancelAnimationFrame(raf); el.swSet(0, false) },
162
+ loop (later) {
163
+ el.swSet(0, false)
164
+ later(() => slide(750, () => el.swConfirm()), 200)
165
+ later(() => DEMO.loop(later), 3900)
166
+ },
167
+ stop () { cancelAnimationFrame(raf); el.swStop(); el.swSet(0, false) },
168
+ }
169
+ // =====================
170
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
171
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
172
+ addEventListener('message', (e) => {
173
+ const d = e.data; if (!d || typeof d !== 'object') return
174
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
175
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
176
+ })
177
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
178
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
179
+ })()
180
+ </script>
181
+ </body>
182
+ </html>
@@ -0,0 +1,180 @@
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-tide","zh":"潮汐进度","en":"Tide Progress","cat":"loading","desc":"圆形水球随水位晃出前后两层潮汐波浪,点击注水带弹簧过冲,数字在水线处反白","desc_en":"Circular wave gauge sloshes with spring physics on tap, inverting the readout along the waterline","needs":"js","play":"press","hint":"点一下注水","hint_en":"Tap to fill","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":"潮汐进度球:116×116 圆形玻璃容器(--color-surface 底色、发丝边与层次阴影),内嵌画布以弹簧阻尼方程(刚度 46、阻尼 10.5)实时模拟前后双层正弦波浪与倾角晃动;前浪用 --color-primary 实色填充并裁切白色等宽百分比,后浪用半透明主色错位晃动,水面之上显示 --color-text 数字。每次点击加 25% 并加大波幅,满 100% 再点归零重注。颜色读 --color-surface / --color-text / --color-line / --color-primary,减少动效定格在 50% 静态水位。","prompt_en":"Tide progress: 116x116 circular --color-surface gauge with a canvas spring-damped wave model (stiffness 46, damping 10.5). Two offset sine waves tilt with velocity: a soft back wave and a --color-primary front wave clipping white digits while upper digits stay --color-text. Each tap adds 25% with extra slosh and empties past 100%. Reads --color-surface / --color-text / --color-line / --color-primary; reduced motion holds at 50%."}</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(#tide-progress):保留 116×116 圆形容器、刚度 46/阻尼 10.5 潮汐方程与水线反白裁切,去 Geist 字体并增静态无脚本回退与悬停静置。
18
+ 读 --color-surface / --color-text / --color-line / --color-primary */
19
+ .c-um-tide{--td-acc:var(--color-primary,#0a84ff);--td-sp:cubic-bezier(.3,1.45,.5,1);position:relative;box-sizing:border-box;width:116px;height:116px;padding:0;border:1px solid var(--color-line,rgba(0,0,0,.1));border-radius:50%;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);overflow:hidden;cursor:pointer;transition:scale .35s var(--td-sp);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
20
+ .c-um-tide:active{scale:.96;transition-duration:.12s}
21
+ .c-um-tide:focus-visible{outline:2px solid var(--td-acc);outline-offset:4px}
22
+ .c-um-tide canvas{position:relative;z-index:2;display:block;width:100%;height:100%}
23
+ .c-um-tide .td-fb{position:absolute;inset:0;z-index:1;pointer-events:none}
24
+ .c-um-tide.is-live .td-fb{display:none}
25
+ .c-um-tide .td-fb svg{position:absolute;inset:0;width:100%;height:100%;display:block}
26
+ .c-um-tide .td-num{position:absolute;inset:0;display:grid;place-items:center;font:650 23px/1 var(--font-sans,system-ui);font-variant-numeric:tabular-nums}
27
+ .c-um-tide .td-num.inv{color:#fff;clip-path:inset(51.5% 0 0 0)}
28
+ @media (prefers-reduced-motion:reduce){.c-um-tide{transition-duration:0s!important}}
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <div class="stage-fit">
33
+ <button class="c-um-tide" data-comp="um-tide" data-pct="50" type="button" aria-label="潮汐进度 50%">
34
+ <span class="td-fb" aria-hidden="true">
35
+ <svg viewBox="0 0 116 116"><path d="M0 57 Q29 53 58 57 T116 57 V116 H0Z" fill="var(--color-primary,#0a84ff)" opacity=".28"/><path d="M0 59 Q29 61 58 59 T116 59 V116 H0Z" fill="var(--color-primary,#0a84ff)"/></svg>
36
+ <span class="td-num">50%</span>
37
+ <span class="td-num inv">50%</span>
38
+ </span>
39
+ <canvas aria-hidden="true"></canvas>
40
+ </button>
41
+ </div>
42
+ <script data-comp>
43
+ /* 潮汐进度逻辑:画布双层波浪弹簧物理 + 点击每步加 25%;悬停或暂停时波浪平稳停住 */
44
+ (() => {
45
+ const rm = matchMedia('(prefers-reduced-motion: reduce)')
46
+ const clamp = (v, a, b) => Math.min(b, Math.max(a, v))
47
+ document.querySelectorAll('.c-um-tide').forEach((el) => {
48
+ const cv = el.querySelector('canvas'), ctx = cv.getContext('2d')
49
+ let target = .5, level = .5, vel = 0, slosh = .02, phase = 0
50
+ let col = null, raf = 0, last = 0, size = 114, dpr = 1, activeClick = false
51
+ const motion = () => !rm.matches && !document.documentElement.classList.contains('paused')
52
+ const readColors = () => {
53
+ const cs = getComputedStyle(el)
54
+ col = {
55
+ acc: cs.getPropertyValue('--color-primary').trim() || '#0a84ff',
56
+ ink: cs.getPropertyValue('--color-text').trim() || '#141413',
57
+ font: cs.fontFamily || 'system-ui,sans-serif',
58
+ }
59
+ }
60
+ const surface = (off, amp, tilt) => {
61
+ const base = size * (1 - level)
62
+ ctx.beginPath(); ctx.moveTo(0, size)
63
+ for (let x = 0; x <= size; x += 2) {
64
+ const t = x / size
65
+ ctx.lineTo(x, base + Math.sin(t * Math.PI * 2.2 + phase + off) * amp * size + (t - .5) * tilt * size)
66
+ }
67
+ ctx.lineTo(size, size); ctx.closePath()
68
+ }
69
+ const label = (c) => {
70
+ ctx.fillStyle = c
71
+ ctx.font = `650 ${Math.round(size * .2)}px ${col.font}`
72
+ ctx.textAlign = 'center'; ctx.textBaseline = 'middle'
73
+ ctx.fillText(Math.round(level * 100) + '%', size / 2, size / 2 + 1)
74
+ }
75
+ const draw = () => {
76
+ if (!size || !col) return
77
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
78
+ ctx.clearRect(0, 0, size, size)
79
+ const amp = level <= .002 || level >= .998 ? 0 : slosh
80
+ const tilt = clamp(vel * .5, -.25, .25)
81
+ surface(1.6, amp * .8, -tilt * .6)
82
+ ctx.save(); ctx.globalAlpha = .28; ctx.fillStyle = col.acc; ctx.fill(); ctx.restore()
83
+ label(col.ink)
84
+ ctx.save(); surface(0, amp, tilt); ctx.fillStyle = col.acc; ctx.fill(); ctx.clip(); label('#fff'); ctx.restore()
85
+ }
86
+ const resize = () => {
87
+ dpr = Math.min(devicePixelRatio || 1, 2)
88
+ size = el.clientWidth || 114
89
+ cv.width = Math.round(size * dpr); cv.height = Math.round(size * dpr)
90
+ draw()
91
+ }
92
+ const step = (now) => {
93
+ const dt = Math.min(.034, (now - last) / 1000 || .016); last = now
94
+ const acc = 46 * (target - level) - 10.5 * vel
95
+ vel += acc * dt; level = clamp(level + vel * dt, 0, 1)
96
+ slosh += (.016 + Math.min(.09, Math.abs(vel) * .22) - slosh) * Math.min(1, dt * 3.2)
97
+ phase += dt * (2.2 + Math.abs(vel) * 6)
98
+ draw()
99
+ if ((el.tdHold && !activeClick) || !motion()) { raf = 0; return }
100
+ if (el.tdHold && activeClick && Math.abs(target - level) < .002 && Math.abs(vel) < .005 && slosh < .024) {
101
+ level = target; vel = 0; slosh = .018; activeClick = false; draw(); raf = 0; return
102
+ }
103
+ raf = requestAnimationFrame(step)
104
+ }
105
+ const sync = () => {
106
+ cancelAnimationFrame(raf); raf = 0
107
+ if (motion() && !document.hidden && (!el.tdHold || activeClick)) {
108
+ last = performance.now(); raf = requestAnimationFrame(step)
109
+ } else {
110
+ level = target; vel = 0; slosh = .018; draw()
111
+ }
112
+ const p = Math.round(target * 100)
113
+ el.dataset.pct = String(p); el.setAttribute('aria-label', `潮汐进度 ${p}%`)
114
+ }
115
+ el.tdSet = (v, anim = true) => {
116
+ target = clamp(v, 0, 1)
117
+ if (!anim) { level = target; vel = 0; slosh = .018; activeClick = false }
118
+ else { slosh = Math.min(.1, slosh + .035) }
119
+ sync()
120
+ }
121
+ el.tdTap = () => {
122
+ const next = target >= .999 ? 0 : Math.min(1, Math.round((target + .25) * 4) / 4)
123
+ el.tdSet(next, true)
124
+ }
125
+ el.addEventListener('click', () => {
126
+ activeClick = true
127
+ el.tdTap()
128
+ })
129
+ el.classList.add('is-live')
130
+ readColors(); resize()
131
+ if (typeof ResizeObserver === 'function') new ResizeObserver(resize).observe(el)
132
+ new MutationObserver(() => { readColors(); sync() }).observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'class'] })
133
+ rm.addEventListener('change', sync)
134
+ document.addEventListener('visibilitychange', sync)
135
+ sync()
136
+ })
137
+ })()
138
+ </script>
139
+ <script data-stage>
140
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
141
+ (() => {
142
+ const q = new URLSearchParams(location.search); const root = document.documentElement
143
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
144
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
145
+ const el = document.querySelector('.stage-fit > [data-comp]')
146
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
147
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
148
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
149
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
150
+ let playing = !q.has('still'); let hovering = false; let timers = []
151
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
152
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
153
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
154
+ // ===== 只改这一段 =====
155
+ const DEMO = {
156
+ settle () { el.tdHold = true; el.tdSet(.5, false) },
157
+ loop (later) {
158
+ el.tdHold = false; el.tdSet(.5, true)
159
+ later(() => el.tdTap(), 900)
160
+ later(() => el.tdTap(), 2200)
161
+ later(() => el.tdTap(), 3500)
162
+ later(() => el.tdTap(), 4700)
163
+ later(() => DEMO.loop(later), 5900)
164
+ },
165
+ stop () { el.tdHold = true; el.tdSet(+(el.dataset.pct || 50) / 100, false) },
166
+ }
167
+ // =====================
168
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
169
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
170
+ addEventListener('message', (e) => {
171
+ const d = e.data; if (!d || typeof d !== 'object') return
172
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
173
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
174
+ })
175
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
176
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
177
+ })()
178
+ </script>
179
+ </body>
180
+ </html>
@@ -115,8 +115,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
115
115
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
116
116
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
117
117
  const el = document.querySelector('.stage-fit > [data-comp]')
118
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
119
- fit(); addEventListener('resize', fit)
118
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
119
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
120
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
121
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
120
122
  let playing = !q.has('still'); let hovering = false; let timers = []
121
123
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
122
124
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -0,0 +1,95 @@
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":"web-404","zh":"走丢页面","en":"404 Not Found","cat":"web","desc":"大号 404 中间嵌指南针圆环,点返回首页指针回正并切换带路态","desc_en":"Large 404 with a compass ring in the zero; tapping Go Home aligns the needle and confirms","needs":"css","play":"press","hint":"点返回首页","hint_en":"Tap go home","source":null,"prompt":"走丢 404 错误页卡片:宽 296px 高 166px 圆角 16px 的 --color-surface 卡片,居中排布。上方大号 404 字符,中间数字 0 做成内联 SVG 指南针表盘,默认指针偏转 -36 度;下方标题「这页去散步了」与一行浅灰提示,底部「返回首页」主色按钮配「刷新试试」次按钮。点返回首页后指针弹簧转回 0 度指北(0.65s),按钮切 --color-success「已带你回首页」。纯 CSS(checkbox),读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger / --color-success。","prompt_en":"404 not-found card, 296x166, 16px-radius --color-surface card centered layout. Bold 404 headline turns the middle zero into an inline SVG compass dial whose needle rests tilted -36deg; below sit a playful title, muted hint, filled Go Home button and outlined Retry button. Tapping Go Home springs the needle to 0deg north (0.65s) and morphs the button to --color-success Heading Home. Pure CSS checkbox reading --color-surface/text/muted/line/primary/danger/success."}</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。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger / --color-success */
18
+ .c-web-404{--nf-sp:linear(0,.07,.245,.475,.716,.931,1.1,1.212,1.267,1.272,1.239,1.184,1.118,1.054,.999,.958,.934,.925,.928,.94,.956,.975,.992,1.005,1.015,1.02,1.021,1.019,1.015,1.01,1.005,1.001,.997,.995,.994,.994,.995,.996,.998,.999,1);position:relative;box-sizing:border-box;width:296px;height:166px;padding:13px 18px 14px;border-radius:16px;overflow:hidden;display:grid;justify-items:center;align-content:center;gap:5px;text-align:center;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
19
+ .c-web-404 .nf-home{position:relative}
20
+ .c-web-404 input{position:absolute;opacity:0;pointer-events:none}
21
+ .c-web-404 .nf-code{display:flex;align-items:center;justify-content:center;gap:4px;font-size:42px;line-height:44px;font-weight:800;letter-spacing:-.04em;font-variant-numeric:tabular-nums;color:var(--color-text,#141413)}
22
+ .c-web-404 .nf-zero{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;background:color-mix(in srgb,var(--color-primary,#0a84ff) 11%,transparent);box-shadow:inset 0 0 0 2.5px var(--color-primary,#0a84ff);transition:background-color .3s,box-shadow .3s}
23
+ .c-web-404 .nf-zero svg{width:24px;height:24px;overflow:visible}
24
+ .c-web-404 .nf-needle{transform-origin:12px 12px;transform:rotate(-36deg);transition:transform .65s var(--nf-sp)}
25
+ .c-web-404:has(input:checked) .nf-code .nf-zero{background:color-mix(in srgb,var(--color-success,#30b35a) 13%,transparent);box-shadow:inset 0 0 0 2.5px var(--color-success,#30b35a)}
26
+ .c-web-404:has(input:checked) .nf-code .nf-needle{transform:rotate(0deg)}
27
+ .c-web-404 h2{margin:2px 0 0;font-size:14px;line-height:1.25;font-weight:700}
28
+ .c-web-404 p{margin:0;font-size:11px;line-height:1.4;color:var(--color-muted,#76756f)}
29
+ .c-web-404 .nf-acts{display:flex;align-items:center;gap:8px;margin-top:5px}
30
+ .c-web-404 .nf-home,.c-web-404 .nf-re{height:28px;padding:0 13px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;font-size:11.5px;font-weight:600;cursor:pointer;transition:transform .38s var(--nf-sp),background-color .25s,box-shadow .25s}
31
+ .c-web-404 .nf-home{min-width:96px;color:#fff;background:var(--color-primary,#0a84ff);box-shadow:0 5px 12px -5px color-mix(in srgb,var(--color-primary,#0a84ff) 70%,transparent)}
32
+ .c-web-404 .nf-home:active,.c-web-404.is-press .nf-home{transform:scale(.92);transition:transform .1s}
33
+ .c-web-404 .nf-home .nf-s2{display:none}
34
+ .c-web-404:has(input:checked) .nf-acts .nf-home{background:var(--color-success,#30b35a);box-shadow:0 5px 12px -5px color-mix(in srgb,var(--color-success,#30b35a) 70%,transparent)}
35
+ .c-web-404:has(input:checked) .nf-acts .nf-home .nf-s1{display:none}
36
+ .c-web-404:has(input:checked) .nf-acts .nf-home .nf-s2{display:inline}
37
+ .c-web-404:has(input:focus-visible) .nf-acts .nf-home{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
38
+ .c-web-404 .nf-re{color:var(--color-text,#141413);background:color-mix(in srgb,var(--color-text,#141413) 5%,transparent);box-shadow:inset 0 0 0 .5px var(--color-line,rgba(0,0,0,.14))}
39
+ .c-web-404 .nf-re:active{transform:scale(.94)}
40
+ @media (prefers-reduced-motion:reduce){.c-web-404 *{transition:none!important}}
41
+ </style>
42
+ </head>
43
+ <body>
44
+ <div class="stage-fit">
45
+ <div class="c-web-404" data-comp="web-404">
46
+ <span class="nf-code" aria-hidden="true"><span>4</span><span class="nf-zero"><svg viewBox="0 0 24 24"><g class="nf-needle"><polygon points="12,3.5 14.6,12 12,11 9.4,12" fill="var(--color-danger,#ff375f)"/><polygon points="12,20.5 9.4,12 12,13 14.6,12" fill="var(--color-muted,#76756f)" opacity=".55"/><circle cx="12" cy="12" r="1.6" fill="var(--color-surface,#fff)"/></g></svg></span><span>4</span></span>
47
+ <h2>这页去散步了</h2>
48
+ <p>链接可能已失效,先回首页逛逛吧</p>
49
+ <span class="nf-acts">
50
+ <label class="nf-home"><input type="checkbox" aria-label="返回首页"><span class="nf-s1">返回首页</span><span class="nf-s2">✓ 已带你回首页</span></label>
51
+ <span class="nf-re">刷新试试</span>
52
+ </span>
53
+ </div>
54
+ </div>
55
+ <script data-stage>
56
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
57
+ (() => {
58
+ const q = new URLSearchParams(location.search); const root = document.documentElement
59
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
60
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
61
+ const el = document.querySelector('.stage-fit > [data-comp]')
62
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
63
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
64
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
65
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
66
+ let playing = !q.has('still'); let hovering = false; let timers = []
67
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
68
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
69
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
70
+ // ===== 只改这一段 =====
71
+ const box = el.querySelector('input')
72
+ const tap = (later) => { el.classList.add('is-press'); later(() => { el.classList.remove('is-press'); box.checked = !box.checked }, 140) }
73
+ const DEMO = {
74
+ settle () { box.checked = false; el.classList.remove('is-press') },
75
+ loop (later) {
76
+ later(() => tap(later), 900)
77
+ later(() => tap(later), 2900)
78
+ later(() => DEMO.loop(later), 4400)
79
+ },
80
+ stop () { el.classList.remove('is-press') },
81
+ }
82
+ // =====================
83
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
84
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
85
+ addEventListener('message', (e) => {
86
+ const d = e.data; if (!d || typeof d !== 'object') return
87
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
88
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
89
+ })
90
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
91
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
92
+ })()
93
+ </script>
94
+ </body>
95
+ </html>