dsh-design-studio 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) 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/demo.gif +0 -0
  5. package/assets/hero-sm.jpg +0 -0
  6. package/assets/motion/ai-capsule.html +4 -2
  7. package/assets/motion/ai-glow-input.html +4 -2
  8. package/assets/motion/app-fab.html +130 -0
  9. package/assets/motion/app-gallery.html +125 -0
  10. package/assets/motion/app-index.html +138 -0
  11. package/assets/motion/app-largetitle.html +138 -0
  12. package/assets/motion/app-onboard.html +141 -0
  13. package/assets/motion/app-player.html +152 -0
  14. package/assets/motion/app-popover.html +133 -0
  15. package/assets/motion/app-rings.html +143 -0
  16. package/assets/motion/app-searchhist.html +131 -0
  17. package/assets/motion/app-tabbar.html +148 -0
  18. package/assets/motion/app-tabs.html +150 -0
  19. package/assets/motion/app-video.html +136 -0
  20. package/assets/motion/balance-odometer.html +4 -2
  21. package/assets/motion/bottom-sheet.html +4 -2
  22. package/assets/motion/brightness-pill.html +4 -2
  23. package/assets/motion/chart-area.html +111 -0
  24. package/assets/motion/chart-bar.html +100 -0
  25. package/assets/motion/chart-donut.html +145 -0
  26. package/assets/motion/chart-funnel.html +120 -0
  27. package/assets/motion/chart-gantt.html +140 -0
  28. package/assets/motion/chart-gauge.html +126 -0
  29. package/assets/motion/chart-heat.html +121 -0
  30. package/assets/motion/chart-kpi.html +110 -0
  31. package/assets/motion/chart-line.html +154 -0
  32. package/assets/motion/chart-radar.html +153 -0
  33. package/assets/motion/chart-rank.html +112 -0
  34. package/assets/motion/chart-stack.html +107 -0
  35. package/assets/motion/comet-ring.html +4 -2
  36. package/assets/motion/copy-morph.html +4 -2
  37. package/assets/motion/cube-grid.html +4 -2
  38. package/assets/motion/day-night.html +4 -2
  39. package/assets/motion/dial-knob.html +4 -2
  40. package/assets/motion/dock-magnify.html +4 -2
  41. package/assets/motion/download-ring.html +4 -2
  42. package/assets/motion/expand-card.html +4 -2
  43. package/assets/motion/flip-card.html +4 -2
  44. package/assets/motion/hold-pay.html +4 -2
  45. package/assets/motion/holo-card.html +4 -2
  46. package/assets/motion/keycap.html +4 -2
  47. package/assets/motion/like-jelly.html +4 -2
  48. package/assets/motion/liquid-progress.html +4 -2
  49. package/assets/motion/liquid-segment.html +4 -2
  50. package/assets/motion/live-capsule.html +4 -2
  51. package/assets/motion/m-actionsheet.html +84 -0
  52. package/assets/motion/m-address.html +113 -0
  53. package/assets/motion/m-buybar.html +122 -0
  54. package/assets/motion/m-calendar.html +135 -0
  55. package/assets/motion/m-capsule-nav.html +97 -0
  56. package/assets/motion/m-cart.html +162 -0
  57. package/assets/motion/m-category.html +154 -0
  58. package/assets/motion/m-chat.html +125 -0
  59. package/assets/motion/m-coupon.html +84 -0
  60. package/assets/motion/m-dialog.html +102 -0
  61. package/assets/motion/m-empty.html +121 -0
  62. package/assets/motion/m-filter.html +171 -0
  63. package/assets/motion/m-goods.html +151 -0
  64. package/assets/motion/m-grid.html +98 -0
  65. package/assets/motion/m-login.html +127 -0
  66. package/assets/motion/m-msglist.html +88 -0
  67. package/assets/motion/m-order.html +111 -0
  68. package/assets/motion/m-profile.html +110 -0
  69. package/assets/motion/m-pull.html +199 -0
  70. package/assets/motion/m-settings.html +81 -0
  71. package/assets/motion/m-sku.html +114 -0
  72. package/assets/motion/m-swiper.html +163 -0
  73. package/assets/motion/m-timeline.html +109 -0
  74. package/assets/motion/m-wheel.html +182 -0
  75. package/assets/motion/marker-highlight.html +4 -2
  76. package/assets/motion/marquee-logos.html +4 -2
  77. package/assets/motion/mp-cartbar.html +158 -0
  78. package/assets/motion/mp-checkin.html +121 -0
  79. package/assets/motion/mp-form.html +128 -0
  80. package/assets/motion/mp-group.html +148 -0
  81. package/assets/motion/mp-invite.html +119 -0
  82. package/assets/motion/mp-points.html +143 -0
  83. package/assets/motion/mp-queue.html +136 -0
  84. package/assets/motion/mp-rate.html +166 -0
  85. package/assets/motion/mp-seckill.html +140 -0
  86. package/assets/motion/mp-store.html +137 -0
  87. package/assets/motion/mp-vip.html +126 -0
  88. package/assets/motion/mp-wizard.html +174 -0
  89. package/assets/motion/otp-code.html +7 -4
  90. package/assets/motion/password-eye.html +4 -2
  91. package/assets/motion/ruler-slider.html +4 -2
  92. package/assets/motion/search-expand.html +4 -2
  93. package/assets/motion/send-fly.html +4 -2
  94. package/assets/motion/skeleton-shine.html +4 -2
  95. package/assets/motion/star-rate.html +4 -2
  96. package/assets/motion/success-check.html +4 -2
  97. package/assets/motion/suggest-chips.html +4 -2
  98. package/assets/motion/swipe-row.html +4 -2
  99. package/assets/motion/tabbar-bounce.html +4 -2
  100. package/assets/motion/tactile-controls.html +4 -2
  101. package/assets/motion/text-scramble.html +4 -2
  102. package/assets/motion/toast-stack.html +4 -2
  103. package/assets/motion/token-stream.html +4 -2
  104. package/assets/motion/um-bell.html +106 -0
  105. package/assets/motion/um-chips.html +132 -0
  106. package/assets/motion/um-coin.html +119 -0
  107. package/assets/motion/um-hue.html +128 -0
  108. package/assets/motion/um-ink-switch.html +129 -0
  109. package/assets/motion/um-leaf-tabs.html +138 -0
  110. package/assets/motion/um-plan.html +110 -0
  111. package/assets/motion/um-radial.html +104 -0
  112. package/assets/motion/um-stroke-check.html +86 -0
  113. package/assets/motion/um-swipe-confirm.html +182 -0
  114. package/assets/motion/um-tide.html +180 -0
  115. package/assets/motion/voice-orb.html +4 -2
  116. package/assets/motion/web-404.html +95 -0
  117. package/assets/motion/web-cmdk.html +167 -0
  118. package/assets/motion/web-dropdown.html +94 -0
  119. package/assets/motion/web-faq.html +84 -0
  120. package/assets/motion/web-footer.html +109 -0
  121. package/assets/motion/web-hero.html +98 -0
  122. package/assets/motion/web-navbar.html +149 -0
  123. package/assets/motion/web-newsletter.html +124 -0
  124. package/assets/motion/web-pagination.html +132 -0
  125. package/assets/motion/web-pricing.html +110 -0
  126. package/assets/motion/web-testimonial.html +129 -0
  127. package/assets/motion/web-upload.html +160 -0
  128. package/lib/client.js +76 -17
  129. package/lib/index.js +6 -2
  130. package/lib/motion.js +11 -2
  131. package/package.json +1 -1
@@ -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() }
@@ -101,8 +101,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
101
101
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
102
102
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
103
103
  const el = document.querySelector('.stage-fit > [data-comp]')
104
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
105
- fit(); addEventListener('resize', fit)
104
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
105
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
106
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
107
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
106
108
  let playing = !q.has('still'); let hovering = false; let timers = []
107
109
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
108
110
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -78,8 +78,10 @@ body{display:grid;place-items:center;background:var(--color-bg);background-image
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() }
@@ -104,8 +104,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
104
104
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
105
105
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
106
106
  const el = document.querySelector('.stage-fit > [data-comp]')
107
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
108
- fit(); addEventListener('resize', fit)
107
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
108
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
109
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
110
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
109
111
  let playing = !q.has('still'); let hovering = false; let timers = []
110
112
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
111
113
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -103,8 +103,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
103
103
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
104
104
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
105
105
  const el = document.querySelector('.stage-fit > [data-comp]')
106
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
107
- fit(); addEventListener('resize', fit)
106
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
107
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
108
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
109
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
108
110
  let playing = !q.has('still'); let hovering = false; let timers = []
109
111
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
110
112
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -67,8 +67,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
67
67
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
68
68
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
69
69
  const el = document.querySelector('.stage-fit > [data-comp]')
70
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
71
- fit(); addEventListener('resize', fit)
70
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
71
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
72
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
73
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
72
74
  let playing = !q.has('still'); let hovering = false; let timers = []
73
75
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
74
76
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -109,8 +109,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
109
109
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
110
110
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
111
111
  const el = document.querySelector('.stage-fit > [data-comp]')
