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,126 @@
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":"mp-vip","zh":"会员开卡","en":"VIP Membership","cat":"shop","desc":"深金会员权益卡配月季方案切换,点立即开卡流光扫过生效","desc_en":"Dark-gold VIP card with plan switch; tapping Join sweeps a shine and activates it","needs":"js","play":"press","hint":"点开卡","hint_en":"Join VIP","source":null,"prompt":"会员开卡模块:宽 296px、圆角 16px 的 --color-surface 外框。上部嵌一张深金渐变黑金卡(圆角 12px),带皇冠图标、「山岚黑金卡」、右侧价格/状态胶囊和三项小权益(免配送、全场9折、生日赠饮);下部左侧月卡 ¥9.9 与季卡 ¥24.9 两个单选胶囊,右侧「立即开卡」主色按钮。切方案实时更新卡面标价;点开卡后一道高光斜扫卡面,状态变为 --color-success「已生效」,按钮切为「去享权益」。","prompt_en":"VIP activation card (296px, 16px radius) on --color-surface. Top holds a 12px-radius dark-gold pass with crown icon, brand name, status pill, and three perk tags. Bottom offers Monthly ¥9.9 and Quarterly ¥24.9 plan pills plus a Join button. Switching plans updates the pass badge live; tapping Join sweeps a highlight sheen across the card and turns the status and CTA --color-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
+ /* 会员开卡:深金卡面 + 方案切换 + 开卡流光生效。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning / --color-success */
18
+ .c-mp-vip{box-sizing:border-box;width:296px;padding:10px;border-radius:16px;display:grid;gap:9px;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-mp-vip button{font:inherit;border:0;padding:0;background:none;color:inherit;cursor:pointer}
20
+ .c-mp-vip button:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
21
+ .c-mp-vip .vp-card{position:relative;padding:11px 13px 10px;border-radius:12px;overflow:hidden;color:#fbe5b7;background:radial-gradient(120% 100% at 100% 0%,rgba(255,204,102,.28),transparent 58%),linear-gradient(140deg,#2e2820,#191612);box-shadow:inset 0 0 0 .5px rgba(255,221,150,.32),0 6px 14px -8px rgba(0,0,0,.45);display:grid;gap:10px}
22
+ .c-mp-vip .vp-card::after{content:"";position:absolute;inset:-20% -60%;background:linear-gradient(110deg,transparent 40%,rgba(255,240,198,.42) 50%,transparent 60%);transform:translateX(-110%);pointer-events:none}
23
+ .c-mp-vip.is-on .vp-card::after{animation:mp-vip-shine .8s cubic-bezier(.25,.7,.3,1)}
24
+ .c-mp-vip .vp-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
25
+ .c-mp-vip .vp-brand{display:inline-flex;align-items:center;gap:6px;font-size:14px;font-weight:700;letter-spacing:.02em}
26
+ .c-mp-vip .vp-brand svg{width:16px;height:16px;fill:var(--color-warning,#ffb340)}
27
+ .c-mp-vip .vp-st{padding:2px 8px;border-radius:10px;font-size:10.5px;font-weight:700;color:#2b1e08;background:linear-gradient(90deg,#ffe09e,var(--color-warning,#ffb340));font-variant-numeric:tabular-nums;transition:background .24s,color .24s}
28
+ .c-mp-vip.is-on .vp-st{color:#fff;background:var(--color-success,#30b35a)}
29
+ .c-mp-vip .vp-perks{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
30
+ .c-mp-vip .vp-pk{padding:5px 4px;border-radius:8px;text-align:center;font-size:10.5px;font-weight:600;color:#f6dca4;background:rgba(255,225,165,.1);box-shadow:inset 0 0 0 .5px rgba(255,225,165,.18)}
31
+ .c-mp-vip .vp-ft{display:flex;align-items:center;gap:7px}
32
+ .c-mp-vip .vp-plans{flex:1;display:grid;grid-template-columns:1fr 1fr;gap:6px}
33
+ .c-mp-vip .vp-pl{height:38px;padding:0 8px;border-radius:10px;display:grid;place-content:center;justify-items:center;gap:1px;background:color-mix(in srgb,var(--color-text,#141413) 5%,transparent);box-shadow:inset 0 0 0 1px transparent;transition:background-color .2s,box-shadow .2s,transform .16s}
34
+ .c-mp-vip .vp-pl:active{transform:scale(.95)}
35
+ .c-mp-vip .vp-pl span{font-size:10px;color:var(--color-muted,#76756f)}
36
+ .c-mp-vip .vp-pl b{font-size:13px;font-weight:700;font-variant-numeric:tabular-nums}
37
+ .c-mp-vip .vp-pl[aria-pressed=true]{background:color-mix(in srgb,var(--color-warning,#ffb340) 16%,transparent);box-shadow:inset 0 0 0 1.2px var(--color-warning,#ffb340)}
38
+ .c-mp-vip .vp-pl[aria-pressed=true] b{color:color-mix(in srgb,var(--color-warning,#ffb340) 68%,var(--color-text,#141413))}
39
+ .c-mp-vip .vp-cta{flex:none;height:38px;padding:0 15px;border-radius:12px;font-size:12.5px;font-weight:700;color:#2b1e08;background:linear-gradient(135deg,#ffe2a4,var(--color-warning,#ffb340));box-shadow:0 4px 12px -4px color-mix(in srgb,var(--color-warning,#ffb340) 65%,transparent);transition:transform .18s,background .24s,color .24s}
40
+ .c-mp-vip .vp-cta:active,.c-mp-vip .vp-cta.is-press{transform:scale(.94)}
41
+ .c-mp-vip.is-on .vp-cta{color:#fff;background:var(--color-success,#30b35a);box-shadow:0 4px 12px -4px color-mix(in srgb,var(--color-success,#30b35a) 60%,transparent)}
42
+ @keyframes mp-vip-shine{from{transform:translateX(-110%)}to{transform:translateX(110%)}}
43
+ @media (prefers-reduced-motion:reduce){.c-mp-vip *,.c-mp-vip *::after{animation:none!important;transition:none!important}}
44
+ </style>
45
+ </head>
46
+ <body>
47
+ <div class="stage-fit">
48
+ <div class="c-mp-vip" data-comp="mp-vip">
49
+ <div class="vp-card">
50
+ <div class="vp-top">
51
+ <span class="vp-brand"><svg viewBox="0 0 20 20" aria-hidden="true"><path d="M2.5 14.5 4 6.5l4.2 3.2L10 4.5l1.8 5.2L16 6.5l1.5 8z"/></svg>山岚黑金卡</span>
52
+ <span class="vp-st">首月 ¥9.9</span>
53
+ </div>
54
+ <div class="vp-perks"><span class="vp-pk">免配送费</span><span class="vp-pk">全场 9 折</span><span class="vp-pk">生日赠饮</span></div>
55
+ </div>
56
+ <div class="vp-ft">
57
+ <div class="vp-plans" role="group" aria-label="会员方案">
58
+ <button class="vp-pl" type="button" data-p="首月 ¥9.9" aria-pressed="true"><span>连续包月</span><b>¥9.9</b></button>
59
+ <button class="vp-pl" type="button" data-p="季卡 ¥24.9" aria-pressed="false"><span>季卡省5元</span><b>¥24.9</b></button>
60
+ </div>
61
+ <button class="vp-cta" type="button">立即开卡</button>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ <script data-comp>
66
+ /* 会员开卡:切换月季方案联动卡面价格,点立即开卡流光扫过并切已生效 */
67
+ (() => {
68
+ document.querySelectorAll('.c-mp-vip').forEach((el) => {
69
+ const plans = [...el.querySelectorAll('.vp-pl')], st = el.querySelector('.vp-st'), cta = el.querySelector('.vp-cta')
70
+ let cur = 0, on = false
71
+ const paint = () => {
72
+ el.classList.toggle('is-on', on)
73
+ plans.forEach((p, i) => p.setAttribute('aria-pressed', i === cur))
74
+ st.textContent = on ? '已生效 30天' : plans[cur].dataset.p
75
+ cta.textContent = on ? '去享权益' : '立即开卡'
76
+ }
77
+ el.vpSet = (idx, active) => { cur = idx; on = active; paint() }
78
+ plans.forEach((p, i) => p.addEventListener('click', () => { cur = i; on = false; paint() }))
79
+ cta.addEventListener('click', () => { on = !on; paint() })
80
+ paint()
81
+ })
82
+ })()
83
+ </script>
84
+ <script data-stage>
85
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
86
+ (() => {
87
+ const q = new URLSearchParams(location.search); const root = document.documentElement
88
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
89
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
90
+ const el = document.querySelector('.stage-fit > [data-comp]')
91
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
92
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
93
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
94
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
95
+ let playing = !q.has('still'); let hovering = false; let timers = []
96
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
97
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
98
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
99
+ // ===== 只改这一段 =====
100
+ const cta = el.querySelector('.vp-cta')
101
+ const tap = (later, idx, on) => { cta.classList.add('is-press'); later(() => { cta.classList.remove('is-press'); el.vpSet(idx, on) }, 120) }
102
+ const DEMO = {
103
+ settle () { el.vpSet(0, false) },
104
+ loop (later) {
105
+ el.vpSet(0, false)
106
+ later(() => el.vpSet(1, false), 850)
107
+ later(() => tap(later, 1, true), 1850)
108
+ later(() => el.vpSet(0, false), 4100)
109
+ later(() => DEMO.loop(later), 4900)
110
+ },
111
+ stop () { cta.classList.remove('is-press') },
112
+ }
113
+ // =====================
114
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
115
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
116
+ addEventListener('message', (e) => {
117
+ const d = e.data; if (!d || typeof d !== 'object') return
118
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
119
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
120
+ })
121
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
122
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
123
+ })()
124
+ </script>
125
+ </body>
126
+ </html>
@@ -0,0 +1,174 @@
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":"mp-wizard","zh":"分步表单","en":"Step Form","cat":"shop","desc":"三步向导带顶部步骤条,点下一步内容横滑并自动汇总到确认页","desc_en":"Three-step wizard with top progress steps; panels slide and summarize on step 3","needs":"js","play":"press","hint":"点下一步","hint_en":"Next step","source":{"name":"Vant","url":"https://github.com/youzan/vant/blob/main/packages/vant/src/steps/index.less","license":"MIT","author":"Youzan, Chen Jiahan and other contributors"},"prompt":"三步分步表单卡片:宽 296px、圆角 16px。顶部横向 3 步进度条改写自 Vant steps(1 选服务、2 选人数、3 确认),连线随进度点亮 --color-primary,已完成圆点显示对勾。中间固定高度视口通过 translateX 在三页间平滑横滑:第一步选体验类型,第二步选同行人数,第三步自动汇总已选结果。底部提供「上一步」与「下一步 / 确认提交」,提交后切 --color-success「重新预约」与「已预约」。","prompt_en":"Three-step wizard card (296px, 16px radius) with a horizontal step bar adapted from Vant steps: active and completed connectors turn --color-primary with checkmarks. A clipped middle track slides horizontally via translateX across Service, Party Size, and Live Summary panes. Bottom Back and Next/Submit buttons turn --color-success on completion."}</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
+ /* 分步表单:顶部横向步骤圆点与连线结构改写自 Vant(MIT,© Youzan, Chen Jiahan and other contributors,https://github.com/youzan/vant)的 steps;三页横滑与实时汇总为新做。
18
+ 读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success */
19
+ .c-mp-wizard{--wz-step:0;box-sizing:border-box;width:296px;padding:8px 13px 9px;border-radius:16px;display:grid;gap:6px;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)}
20
+ .c-mp-wizard button{font:inherit;border:0;padding:0;background:none;color:inherit;cursor:pointer}
21
+ .c-mp-wizard button:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
22
+ .c-mp-wizard .wz-steps{position:relative;display:grid;grid-template-columns:repeat(3,1fr);padding-bottom:5px;border-bottom:.5px solid var(--color-line,rgba(0,0,0,.09))}
23
+ .c-mp-wizard .wz-steps::before,.c-mp-wizard .wz-line{content:"";position:absolute;left:17%;top:9px;height:2px;border-radius:1px}
24
+ .c-mp-wizard .wz-steps::before{right:17%;background:color-mix(in srgb,var(--color-text,#141413) 12%,transparent)}
25
+ .c-mp-wizard .wz-line{width:calc(var(--wz-step,0) * 33%);background:var(--color-primary,#0a84ff);transition:width .36s cubic-bezier(.3,1.2,.4,1),background-color .24s}
26
+ .c-mp-wizard.is-done .wz-line{background:var(--color-success,#30b35a)}
27
+ .c-mp-wizard .wz-st{position:relative;display:grid;justify-items:center;gap:3px;font-size:10.5px;color:var(--color-muted,#76756f)}
28
+ .c-mp-wizard .wz-dot{width:18px;height:18px;border-radius:50%;display:grid;place-items:center;font-style:normal;font-size:10px;font-weight:700;background:var(--color-surface,#fff);color:var(--color-muted,#76756f);box-shadow:inset 0 0 0 1.4px color-mix(in srgb,var(--color-muted,#76756f) 42%,transparent);transition:background-color .24s,color .24s,box-shadow .24s,transform .28s}
29
+ .c-mp-wizard .wz-st.is-now{color:var(--color-primary,#0a84ff);font-weight:600}
30
+ .c-mp-wizard .wz-st.is-now .wz-dot{background:var(--color-primary,#0a84ff);color:#fff;box-shadow:0 0 0 3px color-mix(in srgb,var(--color-primary,#0a84ff) 20%,transparent)}
31
+ .c-mp-wizard .wz-st.is-ok{color:var(--color-text,#141413)}
32
+ .c-mp-wizard .wz-st.is-ok .wz-dot{background:var(--color-success,#30b35a);color:#fff;box-shadow:none}
33
+ .c-mp-wizard .wz-view{overflow:hidden}
34
+ .c-mp-wizard .wz-track{display:flex;transform:translateX(calc(var(--wz-step,0) * -100%));transition:transform .38s cubic-bezier(.3,1.15,.4,1)}
35
+ .c-mp-wizard .wz-pane{flex:none;width:100%;box-sizing:border-box;display:grid;align-content:center;gap:5px;min-height:56px}
36
+ .c-mp-wizard .wz-q{font-size:12px;font-weight:600}
37
+ .c-mp-wizard .wz-opts{display:flex;gap:6px}
38
+ .c-mp-wizard .wz-opt{flex:1;height:30px;border-radius:10px;font-size:11.5px;font-weight:500;color:var(--color-muted,#76756f);background:color-mix(in srgb,var(--color-text,#141413) 5.5%,transparent);box-shadow:inset 0 0 0 1px transparent;transition:background-color .2s,color .2s,box-shadow .2s,transform .16s}
39
+ .c-mp-wizard .wz-opt:active{transform:scale(.94)}
40
+ .c-mp-wizard .wz-opt[aria-pressed=true]{color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-primary,#0a84ff) 12%,transparent);box-shadow:inset 0 0 0 1.2px var(--color-primary,#0a84ff);font-weight:600}
41
+ .c-mp-wizard .wz-sum{padding:8px 10px;border-radius:10px;background:color-mix(in srgb,var(--color-text,#141413) 4.5%,transparent);display:flex;align-items:center;justify-content:space-between;gap:8px}
42
+ .c-mp-wizard .wz-sum div{display:grid;gap:2px}
43
+ .c-mp-wizard .wz-sum strong{font-size:12.5px;font-weight:700}
44
+ .c-mp-wizard .wz-sum span{font-size:11px;color:var(--color-muted,#76756f)}
45
+ .c-mp-wizard .wz-ok-tag{padding:2px 7px;border-radius:8px;font-size:10.5px;font-weight:600;color:var(--color-success,#30b35a);background:color-mix(in srgb,var(--color-success,#30b35a) 15%,transparent)}
46
+ .c-mp-wizard .wz-ft{display:flex;align-items:center;justify-content:space-between;gap:8px}
47
+ .c-mp-wizard .wz-prev{height:30px;padding:0 12px;border-radius:15px;font-size:12px;font-weight:600;color:var(--color-text,#141413);box-shadow:inset 0 0 0 1px var(--color-line,rgba(0,0,0,.18));transition:opacity .2s,transform .16s}
48
+ .c-mp-wizard .wz-prev:disabled{opacity:.32;cursor:default}
49
+ .c-mp-wizard .wz-prev:not(:disabled):active{transform:scale(.94)}
50
+ .c-mp-wizard .wz-next{flex:1;height:30px;border-radius:15px;font-size:12px;font-weight:600;color:#fff;background:var(--color-primary,#0a84ff);transition:background-color .24s,transform .18s}
51
+ .c-mp-wizard .wz-next:active,.c-mp-wizard .wz-next.is-press{transform:scale(.96)}
52
+ .c-mp-wizard.is-done .wz-next{background:var(--color-success,#30b35a)}
53
+ @media (prefers-reduced-motion:reduce){.c-mp-wizard *{transition:none!important}}
54
+ </style>
55
+ </head>
56
+ <body>
57
+ <div class="stage-fit">
58
+ <div class="c-mp-wizard" data-comp="mp-wizard">
59
+ <div class="wz-steps" role="group" aria-label="步骤进度">
60
+ <span class="wz-line"></span>
61
+ <button class="wz-st is-now" type="button" data-go="0"><i class="wz-dot">1</i><span>选服务</span></button>
62
+ <button class="wz-st" type="button" data-go="1"><i class="wz-dot">2</i><span>选人数</span></button>
63
+ <button class="wz-st" type="button" data-go="2"><i class="wz-dot">3</i><span>确认</span></button>
64
+ </div>
65
+ <div class="wz-view">
66
+ <div class="wz-track">
67
+ <div class="wz-pane">
68
+ <div class="wz-q">预约哪种体验</div>
69
+ <div class="wz-opts" data-k="svc"><button class="wz-opt" type="button" aria-pressed="true">到店品茶</button><button class="wz-opt" type="button" aria-pressed="false">手作课堂</button><button class="wz-opt" type="button" aria-pressed="false">团建包场</button></div>
70
+ </div>
71
+ <div class="wz-pane">
72
+ <div class="wz-q">同行人数</div>
73
+ <div class="wz-opts" data-k="num"><button class="wz-opt" type="button" aria-pressed="false">2 人</button><button class="wz-opt" type="button" aria-pressed="true">4 人</button><button class="wz-opt" type="button" aria-pressed="false">6 人</button></div>
74
+ </div>
75
+ <div class="wz-pane">
76
+ <div class="wz-sum"><div><strong class="wz-sv">到店品茶 4 人</strong><span>青松路店 本周六 14:00</span></div><span class="wz-ok-tag">可预约</span></div>
77
+ </div>
78
+ </div>
79
+ </div>
80
+ <div class="wz-ft">
81
+ <button class="wz-prev" type="button" disabled>上一步</button>
82
+ <button class="wz-next" type="button">下一步</button>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ <script data-comp>
87
+ /* 分步表单:步骤 0/1/2 横向切换,汇总前两步选项到确认页,确认后切绿色已提交 */
88
+ (() => {
89
+ document.querySelectorAll('.c-mp-wizard').forEach((el) => {
90
+ const sts = [...el.querySelectorAll('.wz-st')], prev = el.querySelector('.wz-prev'), next = el.querySelector('.wz-next')
91
+ const sv = el.querySelector('.wz-sv'), okTag = el.querySelector('.wz-ok-tag')
92
+ let step = 0, done = false
93
+ const syncSum = () => {
94
+ const a = el.querySelector('[data-k=svc] [aria-pressed=true]').textContent
95
+ const b = el.querySelector('[data-k=num] [aria-pressed=true]').textContent
96
+ sv.textContent = a + ' ' + b
97
+ }
98
+ const paint = () => {
99
+ el.style.setProperty('--wz-step', step)
100
+ el.classList.toggle('is-done', done)
101
+ sts.forEach((s, i) => {
102
+ const ok = i < step || (done && i === 2)
103
+ s.classList.toggle('is-ok', ok)
104
+ s.classList.toggle('is-now', !ok && i === step)
105
+ s.querySelector('.wz-dot').textContent = ok ? '✓' : String(i + 1)
106
+ })
107
+ prev.disabled = step === 0
108
+ okTag.textContent = done ? '已预约' : '可预约'
109
+ next.textContent = done ? '重新预约' : (step === 2 ? '确认提交' : '下一步')
110
+ syncSum()
111
+ }
112
+ el.wzSet = (s, isDone) => { step = s; done = !!isDone; paint() }
113
+ el.addEventListener('click', (e) => {
114
+ const b = e.target.closest('button'); if (!b || b.disabled) return
115
+ if (b.classList.contains('wz-opt')) {
116
+ b.parentNode.querySelectorAll('.wz-opt').forEach((x) => x.setAttribute('aria-pressed', x === b))
117
+ done = false; paint()
118
+ } else if (b.dataset.go != null) { step = Number(b.dataset.go); done = false; paint() }
119
+ else if (b === prev) { step = Math.max(0, step - 1); done = false; paint() }
120
+ else if (b === next) {
121
+ if (done) { step = 0; done = false }
122
+ else if (step < 2) step += 1
123
+ else done = true
124
+ paint()
125
+ }
126
+ })
127
+ paint()
128
+ })
129
+ })()
130
+ </script>
131
+ <script data-stage>
132
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
133
+ (() => {
134
+ const q = new URLSearchParams(location.search); const root = document.documentElement
135
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
136
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
137
+ const el = document.querySelector('.stage-fit > [data-comp]')
138
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
139
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
140
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
141
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
142
+ let playing = !q.has('still'); let hovering = false; let timers = []
143
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
144
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
145
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
146
+ // ===== 只改这一段 =====
147
+ const next = el.querySelector('.wz-next')
148
+ const tap = (later, s, d) => { next.classList.add('is-press'); later(() => { next.classList.remove('is-press'); el.wzSet(s, d) }, 110) }
149
+ const DEMO = {
150
+ settle () { el.wzSet(0, false) },
151
+ loop (later) {
152
+ el.wzSet(0, false)
153
+ later(() => tap(later, 1, false), 600)
154
+ later(() => tap(later, 2, false), 1650)
155
+ later(() => tap(later, 2, true), 2550)
156
+ later(() => el.wzSet(0, false), 4400)
157
+ later(() => DEMO.loop(later), 5100)
158
+ },
159
+ stop () { next.classList.remove('is-press') },
160
+ }
161
+ // =====================
162
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
163
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
164
+ addEventListener('message', (e) => {
165
+ const d = e.data; if (!d || typeof d !== 'object') return
166
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
167
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
168
+ })
169
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
170
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
171
+ })()
172
+ </script>
173
+ </body>
174
+ </html>
@@ -35,7 +35,7 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
35
35
  </head>
36
36
  <body>
37
37
  <div class="stage-fit">
38
- <div class="c-otp-code" data-comp="otp-code" data-len="4"><input class="oc-in" type="text" inputmode="numeric" autocomplete="one-time-code" maxlength="4" aria-label="验证码"></div>
38
+ <div class="c-otp-code" data-comp="otp-code" data-len="4"><input class="oc-in" type="text" inputmode="numeric" autocomplete="one-time-code" maxlength="4" aria-label="验证码"><span class="oc-cell" style="--i:0"></span><span class="oc-cell" style="--i:1"></span><span class="oc-cell" style="--i:2"></span><span class="oc-cell" style="--i:3"></span><span class="oc-ring"></span></div>
39
39
  </div>
40
40
  <script data-comp>
41
41
  /* 验证码输入逻辑:输入框的值 → 四格数字(新数字弹上来、删掉的淡出)、光标框位置、输满变绿。一页可放多个。 */
@@ -43,7 +43,8 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
43
43
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
44
44
  document.querySelectorAll('.c-otp-code').forEach((el) => {
45
45
  const n = +el.dataset.len || 4, inp = el.querySelector('.oc-in')
46
- el.insertAdjacentHTML('beforeend', Array.from({ length: n }, (_, i) => `<span class="oc-cell" style="--i:${i}"></span>`).join('') + '<span class="oc-ring"></span>')
46
+ if (el.querySelectorAll('.oc-cell').length !== n) el.querySelectorAll('.oc-cell, .oc-ring').forEach((x) => x.remove())
47
+ if (!el.querySelector('.oc-cell')) el.insertAdjacentHTML('beforeend', Array.from({ length: n }, (_, i) => `<span class="oc-cell" style="--i:${i}"></span>`).join('') + '<span class="oc-ring"></span>')
47
48
  const cells = [...el.querySelectorAll('.oc-cell')]
48
49
  let shown = ''
49
50
  const set = (raw) => {
@@ -75,8 +76,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
75
76
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
76
77
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
77
78
  const el = document.querySelector('.stage-fit > [data-comp]')
78
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
79
- fit(); addEventListener('resize', fit)
79
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
80
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
81
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
82
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
80
83
  let playing = !q.has('still'); let hovering = false; let timers = []
81
84
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
82
85
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -98,8 +98,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
98
98
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
99
99
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
100
100
  const el = document.querySelector('.stage-fit > [data-comp]')
101
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
102
- fit(); addEventListener('resize', fit)
101
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
102
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
103
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
104
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
103
105
  let playing = !q.has('still'); let hovering = false; let timers = []
104
106
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
105
107
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -102,8 +102,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
102
102
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
103
103
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
104
104
  const el = document.querySelector('.stage-fit > [data-comp]')
105
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
106
- fit(); addEventListener('resize', fit)
105
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
106
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
107
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
108
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
107
109
  let playing = !q.has('still'); let hovering = false; let timers = []
108
110
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
109
111
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -45,8 +45,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
45
45
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
46
46
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
47
47
  const el = document.querySelector('.stage-fit > [data-comp]')
48
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
49
- fit(); addEventListener('resize', fit)
48
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
49
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
50
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
51
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
50
52
  let playing = !q.has('still'); let hovering = false; let timers = []
51
53
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
52
54
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -90,8 +90,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
90
90
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
91
91
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
92
92
  const el = document.querySelector('.stage-fit > [data-comp]')
93
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
94
- fit(); addEventListener('resize', fit)
93
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
94
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
95
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
96
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
95
97
  let playing = !q.has('still'); let hovering = false; let timers = []
96
98
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
97
99
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -95,8 +95,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
95
95
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
96
96
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
97
97
  const el = document.querySelector('.stage-fit > [data-comp]')
98
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
99
- fit(); addEventListener('resize', fit)
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)
100
102
  let playing = !q.has('still'); let hovering = false; let timers = []
101
103
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
102
104
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -61,8 +61,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
61
61
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
62
62
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
63
63
  const el = document.querySelector('.stage-fit > [data-comp]')
64
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
65
- fit(); addEventListener('resize', fit)
64
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
65
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
66
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
67
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
66
68
  let playing = !q.has('still'); let hovering = false; let timers = []
67
69
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
68
70
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -80,8 +80,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
80
80
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
81
81
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
82
82
  const el = document.querySelector('.stage-fit > [data-comp]')
83
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
84
- fit(); addEventListener('resize', fit)
83
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
84
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
85
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
86
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
85
87
  let playing = !q.has('still'); let hovering = false; let timers = []
86
88
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
87
89
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -102,8 +102,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
102
102
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
103
103
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
104
104
  const el = document.querySelector('.stage-fit > [data-comp]')
105
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
106
- fit(); addEventListener('resize', fit)
105
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
106
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
107
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
108
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
107
109
  let playing = !q.has('still'); let hovering = false; let timers = []
108
110
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
109
111
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -98,8 +98,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
98
98
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
99
99
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
100
100
  const el = document.querySelector('.stage-fit > [data-comp]')
101
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
102
- fit(); addEventListener('resize', fit)
101
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
102
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
103
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
104
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
103
105
  let playing = !q.has('still'); let hovering = false; let timers = []
104
106
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
105
107
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -62,8 +62,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
62
62
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
63
63
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
64
64
  const el = document.querySelector('.stage-fit > [data-comp]')
65
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
66
- fit(); addEventListener('resize', fit)
65
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
66
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
67
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
68
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
67
69
  let playing = !q.has('still'); let hovering = false; let timers = []
68
70
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
69
71
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -57,8 +57,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
57
57
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
58
58
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
59
59
  const el = document.querySelector('.stage-fit > [data-comp]')
60
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
61
- fit(); addEventListener('resize', fit)
60
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
61
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
62
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
63
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
62
64
  let playing = !q.has('still'); let hovering = false; let timers = []
63
65
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
64
66
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -141,8 +141,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
141
141
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
142
142
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
143
143
  const el = document.querySelector('.stage-fit > [data-comp]')
144
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
145
- fit(); addEventListener('resize', fit)
144
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
145
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
146
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
147
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
146
148
  let playing = !q.has('still'); let hovering = false; let timers = []
147
149
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
148
150
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -79,8 +79,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
79
79
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
80
80
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
81
81
  const el = document.querySelector('.stage-fit > [data-comp]')
82
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
83
- fit(); addEventListener('resize', fit)
82
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
83
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
84
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
85
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
84
86
  let playing = !q.has('still'); let hovering = false; let timers = []
85
87
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
86
88
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -78,8 +78,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
78
78
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
79
79
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
80
80
  const el = document.querySelector('.stage-fit > [data-comp]')
81
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
82
- fit(); addEventListener('resize', fit)
81
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
82
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
83
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
84
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
83
85
  let playing = !q.has('still'); let hovering = false; let timers = []
84
86
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
85
87
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }