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.
- package/README.en.md +2 -1
- package/README.md +2 -1
- package/THIRD_PARTY_NOTICES.md +319 -0
- package/assets/motion/ai-capsule.html +4 -2
- package/assets/motion/ai-glow-input.html +4 -2
- package/assets/motion/app-fab.html +130 -0
- package/assets/motion/app-gallery.html +125 -0
- package/assets/motion/app-index.html +138 -0
- package/assets/motion/app-largetitle.html +138 -0
- package/assets/motion/app-onboard.html +141 -0
- package/assets/motion/app-player.html +152 -0
- package/assets/motion/app-popover.html +133 -0
- package/assets/motion/app-rings.html +143 -0
- package/assets/motion/app-searchhist.html +131 -0
- package/assets/motion/app-tabbar.html +148 -0
- package/assets/motion/app-tabs.html +150 -0
- package/assets/motion/app-video.html +136 -0
- package/assets/motion/balance-odometer.html +4 -2
- package/assets/motion/bottom-sheet.html +4 -2
- package/assets/motion/brightness-pill.html +4 -2
- package/assets/motion/chart-area.html +111 -0
- package/assets/motion/chart-bar.html +100 -0
- package/assets/motion/chart-donut.html +145 -0
- package/assets/motion/chart-funnel.html +120 -0
- package/assets/motion/chart-gantt.html +140 -0
- package/assets/motion/chart-gauge.html +126 -0
- package/assets/motion/chart-heat.html +121 -0
- package/assets/motion/chart-kpi.html +110 -0
- package/assets/motion/chart-line.html +154 -0
- package/assets/motion/chart-radar.html +153 -0
- package/assets/motion/chart-rank.html +112 -0
- package/assets/motion/chart-stack.html +107 -0
- package/assets/motion/comet-ring.html +4 -2
- package/assets/motion/copy-morph.html +4 -2
- package/assets/motion/cube-grid.html +4 -2
- package/assets/motion/day-night.html +4 -2
- package/assets/motion/dial-knob.html +4 -2
- package/assets/motion/dock-magnify.html +4 -2
- package/assets/motion/download-ring.html +4 -2
- package/assets/motion/expand-card.html +4 -2
- package/assets/motion/flip-card.html +4 -2
- package/assets/motion/hold-pay.html +4 -2
- package/assets/motion/holo-card.html +4 -2
- package/assets/motion/keycap.html +4 -2
- package/assets/motion/like-jelly.html +4 -2
- package/assets/motion/liquid-progress.html +4 -2
- package/assets/motion/liquid-segment.html +4 -2
- package/assets/motion/live-capsule.html +4 -2
- package/assets/motion/m-actionsheet.html +84 -0
- package/assets/motion/m-address.html +113 -0
- package/assets/motion/m-buybar.html +122 -0
- package/assets/motion/m-calendar.html +135 -0
- package/assets/motion/m-capsule-nav.html +97 -0
- package/assets/motion/m-cart.html +162 -0
- package/assets/motion/m-category.html +154 -0
- package/assets/motion/m-chat.html +125 -0
- package/assets/motion/m-coupon.html +84 -0
- package/assets/motion/m-dialog.html +102 -0
- package/assets/motion/m-empty.html +121 -0
- package/assets/motion/m-filter.html +171 -0
- package/assets/motion/m-goods.html +151 -0
- package/assets/motion/m-grid.html +98 -0
- package/assets/motion/m-login.html +127 -0
- package/assets/motion/m-msglist.html +88 -0
- package/assets/motion/m-order.html +111 -0
- package/assets/motion/m-profile.html +110 -0
- package/assets/motion/m-pull.html +199 -0
- package/assets/motion/m-settings.html +81 -0
- package/assets/motion/m-sku.html +114 -0
- package/assets/motion/m-swiper.html +163 -0
- package/assets/motion/m-timeline.html +109 -0
- package/assets/motion/m-wheel.html +182 -0
- package/assets/motion/marker-highlight.html +4 -2
- package/assets/motion/marquee-logos.html +4 -2
- package/assets/motion/mp-cartbar.html +158 -0
- package/assets/motion/mp-checkin.html +121 -0
- package/assets/motion/mp-form.html +128 -0
- package/assets/motion/mp-group.html +148 -0
- package/assets/motion/mp-invite.html +119 -0
- package/assets/motion/mp-points.html +143 -0
- package/assets/motion/mp-queue.html +136 -0
- package/assets/motion/mp-rate.html +166 -0
- package/assets/motion/mp-seckill.html +140 -0
- package/assets/motion/mp-store.html +137 -0
- package/assets/motion/mp-vip.html +126 -0
- package/assets/motion/mp-wizard.html +174 -0
- package/assets/motion/otp-code.html +7 -4
- package/assets/motion/password-eye.html +4 -2
- package/assets/motion/ruler-slider.html +4 -2
- package/assets/motion/search-expand.html +4 -2
- package/assets/motion/send-fly.html +4 -2
- package/assets/motion/skeleton-shine.html +4 -2
- package/assets/motion/star-rate.html +4 -2
- package/assets/motion/success-check.html +4 -2
- package/assets/motion/suggest-chips.html +4 -2
- package/assets/motion/swipe-row.html +4 -2
- package/assets/motion/tabbar-bounce.html +4 -2
- package/assets/motion/tactile-controls.html +4 -2
- package/assets/motion/text-scramble.html +4 -2
- package/assets/motion/toast-stack.html +4 -2
- package/assets/motion/token-stream.html +4 -2
- package/assets/motion/um-bell.html +106 -0
- package/assets/motion/um-chips.html +132 -0
- package/assets/motion/um-coin.html +119 -0
- package/assets/motion/um-hue.html +128 -0
- package/assets/motion/um-ink-switch.html +129 -0
- package/assets/motion/um-leaf-tabs.html +138 -0
- package/assets/motion/um-plan.html +110 -0
- package/assets/motion/um-radial.html +104 -0
- package/assets/motion/um-stroke-check.html +86 -0
- package/assets/motion/um-swipe-confirm.html +182 -0
- package/assets/motion/um-tide.html +180 -0
- package/assets/motion/voice-orb.html +4 -2
- package/assets/motion/web-404.html +95 -0
- package/assets/motion/web-cmdk.html +167 -0
- package/assets/motion/web-dropdown.html +94 -0
- package/assets/motion/web-faq.html +84 -0
- package/assets/motion/web-footer.html +109 -0
- package/assets/motion/web-hero.html +98 -0
- package/assets/motion/web-navbar.html +149 -0
- package/assets/motion/web-newsletter.html +124 -0
- package/assets/motion/web-pagination.html +132 -0
- package/assets/motion/web-pricing.html +110 -0
- package/assets/motion/web-testimonial.html +129 -0
- package/assets/motion/web-upload.html +160 -0
- package/lib/client.js +72 -14
- package/lib/index.js +6 -2
- package/lib/motion.js +11 -2
- package/package.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>摇铃开关</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"um-bell","zh":"摇铃开关","en":"Bell Toggle","cat":"button","desc":"点亮通知时铃身与铃舌反向衰减摇摆并弹出红点角标,静音时画出斜线收起角标","desc_en":"Turning alerts on rings the bell and counter-swings its clapper with a badge; muting draws a slash","needs":"js","play":"press","hint":"点一下摇铃","hint_en":"Tap to ring","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/actions.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"摇铃开关:58×58 圆角 18px 方形图标按钮(--color-surface、发丝边与阴影),按下缩至 0.93。开启态图标呈 --color-primary,右上角弹出 20px 的 --color-danger 计数角标「3」,并驱动铃身按 18°/-15°/11°/-7°/3° 衰减摇摆(760ms),铃舌延迟 40ms 按 -1.4 倍角度反向摆动;静音态在 350ms 内沿对角画出斜杠并把角标缩为 0,下方切换「通知已开启」与「通知已静音」。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger,减少动效直接切态。","prompt_en":"Bell toggle: 58x58 --color-surface icon button (18px radius, presses to .93). Enabling colors the icon --color-primary, pops a --color-danger count badge, and rings the bell over 760ms (18/-15/11/-7/3 deg) while the clapper counter-swings -1.4x with a 40ms lag. Muting draws a diagonal slash (350ms), shrinks the badge to 0, and updates the status line. Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger; reduced motion snaps."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 摇铃开关:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/actions.html(#bell-toggle):保留 58×58 按钮、760ms 铃身/铃舌 40ms 错拍反向衰减摇摆与斜线描边,改中文状态并接设计变量。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-danger */
|
|
19
|
+
.c-um-bell{--bl-acc:var(--color-primary,#0a84ff);--bl-sp:cubic-bezier(.3,1.45,.5,1);--bl-ea:cubic-bezier(.16,1,.3,1);display:grid;justify-items:center;gap:10px;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-um-bell .bl-btn{position:relative;display:grid;place-items:center;width:58px;height:58px;padding:0;border:1px solid var(--color-line,rgba(0,0,0,.09));border-radius:18px;background:var(--color-surface,#fff);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 0 0 .5px var(--color-line,rgba(0,0,0,.09)),0 1px 2px rgba(0,0,0,.1),0 6px 18px rgba(0,0,0,.12);color:var(--color-muted,#76756f);cursor:pointer;transition:color .3s,scale .3s var(--bl-sp)}
|
|
21
|
+
.c-um-bell .bl-btn:active{scale:.93;transition-duration:.1s}
|
|
22
|
+
.c-um-bell .bl-btn:focus-visible{outline:2px solid var(--bl-acc);outline-offset:4px}
|
|
23
|
+
.c-um-bell .bl-btn[aria-pressed="true"]{color:var(--bl-acc)}
|
|
24
|
+
.c-um-bell svg{width:26px;height:26px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;overflow:visible}
|
|
25
|
+
.c-um-bell .bl-body,.c-um-bell .bl-clapper{transform-box:view-box;transform-origin:12px 3px}
|
|
26
|
+
.c-um-bell .bl-slash{stroke-dasharray:26;stroke-dashoffset:26;transition:stroke-dashoffset .35s var(--bl-ea)}
|
|
27
|
+
.c-um-bell .bl-btn[aria-pressed="false"] .bl-slash{stroke-dashoffset:0}
|
|
28
|
+
.c-um-bell .bl-badge{position:absolute;top:-6px;right:-6px;display:grid;place-items:center;min-width:20px;height:20px;padding:0 5px;box-sizing:border-box;border:2px solid var(--color-bg,var(--color-surface,#fff));border-radius:10px;background:var(--color-danger,#ff375f);color:#fff;font-size:11px;font-weight:700;font-variant-numeric:tabular-nums;transition:scale .35s var(--bl-sp)}
|
|
29
|
+
.c-um-bell .bl-btn[aria-pressed="false"] .bl-badge{scale:0}
|
|
30
|
+
.c-um-bell .bl-state{margin:0;font-size:12px;color:var(--color-muted,#76756f)}
|
|
31
|
+
@media (prefers-reduced-motion:reduce){.c-um-bell *{transition-duration:0s!important}}
|
|
32
|
+
</style>
|
|
33
|
+
</head>
|
|
34
|
+
<body>
|
|
35
|
+
<div class="stage-fit">
|
|
36
|
+
<div class="c-um-bell" data-comp="um-bell" data-on="1">
|
|
37
|
+
<button class="bl-btn" type="button" aria-pressed="true" aria-label="通知开关,未读 3 条">
|
|
38
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><g class="bl-body"><path d="M6 16.5V11a6 6 0 0 1 12 0v5.5l1.5 2h-15l1.5-2Z"/><path d="M12 3v2"/></g><path class="bl-clapper" d="M10 20.5a2 2 0 0 0 4 0"/><path class="bl-slash" d="M4 4l16 16"/></svg>
|
|
39
|
+
<span class="bl-badge" aria-hidden="true">3</span>
|
|
40
|
+
</button>
|
|
41
|
+
<p class="bl-state" aria-live="polite">通知已开启</p>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<script data-comp>
|
|
45
|
+
/* 摇铃开关逻辑:切开通知时铃身与铃舌延迟 40ms 反向衰减摇摆,静音时收起角标并画斜线 */
|
|
46
|
+
(() => {
|
|
47
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
48
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
49
|
+
const SWING = [0, 18, -15, 11, -7, 3, 0]
|
|
50
|
+
document.querySelectorAll('.c-um-bell').forEach((el) => {
|
|
51
|
+
const btn = el.querySelector('.bl-btn'), state = el.querySelector('.bl-state')
|
|
52
|
+
const body = el.querySelector('.bl-body'), clapper = el.querySelector('.bl-clapper')
|
|
53
|
+
let a1 = null, a2 = null
|
|
54
|
+
el.blSet = (on, anim = true) => {
|
|
55
|
+
btn.setAttribute('aria-pressed', String(on))
|
|
56
|
+
el.dataset.on = on ? '1' : '0'
|
|
57
|
+
state.textContent = on ? '通知已开启' : '通知已静音'
|
|
58
|
+
a1?.cancel(); a2?.cancel()
|
|
59
|
+
if (!on || !anim || !ok()) return
|
|
60
|
+
a1 = body.animate(SWING.map((d) => ({ rotate: d + 'deg' })), { duration: 760, easing: 'ease-out' })
|
|
61
|
+
a2 = clapper.animate(SWING.map((d) => ({ rotate: (-d * 1.4) + 'deg', translate: `${d * .08}px 0` })), { duration: 760, delay: 40, easing: 'ease-out' })
|
|
62
|
+
}
|
|
63
|
+
el.blStop = () => { a1?.cancel(); a2?.cancel() }
|
|
64
|
+
btn.addEventListener('click', () => el.blSet(btn.getAttribute('aria-pressed') !== 'true', true))
|
|
65
|
+
})
|
|
66
|
+
})()
|
|
67
|
+
</script>
|
|
68
|
+
<script data-stage>
|
|
69
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
70
|
+
(() => {
|
|
71
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
72
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
73
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
74
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
75
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
76
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
77
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
78
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
79
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
80
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
81
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
82
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
83
|
+
// ===== 只改这一段 =====
|
|
84
|
+
const DEMO = {
|
|
85
|
+
settle () { el.blSet(true, false) },
|
|
86
|
+
loop (later) {
|
|
87
|
+
later(() => el.blSet(false, true), 700)
|
|
88
|
+
later(() => el.blSet(true, true), 2300)
|
|
89
|
+
later(() => DEMO.loop(later), 4000)
|
|
90
|
+
},
|
|
91
|
+
stop () { el.blStop() },
|
|
92
|
+
}
|
|
93
|
+
// =====================
|
|
94
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
95
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
96
|
+
addEventListener('message', (e) => {
|
|
97
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
98
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
99
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
100
|
+
})
|
|
101
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
102
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
103
|
+
})()
|
|
104
|
+
</script>
|
|
105
|
+
</body>
|
|
106
|
+
</html>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>标签输入</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"um-chips","zh":"标签输入","en":"Chip Input","cat":"input","desc":"输入按回车或逗号弹出新标签,点叉或退格缩小移除,重复输入轻抖提示","desc_en":"Press Enter or comma to pop in a new chip; Backspace or click X shrinks it away, duplicates shake","needs":"js","play":"press","hint":"回车添标签","hint_en":"Type & enter","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/inputs.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"标签输入框:宽 244px、最小高 46px、圆角 13px 的 --color-surface 输入容器,最多容纳 5 枚 28px 高主色浅底标签(超出自动移除最早一枚)。键入文字按回车或逗号从 scale 0.6 弹簧弹出新标签(380ms),重复或空值提交时整框左右轻抖(±4px、240ms);点标签右侧叉号或在空输入时按退格,标签缩至 0.5 并淡出(180ms)。颜色读 --color-surface / --color-text / --color-muted / --color-line / --color-primary,减少动效直接增删。","prompt_en":"Chip input: 244px wide, 46px min-height --color-surface field (13px radius) holding up to five 28px --color-primary chips. Enter or comma pops a chip from scale .6 (380ms spring); empty or duplicate entries shake +/-4px (240ms). Close button or Backspace shrinks a chip to .5 and fades out (180ms). Reads --color-surface / --color-text / --color-muted / --color-line / --color-primary; reduced motion snaps."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 标签输入:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/inputs.html(#chip-input):保留最多 5 枚标签、380ms 弹入、180ms 缩出与重复轻抖逻辑,改为中文预置并接设计变量。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary */
|
|
19
|
+
.c-um-chips{--ch-acc:var(--color-primary,#0a84ff);--ch-sp:cubic-bezier(.3,1.45,.5,1);box-sizing:border-box;display:flex;flex-wrap:wrap;align-items:center;gap:6px;width:244px;min-height:46px;padding:7px;border:1px solid var(--color-line,rgba(0,0,0,.1));border-radius:13px;background:var(--color-surface,#fff);box-shadow:0 1px 2px rgba(0,0,0,.04);cursor:text;transition:border-color .25s,box-shadow .25s;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-um-chips:focus-within{border-color:var(--ch-acc);box-shadow:0 0 0 4px color-mix(in srgb,var(--ch-acc) 15%,transparent)}
|
|
21
|
+
.c-um-chips .ch-tag{display:inline-flex;align-items:center;gap:3px;height:28px;padding:0 4px 0 10px;border-radius:8px;background:color-mix(in srgb,var(--ch-acc) 13%,transparent);color:var(--ch-acc);font-size:13px;font-weight:560;white-space:nowrap}
|
|
22
|
+
.c-um-chips .ch-tag.is-new{animation:um-chips-in .38s var(--ch-sp)}
|
|
23
|
+
.c-um-chips .ch-tag button{display:grid;place-items:center;width:20px;height:20px;padding:0;border:0;border-radius:6px;background:none;color:inherit;font:500 15px/1 var(--font-sans,system-ui);opacity:.72;cursor:pointer;transition:opacity .15s,background-color .15s}
|
|
24
|
+
.c-um-chips .ch-tag button:hover{opacity:1;background:color-mix(in srgb,var(--ch-acc) 18%,transparent)}
|
|
25
|
+
.c-um-chips .ch-tag button:focus-visible{outline:2px solid var(--ch-acc);outline-offset:1px}
|
|
26
|
+
.c-um-chips input{flex:1;min-width:66px;height:28px;padding:0 4px;border:0;outline:0;background:none;color:var(--color-text,#141413);font:400 13.5px/1 var(--font-sans,system-ui);-webkit-user-select:text;user-select:text}
|
|
27
|
+
.c-um-chips input::placeholder{color:var(--color-muted,#76756f)}
|
|
28
|
+
@keyframes um-chips-in{from{scale:.6;opacity:0}}
|
|
29
|
+
@media (prefers-reduced-motion:reduce){.c-um-chips *{animation:none!important;transition-duration:0s!important}}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<div class="stage-fit">
|
|
34
|
+
<div class="c-um-chips" data-comp="um-chips" role="group" aria-label="标签输入">
|
|
35
|
+
<span class="ch-tag" data-val="设计">设计<button type="button" aria-label="移除设计">×</button></span>
|
|
36
|
+
<span class="ch-tag" data-val="动效">动效<button type="button" aria-label="移除动效">×</button></span>
|
|
37
|
+
<input type="text" placeholder="回车添加" aria-label="新标签" enterkeyhint="done" maxlength="8">
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
<script data-comp>
|
|
41
|
+
/* 标签输入逻辑:回车或逗号添加标签,最多 5 枚,重复轻抖,点叉或退格缩小删除 */
|
|
42
|
+
(() => {
|
|
43
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
44
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
45
|
+
document.querySelectorAll('.c-um-chips').forEach((el) => {
|
|
46
|
+
const inp = el.querySelector('input'), MAX = 5
|
|
47
|
+
const remove = (chip, anim = true) => {
|
|
48
|
+
if (!chip || chip.dataset.leaving) return
|
|
49
|
+
chip.dataset.leaving = ''
|
|
50
|
+
if (!anim || !ok()) return chip.remove()
|
|
51
|
+
chip.animate([{ scale: 1, opacity: 1 }, { scale: .5, opacity: 0 }], { duration: 180, easing: 'ease-in' }).onfinish = () => chip.remove()
|
|
52
|
+
}
|
|
53
|
+
const bindTag = (chip) => {
|
|
54
|
+
const btn = chip.querySelector('button')
|
|
55
|
+
btn.addEventListener('click', () => { remove(chip, true); inp.focus() })
|
|
56
|
+
}
|
|
57
|
+
const add = (text, anim = true) => {
|
|
58
|
+
text = text.trim()
|
|
59
|
+
const list = [...el.querySelectorAll('.ch-tag:not([data-leaving])')]
|
|
60
|
+
if (!text || list.some((c) => c.dataset.val === text)) {
|
|
61
|
+
if (anim && ok()) el.animate([{ translate: '0 0' }, { translate: '-4px 0' }, { translate: '4px 0' }, { translate: '0 0' }], { duration: 240 })
|
|
62
|
+
return
|
|
63
|
+
}
|
|
64
|
+
if (list.length >= MAX) remove(list[0], anim)
|
|
65
|
+
const chip = document.createElement('span')
|
|
66
|
+
chip.className = anim ? 'ch-tag is-new' : 'ch-tag'
|
|
67
|
+
chip.dataset.val = text
|
|
68
|
+
chip.append(text)
|
|
69
|
+
const x = document.createElement('button')
|
|
70
|
+
x.type = 'button'; x.textContent = '×'; x.setAttribute('aria-label', '移除' + text)
|
|
71
|
+
chip.append(x); bindTag(chip)
|
|
72
|
+
el.insertBefore(chip, inp)
|
|
73
|
+
}
|
|
74
|
+
el.querySelectorAll('.ch-tag').forEach(bindTag)
|
|
75
|
+
el.chAdd = (t) => add(t, true)
|
|
76
|
+
el.chPop = () => remove([...el.querySelectorAll('.ch-tag:not([data-leaving])')].at(-1), true)
|
|
77
|
+
el.chReset = () => {
|
|
78
|
+
el.querySelectorAll('.ch-tag').forEach((c) => c.remove())
|
|
79
|
+
inp.value = ''
|
|
80
|
+
;['设计', '动效'].forEach((t) => add(t, false))
|
|
81
|
+
}
|
|
82
|
+
inp.addEventListener('keydown', (e) => {
|
|
83
|
+
if (e.isComposing) return
|
|
84
|
+
if (e.key === 'Enter' || e.key === ',' || e.key === ',') { e.preventDefault(); add(inp.value, true); inp.value = '' }
|
|
85
|
+
else if (e.key === 'Backspace' && !inp.value) remove([...el.querySelectorAll('.ch-tag:not([data-leaving])')].at(-1), true)
|
|
86
|
+
})
|
|
87
|
+
el.addEventListener('pointerdown', (e) => { if (e.target === el) { e.preventDefault(); inp.focus() } })
|
|
88
|
+
})
|
|
89
|
+
})()
|
|
90
|
+
</script>
|
|
91
|
+
<script data-stage>
|
|
92
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
93
|
+
(() => {
|
|
94
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
95
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
96
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
97
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
98
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
99
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
100
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
101
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
102
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
103
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
104
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
105
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
106
|
+
// ===== 只改这一段 =====
|
|
107
|
+
const DEMO = {
|
|
108
|
+
settle () { el.chReset() },
|
|
109
|
+
loop (later) {
|
|
110
|
+
el.chReset()
|
|
111
|
+
later(() => el.chAdd('交互'), 700)
|
|
112
|
+
later(() => el.chAdd('组件'), 1700)
|
|
113
|
+
later(() => el.chAdd('设计'), 2600)
|
|
114
|
+
later(() => el.chPop(), 3400)
|
|
115
|
+
later(() => DEMO.loop(later), 4400)
|
|
116
|
+
},
|
|
117
|
+
stop () {},
|
|
118
|
+
}
|
|
119
|
+
// =====================
|
|
120
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
121
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
122
|
+
addEventListener('message', (e) => {
|
|
123
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
124
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
125
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
126
|
+
})
|
|
127
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
128
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
129
|
+
})()
|
|
130
|
+
</script>
|
|
131
|
+
</body>
|
|
132
|
+
</html>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>翻硬币</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"um-coin","zh":"翻硬币","en":"Flip Coin","cat":"button","desc":"点硬币抛向空中连续翻转数圈落下轻弹,底部影子随高度缩散,随机停在太阳或月亮面","desc_en":"Tapping tosses a 3D sun-and-moon coin into the air with a landing bounce while its shadow shrinks","needs":"js","play":"press","hint":"点一下抛起","hint_en":"Tap to flip","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/color.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"翻硬币按钮:120×150 舞台内带 500px 透视,居中 72×72 双面立体圆形硬币,正面太阳面读 --color-warning 暖金配柔光圆日,背面月亮面读 --color-primary 靛蓝配弯月,下方 54×10 模糊投影。点击后硬币向上抛高 58px 并沿 Y 轴连续翻转 4 至 7 个半圈(900ms),落地带 6px 轻弹,阴影同步缩至 0.5 倍、透明度 0.4 再恢复(820ms)。按下缩至 0.92,颜色读 --color-warning / --color-primary,减少动效直接翻面。","prompt_en":"Flip coin button: 120x150 stage with 500px perspective, a 72x72 two-sided 3D coin (sun face tinted with --color-warning, moon face tinted with --color-primary), and a 54x10 blurred ground shadow. Clicking tosses it 58px high across 4 to 7 half-turns over 900ms with a 6px landing bounce while the shadow shrinks to .5 scale and .4 opacity (820ms). Pressing scales to .92. Reads --color-warning / --color-primary; reduced motion flips 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
|
+
/* 翻硬币:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/color.html(#flip-coin):保留 500px 透视、72px 双面硬币、58px 抛高 900ms 落地轻弹与 820ms 影子缩放,日月面改由设计变量混色并增按压反馈。
|
|
18
|
+
读 --color-warning / --color-primary */
|
|
19
|
+
.c-um-coin{--co-sun:color-mix(in srgb,var(--color-warning,#ffb340) 88%,#d97706);--co-moon:color-mix(in srgb,var(--color-primary,#0a84ff) 46%,#6366f1);--co-sp:cubic-bezier(.3,1.45,.5,1);position:relative;display:grid;place-items:center;width:120px;height:150px;perspective:500px;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent}
|
|
20
|
+
.c-um-coin .co-btn{position:relative;width:72px;height:72px;padding:0;border:0;border-radius:50%;background:none;transform-style:preserve-3d;cursor:pointer;transition:scale .18s var(--co-sp)}
|
|
21
|
+
.c-um-coin .co-btn:active{scale:.92;transition-duration:.1s}
|
|
22
|
+
.c-um-coin .co-btn:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:6px}
|
|
23
|
+
.c-um-coin .co-face{position:absolute;inset:0;display:grid;place-items:center;border-radius:50%;backface-visibility:hidden;box-shadow:inset 0 1px 1px rgba(255,255,255,.38),inset 0 0 0 4px rgba(0,0,0,.08),inset 0 -5px 10px rgba(0,0,0,.14)}
|
|
24
|
+
.c-um-coin .co-sun{background:var(--co-sun)}
|
|
25
|
+
.c-um-coin .co-moon{background:var(--co-moon);transform:rotateY(180deg)}
|
|
26
|
+
.c-um-coin .co-sun::before{content:"";width:26px;height:26px;border-radius:50%;background:#fff;opacity:.92;box-shadow:0 0 0 5px rgba(255,255,255,.26)}
|
|
27
|
+
.c-um-coin .co-moon::before{content:"";width:28px;height:28px;border-radius:50%;box-shadow:inset -8px 4px 0 0 #fff;opacity:.92;rotate:-20deg}
|
|
28
|
+
.c-um-coin .co-shadow{position:absolute;bottom:14px;width:54px;height:10px;border-radius:50%;background:rgba(0,0,0,.22);filter:blur(2px);pointer-events:none}
|
|
29
|
+
@media (prefers-reduced-motion:reduce){.c-um-coin *{transition-duration:0s!important}}
|
|
30
|
+
</style>
|
|
31
|
+
</head>
|
|
32
|
+
<body>
|
|
33
|
+
<div class="stage-fit">
|
|
34
|
+
<div class="c-um-coin" data-comp="um-coin" data-side="sun" data-flips="0">
|
|
35
|
+
<span class="co-shadow" aria-hidden="true"></span>
|
|
36
|
+
<button class="co-btn" type="button" aria-label="翻硬币,当前太阳面"><span class="co-face co-sun"></span><span class="co-face co-moon"></span></button>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
<script data-comp>
|
|
40
|
+
/* 翻硬币逻辑:点击随机抛起 4–7 个半圈并在 900ms 落地轻弹,投影同步缩放 */
|
|
41
|
+
(() => {
|
|
42
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
43
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
44
|
+
document.querySelectorAll('.c-um-coin').forEach((el) => {
|
|
45
|
+
const coin = el.querySelector('.co-btn'), shadow = el.querySelector('.co-shadow')
|
|
46
|
+
let side = 0, flips = 0, busy = false, aCoin = null, aSh = null
|
|
47
|
+
const apply = (s) => {
|
|
48
|
+
side = s
|
|
49
|
+
coin.style.transform = `rotateY(${side * 180}deg)`
|
|
50
|
+
el.dataset.side = side ? 'moon' : 'sun'
|
|
51
|
+
coin.setAttribute('aria-label', side ? '翻硬币,当前月亮面' : '翻硬币,当前太阳面')
|
|
52
|
+
}
|
|
53
|
+
const toss = (forced) => {
|
|
54
|
+
if (busy) return
|
|
55
|
+
const next = forced === 0 || forced === 1 ? forced : (Math.random() < .5 ? 0 : 1)
|
|
56
|
+
const turns = 4 + next - side + (Math.random() < .5 ? 2 : 0)
|
|
57
|
+
const from = side * 180, to = from + turns * 180
|
|
58
|
+
flips += 1; el.dataset.flips = String(flips)
|
|
59
|
+
side = next; el.dataset.side = side ? 'moon' : 'sun'
|
|
60
|
+
coin.setAttribute('aria-label', side ? '翻硬币,当前月亮面' : '翻硬币,当前太阳面')
|
|
61
|
+
if (!ok()) return apply(side)
|
|
62
|
+
busy = true
|
|
63
|
+
aCoin = coin.animate([
|
|
64
|
+
{ transform: `translateY(0) rotateY(${from}deg)` },
|
|
65
|
+
{ transform: `translateY(-58px) rotateY(${(from + to) / 2}deg)`, easing: 'cubic-bezier(.2,.6,.4,1)' },
|
|
66
|
+
{ transform: `translateY(0) rotateY(${to}deg)`, easing: 'cubic-bezier(.6,0,.8,.4)' },
|
|
67
|
+
{ transform: `translateY(-6px) rotateY(${to}deg)`, offset: .9 },
|
|
68
|
+
{ transform: `translateY(0) rotateY(${to}deg)` },
|
|
69
|
+
], { duration: 900, fill: 'forwards' })
|
|
70
|
+
aSh = shadow.animate([{ scale: '1', opacity: 1 }, { scale: '.5', opacity: .4 }, { scale: '1', opacity: 1 }], { duration: 820 })
|
|
71
|
+
aCoin.onfinish = () => { coin.style.transform = `rotateY(${to % 360}deg)`; aCoin.cancel(); busy = false }
|
|
72
|
+
}
|
|
73
|
+
el.coSet = (s) => { aCoin?.cancel(); aSh?.cancel(); busy = false; apply(s) }
|
|
74
|
+
el.coFlip = toss
|
|
75
|
+
el.coStop = () => { aCoin?.cancel(); aSh?.cancel(); busy = false; apply(side) }
|
|
76
|
+
coin.addEventListener('click', () => toss())
|
|
77
|
+
apply(0)
|
|
78
|
+
})
|
|
79
|
+
})()
|
|
80
|
+
</script>
|
|
81
|
+
<script data-stage>
|
|
82
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
83
|
+
(() => {
|
|
84
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
85
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
86
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
87
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
88
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
89
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
90
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
91
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
92
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
93
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
94
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
95
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
96
|
+
// ===== 只改这一段 =====
|
|
97
|
+
const DEMO = {
|
|
98
|
+
settle () { el.coSet(0) },
|
|
99
|
+
loop (later) {
|
|
100
|
+
later(() => el.coFlip(1), 650)
|
|
101
|
+
later(() => el.coFlip(0), 2350)
|
|
102
|
+
later(() => DEMO.loop(later), 3800)
|
|
103
|
+
},
|
|
104
|
+
stop () { el.coStop() },
|
|
105
|
+
}
|
|
106
|
+
// =====================
|
|
107
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
108
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
109
|
+
addEventListener('message', (e) => {
|
|
110
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
111
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
112
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
113
|
+
})
|
|
114
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
115
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
116
|
+
})()
|
|
117
|
+
</script>
|
|
118
|
+
</body>
|
|
119
|
+
</html>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>色环取色</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"um-hue","zh":"色环取色","en":"Hue Orbit","cat":"slider","desc":"绕 12 枚色点滑动选色,选中色点放大并亮出描边环,中心主色球随之回弹变色","desc_en":"Drag around twelve color swatches; the active dot pops with a ring and pulses the glowing core","needs":"js","play":"drag","hint":"绕圈拖取色","hint_en":"Circle to pick","source":{"name":"UI Moments","url":"https://github.com/guanmo-ai/ui-moments/blob/main/gallery/originals/color.html","license":"MIT","author":"2026 guanmo-ai"},"prompt":"色环取色器:150×150 圆形色环,外圈半径 62px 等距排布 12 枚 16px 色点(每 30° 一档,oklch(.72 .15 var(--h))),中央 70×70 色球自带同色柔光阴影。按住拖转或方向键切换色相时按 30° 吸附,按压态色球轻缩至 0.96,当前色点弹簧放大至 1.45 倍并套双层外环,换色瞬间中央色球弹跳(1.12 回 1,320ms)。外环底色读 --color-bg / --color-surface 兜底,减少动效直接切色。","prompt_en":"Hue orbit picker: 150x150 circular slider with twelve 16px OKLCH swatches spaced every 30 deg on a 62px orbit around a 70x70 glowing core. Dragging or arrow keys snap in 30 deg steps; pressing scales the core to .96, the active swatch springs to 1.45x with a double halo, and each step pulses the core to 1.12 (320ms). Halo cutout reads --color-bg / --color-surface; reduced motion snaps."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 色环取色:改写自 UI Moments(MIT,© 2026 guanmo-ai,https://github.com/guanmo-ai/ui-moments)的 gallery/originals/color.html(#hue-orbit):保留 150×150 尺寸、12 枚 30° OKLCH 色点、1.45× 选中外环与 320ms 核心弹跳,外环改读舞台背景变量并预渲染静态节点。
|
|
18
|
+
读 --color-bg / --color-surface / --color-primary */
|
|
19
|
+
.c-um-hue{--hu-sp:cubic-bezier(.3,1.45,.5,1);--hue:270;position:relative;width:150px;height:150px;border-radius:50%;cursor:grab;touch-action:none;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent}
|
|
20
|
+
.c-um-hue[data-drag]{cursor:grabbing}
|
|
21
|
+
.c-um-hue[data-drag] .hu-core{scale:.96}
|
|
22
|
+
.c-um-hue:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:6px}
|
|
23
|
+
.c-um-hue i{position:absolute;top:50%;left:50%;width:16px;height:16px;margin:-8px;border-radius:50%;background:oklch(.72 .15 var(--h));transform:rotate(var(--h)) translateY(-62px) scale(var(--s,1));transition:transform .35s var(--hu-sp),box-shadow .3s;pointer-events:none}
|
|
24
|
+
.c-um-hue i[data-on]{--s:1.45;box-shadow:0 0 0 3px var(--color-bg,var(--color-surface,#fff)),0 0 0 4.5px oklch(.72 .15 var(--h))}
|
|
25
|
+
.c-um-hue .hu-core{position:absolute;inset:40px;border-radius:50%;background:oklch(.72 .15 var(--hue));box-shadow:inset 0 1px 1px rgba(255,255,255,.35),0 10px 28px -6px oklch(.6 .17 var(--hue)/.65);transition:background .25s,box-shadow .25s,scale .13s cubic-bezier(.2,.9,.34,1.16);pointer-events:none}
|
|
26
|
+
@media (prefers-reduced-motion:reduce){.c-um-hue *{transition-duration:0s!important}}
|
|
27
|
+
</style>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<div class="stage-fit">
|
|
31
|
+
<div class="c-um-hue" data-comp="um-hue" role="slider" tabindex="0" aria-label="色环取色" aria-valuemin="0" aria-valuemax="330" aria-valuenow="270" aria-valuetext="色相 270 度" style="--hue:270">
|
|
32
|
+
<i style="--h:0deg"></i>
|
|
33
|
+
<i style="--h:30deg"></i>
|
|
34
|
+
<i style="--h:60deg"></i>
|
|
35
|
+
<i style="--h:90deg"></i>
|
|
36
|
+
<i style="--h:120deg"></i>
|
|
37
|
+
<i style="--h:150deg"></i>
|
|
38
|
+
<i style="--h:180deg"></i>
|
|
39
|
+
<i style="--h:210deg"></i>
|
|
40
|
+
<i style="--h:240deg"></i>
|
|
41
|
+
<i style="--h:270deg" data-on></i>
|
|
42
|
+
<i style="--h:300deg"></i>
|
|
43
|
+
<i style="--h:330deg"></i>
|
|
44
|
+
<span class="hu-core" aria-hidden="true"></span>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
<script data-comp>
|
|
48
|
+
/* 色环取色逻辑:按指针相对圆心角度按 30° 吸附选色,支持方向键微调 */
|
|
49
|
+
(() => {
|
|
50
|
+
const rm = matchMedia('(prefers-reduced-motion: reduce)')
|
|
51
|
+
const ok = () => !rm.matches && !document.documentElement.classList.contains('paused')
|
|
52
|
+
document.querySelectorAll('.c-um-hue').forEach((el) => {
|
|
53
|
+
const core = el.querySelector('.hu-core'), dots = [...el.querySelectorAll('i')]
|
|
54
|
+
let hue = 270, active = false, pop = null
|
|
55
|
+
const set = (next, pulse = true) => {
|
|
56
|
+
next = ((Math.round(next / 30) * 30) % 360 + 360) % 360
|
|
57
|
+
const ch = next !== hue
|
|
58
|
+
hue = next
|
|
59
|
+
el.style.setProperty('--hue', hue)
|
|
60
|
+
el.dataset.hue = String(hue)
|
|
61
|
+
el.setAttribute('aria-valuenow', hue)
|
|
62
|
+
el.setAttribute('aria-valuetext', `色相 ${hue} 度`)
|
|
63
|
+
dots.forEach((d, i) => d.toggleAttribute('data-on', i * 30 === hue))
|
|
64
|
+
if (ch && pulse && ok()) {
|
|
65
|
+
pop?.cancel()
|
|
66
|
+
pop = core.animate([{ scale: '1' }, { scale: '1.12' }, { scale: '1' }], { duration: 320, easing: 'cubic-bezier(.3,1.5,.5,1)' })
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const pick = (e) => {
|
|
70
|
+
const r = el.getBoundingClientRect()
|
|
71
|
+
set(Math.atan2(e.clientX - (r.left + r.width / 2), -(e.clientY - (r.top + r.height / 2))) * 180 / Math.PI)
|
|
72
|
+
}
|
|
73
|
+
el.huSet = set
|
|
74
|
+
el.huStop = () => { pop?.cancel() }
|
|
75
|
+
el.addEventListener('pointerdown', (e) => {
|
|
76
|
+
if (e.button !== 0) return
|
|
77
|
+
active = true; el.dataset.drag = ''; el.setPointerCapture(e.pointerId); pick(e)
|
|
78
|
+
})
|
|
79
|
+
el.addEventListener('pointermove', (e) => { if (active) pick(e) })
|
|
80
|
+
const end = () => { active = false; delete el.dataset.drag }
|
|
81
|
+
el.addEventListener('pointerup', end); el.addEventListener('pointercancel', end)
|
|
82
|
+
el.addEventListener('keydown', (e) => {
|
|
83
|
+
const d = { ArrowRight: 30, ArrowUp: 30, ArrowLeft: -30, ArrowDown: -30 }[e.key]
|
|
84
|
+
if (d === undefined) return
|
|
85
|
+
e.preventDefault(); set(hue + d)
|
|
86
|
+
})
|
|
87
|
+
set(270, false)
|
|
88
|
+
})
|
|
89
|
+
})()
|
|
90
|
+
</script>
|
|
91
|
+
<script data-stage>
|
|
92
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
93
|
+
(() => {
|
|
94
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
95
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
96
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
97
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
98
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
99
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
100
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
101
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
102
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
103
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
104
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
105
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
106
|
+
// ===== 只改这一段 =====
|
|
107
|
+
const seq = [330, 30, 150, 210, 270]; let k = 0
|
|
108
|
+
const DEMO = {
|
|
109
|
+
settle () { el.huSet(270, false) },
|
|
110
|
+
loop (later) {
|
|
111
|
+
later(() => { el.huSet(seq[k++ % seq.length], true); DEMO.loop(later) }, 1050)
|
|
112
|
+
},
|
|
113
|
+
stop () { el.huStop() },
|
|
114
|
+
}
|
|
115
|
+
// =====================
|
|
116
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
117
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
118
|
+
addEventListener('message', (e) => {
|
|
119
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
120
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
121
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
122
|
+
})
|
|
123
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
124
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
125
|
+
})()
|
|
126
|
+
</script>
|
|
127
|
+
</body>
|
|
128
|
+
</html>
|