112
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
113
- fit(); addEventListener('resize', fit)
112
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
113
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
114
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
115
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
114
116
  let playing = !q.has('still'); let hovering = false; let timers = []
115
117
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
116
118
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -96,8 +96,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
96
96
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
97
97
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
98
98
  const el = document.querySelector('.stage-fit > [data-comp]')
99
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
100
- fit(); addEventListener('resize', fit)
99
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
100
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
101
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
102
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
101
103
  let playing = !q.has('still'); let hovering = false; let timers = []
102
104
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
103
105
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -59,8 +59,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
59
59
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
60
60
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
61
61
  const el = document.querySelector('.stage-fit > [data-comp]')
62
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
63
- fit(); addEventListener('resize', fit)
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)
64
66
  let playing = !q.has('still'); let hovering = false; let timers = []
65
67
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
66
68
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -58,8 +58,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
58
58
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
59
59
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
60
60
  const el = document.querySelector('.stage-fit > [data-comp]')
61
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
62
- fit(); addEventListener('resize', fit)
61
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
62
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
63
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
64
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
63
65
  let playing = !q.has('still'); let hovering = false; let timers = []
64
66
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
65
67
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -84,8 +84,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
84
84
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
85
85
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
86
86
  const el = document.querySelector('.stage-fit > [data-comp]')
87
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
88
- fit(); addEventListener('resize', fit)
87
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
88
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
89
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
90
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
89
91
  let playing = !q.has('still'); let hovering = false; let timers = []
90
92
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
91
93
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -93,8 +93,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
93
93
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
94
94
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
95
95
  const el = document.querySelector('.stage-fit > [data-comp]')
96
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
97
- fit(); addEventListener('resize', fit)
96
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
97
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
98
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
99
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
98
100
  let playing = !q.has('still'); let hovering = false; let timers = []
99
101
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
100
102
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -109,8 +109,10 @@ body{display:grid;place-items:center;background:var(--color-bg);font-family:var(
109
109
  root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
110
110
  const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
111
111
  const el = document.querySelector('.stage-fit > [data-comp]')
112
- const fit = () => root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3))
113
- fit(); addEventListener('resize', fit)
112
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
113
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
114
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
115
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
114
116
  let playing = !q.has('still'); let hovering = false; let timers = []
115
117
  const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
116
118
  const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
@@ -0,0 +1,84 @@
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":"m-actionsheet","zh":"分享菜单","en":"Action Sheet","cat":"mobile","desc":"点分享,菜单从底部滑上来,背后压暗","desc_en":"Tap Share and the sheet slides up while the page dims","needs":"css","play":"press","hint":"点分享","hint_en":"Tap share","source":{"name":"WeUI","url":"https://github.com/Tencent/weui/blob/master/src/style/widget/weui-tips/weui-actionsheet.less","license":"MIT","author":"2017 THL A29 Limited (Tencent)"},"prompt":"底部操作菜单:手机一屏里点「分享」按钮,半透明黑色蒙层淡入,菜单从底部上滑(transform .3s,WeUI 做法),顶部圆角 14px。从上到下:小号灰色标题、几行居中操作(行间 0.5px --color-line)、一条灰色间隔、「取消」。按下一行变浅灰;点蒙层或取消收起。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary。纯 CSS(整块是 label 包一个 checkbox)。","prompt_en":"Bottom action sheet: tapping Share fades in a dim mask and slides the sheet up (transform .3s, as in WeUI), 14px top radius. Small muted title, centered actions split by .5px --color-line, an 8px gray gap, then Cancel. Rows tint on press; mask or Cancel closes. Colors --color-surface/text/muted/line/primary. Pure CSS: a label wrapping one checkbox."}</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
+ /* 分享菜单:改写自 WeUI(MIT,© 2017 THL A29 Limited,https://github.com/Tencent/weui)的 weui-actionsheet.less:上滑过渡、标题与取消分区。
18
+ 读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
19
+ .c-m-actionsheet{position:relative;display:block;cursor:pointer;width:232px;height:172px;border-radius:22px;overflow:hidden;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-m-actionsheet input{position:absolute;opacity:0;pointer-events:none}
21
+ .c-m-actionsheet .as-page,.c-m-actionsheet .as-mask,.c-m-actionsheet .as-sheet span{display:block}
22
+ .c-m-actionsheet .as-page{position:absolute;inset:0;padding:16px}
23
+ .c-m-actionsheet .as-pic{display:block;height:74px;border-radius:12px;background:linear-gradient(135deg,color-mix(in srgb,var(--color-primary,#0a84ff) 55%,#fff),color-mix(in srgb,var(--color-primary,#0a84ff) 20%,var(--color-surface,#fff)))}
24
+ .c-m-actionsheet .as-line{display:block;height:7px;width:70%;margin-top:11px;border-radius:4px;background:color-mix(in srgb,var(--color-text,#141413) 13%,transparent)}
25
+ .c-m-actionsheet .as-line+.as-line{width:46%;margin-top:7px;opacity:.6}
26
+ .c-m-actionsheet .as-open{position:absolute;left:50%;bottom:14px;transform:translateX(-50%);height:30px;padding:0 22px;border-radius:15px;display:grid;place-items:center;font-size:13px;font-weight:600;color:#fff;background:var(--color-primary,#0a84ff);cursor:pointer;transition:transform .2s}
27
+ .c-m-actionsheet .as-open:active{transform:translateX(-50%) scale(.94)}
28
+ .c-m-actionsheet .as-mask{position:absolute;inset:0;background:rgba(0,0,0,.45);opacity:0;transition:opacity .3s}
29
+ .c-m-actionsheet .as-sheet{display:block;position:absolute;left:0;right:0;bottom:0;border-radius:14px 14px 0 0;overflow:hidden;background:color-mix(in srgb,var(--color-text,#141413) 6%,var(--color-surface,#fff));transform:translateY(100%);transition:transform .3s}
30
+ .c-m-actionsheet .as-sheet .as-title{height:22px;display:grid;place-items:center;font-size:11px;color:var(--color-muted,#76756f);background:var(--color-surface,#fff)}
31
+ .c-m-actionsheet .as-sheet .as-cell{height:28px;display:grid;place-items:center;font-size:13.5px;background:var(--color-surface,#fff);box-shadow:inset 0 .5px 0 var(--color-line,rgba(0,0,0,.1));cursor:pointer}
32
+ .c-m-actionsheet .as-sheet .as-cell:active{background:color-mix(in srgb,var(--color-text,#141413) 7%,var(--color-surface,#fff))}
33
+ .c-m-actionsheet .as-sheet .as-cancel{margin-top:6px;box-shadow:none}
34
+ .c-m-actionsheet input:checked~.as-mask{opacity:1}
35
+ .c-m-actionsheet input:checked~.as-sheet{transform:none}
36
+ .c-m-actionsheet input:focus-visible~.as-page .as-open{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
37
+ @media (prefers-reduced-motion:reduce){.c-m-actionsheet *{transition:none!important}}
38
+ </style>
39
+ </head>
40
+ <body>
41
+ <div class="stage-fit">
42
+ <label class="c-m-actionsheet" data-comp="m-actionsheet">
43
+ <input type="checkbox" aria-label="分享">
44
+ <span class="as-page"><span class="as-pic"></span><span class="as-line"></span><span class="as-line"></span><span class="as-open">分享</span></span>
45
+ <span class="as-mask"></span>
46
+ <span class="as-sheet"><span class="as-title">分享给朋友</span><span class="as-cell">发送给朋友</span><span class="as-cell">生成海报</span><span class="as-cell">复制链接</span><span class="as-cell as-cancel">取消</span></span>
47
+ </label>
48
+ </div>
49
+ <script data-stage>
50
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
51
+ (() => {
52
+ const q = new URLSearchParams(location.search); const root = document.documentElement
53
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
54
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
55
+ const el = document.querySelector('.stage-fit > [data-comp]')
56
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
57
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
58
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
59
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
60
+ let playing = !q.has('still'); let hovering = false; let timers = []
61
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
62
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
63
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
64
+ // ===== 只改这一段 =====
65
+ const box = el.querySelector('input')
66
+ const DEMO = {
67
+ settle () { box.checked = true },
68
+ loop (later) { later(() => { box.checked = true }, 500); later(() => { box.checked = false }, 2600); later(() => DEMO.loop(later), 3600) },
69
+ stop () {},
70
+ }
71
+ // =====================
72
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
73
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
74
+ addEventListener('message', (e) => {
75
+ const d = e.data; if (!d || typeof d !== 'object') return
76
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
77
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
78
+ })
79
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
80
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
81
+ })()
82
+ </script>
83
+ </body>
84
+ </html>
@@ -0,0 +1,113 @@
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":"m-address","zh":"地址卡片","en":"Address Card","cat":"shop","desc":"收货地址列表,带默认标签,点一条选中打勾,右侧带编辑按钮","desc_en":"Shipping address list with a default tag, tap to check, and an edit button","needs":"css","play":"press","hint":"点地址切换","hint_en":"Tap to pick","source":{"name":"TDesign 零售模板","url":"https://github.com/Tencent/tdesign-miniprogram-starter-retail/blob/main/pages/user/components/ui-address-item/index.wxml","license":"MIT","author":"2021-present TDesign"},"prompt":"收货地址列表卡片:宽 296px、圆角 16px 的 --color-surface 卡片(用 form 包裹,一页放多个不互相冲突),两条收货地址用 0.5px --color-line 分隔。每条左侧 20px 勾选圆点(选中填 --color-primary 弹簧打勾,整行带淡主色底),中间联系人与示例手机号、下方「默认」淡红胶囊或「公司」淡蓝胶囊加详细地址,右侧 30px 圆形编辑图标按钮带按压缩放反馈。纯 CSS(radio + :has)。","prompt_en":"Address list card: 296px --color-surface card (16px radius) wrapped in a form so multiple instances isolate radios. Two rows separated by a .5px --color-line hairline: left 20px check circle (fills --color-primary with a spring tick and tints the row), middle name, fake phone, Default/Office tag pill and address, right 30px edit icon button. Pure CSS radios and :has."}</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
+ /* 地址卡片 改写自 TDesign 小程序零售模板(MIT,© 2021-present TDesign,https://github.com/Tencent/tdesign-miniprogram-starter-retail)的 ui-address-item:左勾选、姓名电话与默认标签、右编辑按钮布局;去掉左滑删除,改用纯 CSS 表单单选。
18
+ 读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger */
19
+ .c-m-address{width:296px;border-radius:16px;overflow:hidden;margin:0;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-m-address .ad-row{position:relative;display:flex;align-items:center;transition:background-color .22s}
21
+ .c-m-address .ad-row+.ad-row::before{content:"";position:absolute;left:40px;right:12px;top:0;border-top:.5px solid var(--color-line,rgba(0,0,0,.1))}
22
+ .c-m-address .ad-row:has(input:checked){background:color-mix(in srgb,var(--color-primary,#0a84ff) 6%,transparent)}
23
+ .c-m-address .ad-main{flex:1;min-width:0;display:flex;align-items:center;gap:10px;padding:12px 6px 12px 12px;cursor:pointer;transition:transform .16s}
24
+ .c-m-address .ad-main:active{transform:scale(.985)}
25
+ .c-m-address input{position:absolute;opacity:0;pointer-events:none}
26
+ .c-m-address .ad-chk{flex:none;width:19px;height:19px;border-radius:50%;display:grid;place-items:center;box-shadow:inset 0 0 0 1.4px color-mix(in srgb,var(--color-muted,#76756f) 55%,transparent);transition:background-color .2s,box-shadow .2s,transform .3s cubic-bezier(.3,1.65,.5,1)}
27
+ .c-m-address .ad-chk svg{width:11px;height:11px;fill:none;stroke:#fff;stroke-width:2.3;stroke-linecap:round;stroke-linejoin:round;opacity:0;transform:scale(.45);transition:opacity .16s,transform .28s cubic-bezier(.3,1.6,.5,1)}
28
+ .c-m-address input:checked+.ad-chk{background:var(--color-primary,#0a84ff);box-shadow:none;transform:scale(1.05)}
29
+ .c-m-address input:checked+.ad-chk svg{opacity:1;transform:scale(1)}
30
+ .c-m-address input:focus-visible+.ad-chk{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
31
+ .c-m-address .ad-info{flex:1;min-width:0;display:grid;gap:4px}
32
+ .c-m-address .ad-hd{display:flex;align-items:baseline;gap:7px;line-height:1.25}
33
+ .c-m-address .ad-hd strong{font-size:13.5px;font-weight:600}
34
+ .c-m-address .ad-hd span{font-size:12px;color:var(--color-muted,#76756f);font-variant-numeric:tabular-nums}
35
+ .c-m-address .ad-desc{font-size:11.5px;line-height:1.4;color:var(--color-muted,#76756f);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
36
+ .c-m-address .ad-tag{display:inline-block;margin-right:5px;padding:1px 6px;border-radius:9px;font-style:normal;font-size:10px;font-weight:600;line-height:1.4;vertical-align:1px}
37
+ .c-m-address .ad-tag.def{color:var(--color-danger,#ff375f);background:color-mix(in srgb,var(--color-danger,#ff375f) 13%,transparent)}
38
+ .c-m-address .ad-tag.biz{color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-primary,#0a84ff) 13%,transparent)}
39
+ .c-m-address .ad-edit{flex:none;width:30px;height:30px;margin-right:8px;border:0;border-radius:50%;background:none;color:var(--color-muted,#76756f);display:grid;place-items:center;cursor:pointer;transition:background-color .18s,color .18s,transform .18s}
40
+ .c-m-address .ad-edit:hover{background:color-mix(in srgb,var(--color-text,#141413) 7%,transparent);color:var(--color-text,#141413)}
41
+ .c-m-address .ad-edit:active{transform:scale(.86)}
42
+ .c-m-address .ad-edit:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:1px}
43
+ .c-m-address .ad-edit svg{width:15px;height:15px;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
44
+ @media (prefers-reduced-motion:reduce){.c-m-address *{transition:none!important}}
45
+ </style>
46
+ </head>
47
+ <body>
48
+ <div class="stage-fit">
49
+ <form class="c-m-address" data-comp="m-address">
50
+ <div class="ad-row">
51
+ <label class="ad-main">
52
+ <input type="radio" name="ad-pick" checked>
53
+ <i class="ad-chk" aria-hidden="true"><svg viewBox="0 0 12 12"><path d="M2.4 6.2 5 8.8 9.6 3.5"/></svg></i>
54
+ <span class="ad-info">
55
+ <span class="ad-hd"><strong>林小满</strong><span>138 0000 0000</span></span>
56
+ <span class="ad-desc"><em class="ad-tag def">默认</em>示例市青松路 88 号 3 栋 201</span>
57
+ </span>
58
+ </label>
59
+ <button class="ad-edit" type="button" aria-label="编辑林小满的地址"><svg viewBox="0 0 18 18"><path d="M12.6 3.2 14.8 5.4 6.6 13.6 3.6 14.4 4.4 11.4z"/><path d="M10.8 5 13 7.2"/></svg></button>
60
+ </div>
61
+ <div class="ad-row">
62
+ <label class="ad-main">
63
+ <input type="radio" name="ad-pick">
64
+ <i class="ad-chk" aria-hidden="true"><svg viewBox="0 0 12 12"><path d="M2.4 6.2 5 8.8 9.6 3.5"/></svg></i>
65
+ <span class="ad-info">
66
+ <span class="ad-hd"><strong>陈安宁</strong><span>139 0000 0000</span></span>
67
+ <span class="ad-desc"><em class="ad-tag biz">公司</em>示例市滨河路 100 号东座 502</span>
68
+ </span>
69
+ </label>
70
+ <button class="ad-edit" type="button" aria-label="编辑陈安宁的地址"><svg viewBox="0 0 18 18"><path d="M12.6 3.2 14.8 5.4 6.6 13.6 3.6 14.4 4.4 11.4z"/><path d="M10.8 5 13 7.2"/></svg></button>
71
+ </div>
72
+ </form>
73
+ </div>
74
+ <script data-stage>
75
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
76
+ (() => {
77
+ const q = new URLSearchParams(location.search); const root = document.documentElement
78
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
79
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
80
+ const el = document.querySelector('.stage-fit > [data-comp]')
81
+ // 桌面版里框常常先报 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)
85
+ let playing = !q.has('still'); let hovering = false; let timers = []
86
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
87
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
88
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
89
+ // ===== 只改这一段 =====
90
+ const radios = el.querySelectorAll('input[type=radio]')
91
+ const DEMO = {
92
+ settle () { radios[0].checked = true },
93
+ loop (later) {
94
+ later(() => { radios[1].checked = true }, 900)
95
+ later(() => { radios[0].checked = true }, 2400)
96
+ later(() => DEMO.loop(later), 3800)
97
+ },
98
+ stop () {},
99
+ }
100
+ // =====================
101
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
102
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
103
+ addEventListener('message', (e) => {
104
+ const d = e.data; if (!d || typeof d !== 'object') return
105
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
106
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
107
+ })
108
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
109
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
110
+ })()
111
+ </script>
112
+ </body>
113
+ </html>
@@ -0,0 +1,122 @@
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":"m-buybar","zh":"底部购买栏","en":"Product Buy Bar","cat":"shop","desc":"商品详情底栏:客服、带角标购物车和双拼按钮,点加购角标轻弹","desc_en":"Product footer with support, badged cart, and split pills; adding pops the badge","needs":"js","play":"press","hint":"点加购","hint_en":"Add to cart","source":{"name":"TDesign 零售模板","url":"https://github.com/Tencent/tdesign-miniprogram-starter-retail/blob/main/pages/goods/details/components/buy-bar/index.wxml","license":"MIT","author":"2021-present TDesign"},"prompt":"商品详情页底部购买栏:宽 300px、高 60px、圆角 18px 的 --color-surface 悬浮条。左侧两枚图标按钮「客服」与「购物车」,购物车右上角带 --color-danger 计数角标;右侧一对拼合胶囊按钮,左边浅红底红字「加入购物车」,右边 --color-danger 实心白字「立即购买」。点「加入购物车」时按钮按压缩放,购物车角标加一并弹簧跳动,上方轻飘一颗「+1」淡出;点「立即购买」给出按压反馈。减少动效时只更新角标数字。","prompt_en":"Product detail buy bar: 300×60 --color-surface pill bar (18px radius). Left: Support and Cart icon buttons, Cart carrying a --color-danger count badge; right: split pill buttons, tinted Add to cart and solid --color-danger Buy now. Tapping Add to cart increments and spring-pops the badge, tilts the cart icon, and floats a fading +1 tag. Reduced motion updates the count immediately."}</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
+ /* 底部购买栏 改写自 TDesign 小程序零售模板(MIT,© 2021-present TDesign,https://github.com/Tencent/tdesign-miniprogram-starter-retail)的 buy-bar:左双图标带角标、右拼合双胶囊按钮;图标改用内联 SVG,新增角标弹簧跳动与 +1 轻飘反馈。
18
+ 读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger */
19
+ .c-m-buybar{position:relative;width:300px;height:60px;padding:0 10px 0 8px;box-sizing:border-box;border-radius:18px;display:flex;align-items:center;gap:4px;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-m-buybar button{font:inherit;border:0;padding:0;background:none;color:inherit;cursor:pointer}
21
+ .c-m-buybar button:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
22
+ .c-m-buybar .bb-ico{position:relative;flex:none;width:44px;height:44px;border-radius:12px;display:grid;place-content:center;justify-items:center;gap:2px;color:var(--color-muted,#76756f);transition:background-color .2s,transform .18s}
23
+ .c-m-buybar .bb-ico:active,.c-m-buybar .bb-ico.is-press{transform:scale(.9);background:color-mix(in srgb,var(--color-text,#141413) 6%,transparent)}
24
+ .c-m-buybar .bb-ico svg{width:19px;height:19px;fill:none;stroke:var(--color-text,#141413);stroke-width:1.75;stroke-linecap:round;stroke-linejoin:round}
25
+ .c-m-buybar .bb-ico span{font-size:10px;line-height:1}
26
+ .c-m-buybar .bb-badge{position:absolute;top:1px;right:3px;min-width:16px;height:16px;padding:0 4px;box-sizing:border-box;border-radius:8px;display:grid;place-items:center;font-style:normal;font-size:10px;font-weight:700;font-variant-numeric:tabular-nums;color:#fff;background:var(--color-danger,#ff375f);box-shadow:0 0 0 1.5px var(--color-surface,#fff)}
27
+ .c-m-buybar .bb-plus{position:absolute;left:50%;top:-4px;transform:translateX(-50%);font-size:11px;font-weight:700;color:var(--color-danger,#ff375f);opacity:0;pointer-events:none}
28
+ .c-m-buybar .bb-cart.is-pop .bb-badge{animation:m-buybar-pop .44s cubic-bezier(.3,1.75,.45,1)}
29
+ .c-m-buybar .bb-cart.is-pop svg{animation:m-buybar-hop .42s cubic-bezier(.3,1.5,.5,1)}
30
+ .c-m-buybar .bb-cart.is-pop .bb-plus{animation:m-buybar-rise .6s cubic-bezier(.2,.8,.3,1)}
31
+ .c-m-buybar .bb-acts{flex:1;display:flex;height:38px;margin-left:4px}
32
+ .c-m-buybar .bb-add,.c-m-buybar .bb-buy{flex:1;height:38px;font-size:12.5px;font-weight:600;display:grid;place-items:center;transition:transform .18s cubic-bezier(.3,1.5,.5,1),filter .18s}
33
+ .c-m-buybar .bb-add{border-radius:19px 0 0 19px;color:var(--color-danger,#ff375f);background:color-mix(in srgb,var(--color-danger,#ff375f) 14%,var(--color-surface,#fff))}
34
+ .c-m-buybar .bb-buy{border-radius:0 19px 19px 0;color:#fff;background:var(--color-danger,#ff375f);box-shadow:inset 0 1px 0 rgba(255,255,255,.26)}
35
+ .c-m-buybar .bb-add:active,.c-m-buybar .bb-add.is-press,.c-m-buybar .bb-buy:active,.c-m-buybar .bb-buy.is-press{transform:scale(.95)}
36
+ @keyframes m-buybar-pop{0%{transform:scale(1)}35%{transform:scale(1.42)}70%{transform:scale(.92)}100%{transform:scale(1)}}
37
+ @keyframes m-buybar-hop{0%{transform:none}35%{transform:translateY(-3px) rotate(-8deg)}70%{transform:translateY(1px) rotate(4deg)}100%{transform:none}}
38
+ @keyframes m-buybar-rise{0%{opacity:0;transform:translate(-50%,4px) scale(.8)}30%{opacity:1;transform:translate(-50%,-8px) scale(1)}100%{opacity:0;transform:translate(-50%,-18px) scale(.9)}}
39
+ @media (prefers-reduced-motion:reduce){.c-m-buybar *{animation:none!important;transition:none!important}}
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <div class="stage-fit">
44
+ <div class="c-m-buybar" data-comp="m-buybar">
45
+ <button class="bb-ico bb-kf" type="button" aria-label="联系客服">
46
+ <svg viewBox="0 0 22 22" aria-hidden="true"><path d="M5 12v-1a6 6 0 0 1 12 0v1"/><rect x="3.5" y="11.5" width="3" height="5" rx="1.4"/><rect x="15.5" y="11.5" width="3" height="5" rx="1.4"/><path d="M16.5 16.5c0 1.4-1.3 2.2-3.2 2.2H11"/></svg>
47
+ <span>客服</span>
48
+ </button>
49
+ <button class="bb-ico bb-cart" type="button" aria-label="查看购物车">
50
+ <svg viewBox="0 0 22 22" aria-hidden="true"><path d="M3 4.5h2.4l1.8 9h9.6l1.7-6.5H6.4"/><circle cx="8.6" cy="17.2" r="1.3"/><circle cx="15.6" cy="17.2" r="1.3"/></svg>
51
+ <span>购物车</span>
52
+ <i class="bb-badge" aria-live="polite">2</i>
53
+ <b class="bb-plus" aria-hidden="true">+1</b>
54
+ </button>
55
+ <div class="bb-acts">
56
+ <button class="bb-add" type="button">加入购物车</button>
57
+ <button class="bb-buy" type="button">立即购买</button>
58
+ </div>
59
+ </div>
60
+ </div>
61
+ <script data-comp>
62
+ /* 底部购买栏:点加入购物车角标数字加一并弹簧跳动,点立即购买给出轻弹反馈。支持一页多实例。 */
63
+ (() => {
64
+ document.querySelectorAll('.c-m-buybar').forEach((el) => {
65
+ const cart = el.querySelector('.bb-cart'), badge = el.querySelector('.bb-badge'), buy = el.querySelector('.bb-buy')
66
+ let n = 2, buyTimer = 0
67
+ const addOne = () => {
68
+ n = n >= 99 ? 1 : n + 1; badge.textContent = String(n)
69
+ cart.classList.remove('is-pop'); void cart.offsetWidth; cart.classList.add('is-pop')
70
+ }
71
+ el.querySelector('.bb-add').addEventListener('click', addOne)
72
+ buy.addEventListener('click', () => {
73
+ clearTimeout(buyTimer); buy.textContent = '去结算'; buyTimer = setTimeout(() => { buy.textContent = '立即购买' }, 900)
74
+ })
75
+ el.bbSet = (v) => { clearTimeout(buyTimer); buy.textContent = '立即购买'; n = v; badge.textContent = String(n); cart.classList.remove('is-pop') }
76
+ el.bbStop = () => { clearTimeout(buyTimer); buy.textContent = '立即购买'; cart.classList.remove('is-pop') }
77
+ })
78
+ })()
79
+ </script>
80
+ <script data-stage>
81
+ /* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
82
+ (() => {
83
+ const q = new URLSearchParams(location.search); const root = document.documentElement
84
+ root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
85
+ const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
86
+ const el = document.querySelector('.stage-fit > [data-comp]')
87
+ // 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
88
+ const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
89
+ fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
90
+ if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
91
+ let playing = !q.has('still'); let hovering = false; let timers = []
92
+ const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
93
+ const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
94
+ const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
95
+ // ===== 只改这一段 =====
96
+ const add = el.querySelector('.bb-add')
97
+ const tap = (later) => { add.classList.add('is-press'); later(() => { add.classList.remove('is-press'); add.click() }, 120) }
98
+ const DEMO = {
99
+ settle () { el.bbSet(3) },
100
+ loop (later) {
101
+ el.bbSet(2)
102
+ later(() => tap(later), 400)
103
+ later(() => tap(later), 1020)
104
+ later(() => tap(later), 2350)
105
+ later(() => DEMO.loop(later), 4100)
106
+ },
107
+ stop () { add.classList.remove('is-press'); el.bbStop() },
108
+ }
109
+ // =====================
110
+ document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
111
+ document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
112
+ addEventListener('message', (e) => {
113
+ const d = e.data; if (!d || typeof d !== 'object') return
114
+ if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
115
+ if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
116
+ })
117
+ try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
118
+ if (reduced || q.has('still')) DEMO.settle(); else go(600)
119
+ })()
120
+ </script>
121
+ </body>
122
+ </html>