dsh-design-studio 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -1
- package/README.md +2 -1
- package/THIRD_PARTY_NOTICES.md +319 -0
- package/assets/demo.gif +0 -0
- package/assets/hero-sm.jpg +0 -0
- package/assets/motion/ai-capsule.html +4 -2
- package/assets/motion/ai-glow-input.html +4 -2
- package/assets/motion/app-fab.html +130 -0
- package/assets/motion/app-gallery.html +125 -0
- package/assets/motion/app-index.html +138 -0
- package/assets/motion/app-largetitle.html +138 -0
- package/assets/motion/app-onboard.html +141 -0
- package/assets/motion/app-player.html +152 -0
- package/assets/motion/app-popover.html +133 -0
- package/assets/motion/app-rings.html +143 -0
- package/assets/motion/app-searchhist.html +131 -0
- package/assets/motion/app-tabbar.html +148 -0
- package/assets/motion/app-tabs.html +150 -0
- package/assets/motion/app-video.html +136 -0
- package/assets/motion/balance-odometer.html +4 -2
- package/assets/motion/bottom-sheet.html +4 -2
- package/assets/motion/brightness-pill.html +4 -2
- package/assets/motion/chart-area.html +111 -0
- package/assets/motion/chart-bar.html +100 -0
- package/assets/motion/chart-donut.html +145 -0
- package/assets/motion/chart-funnel.html +120 -0
- package/assets/motion/chart-gantt.html +140 -0
- package/assets/motion/chart-gauge.html +126 -0
- package/assets/motion/chart-heat.html +121 -0
- package/assets/motion/chart-kpi.html +110 -0
- package/assets/motion/chart-line.html +154 -0
- package/assets/motion/chart-radar.html +153 -0
- package/assets/motion/chart-rank.html +112 -0
- package/assets/motion/chart-stack.html +107 -0
- package/assets/motion/comet-ring.html +4 -2
- package/assets/motion/copy-morph.html +4 -2
- package/assets/motion/cube-grid.html +4 -2
- package/assets/motion/day-night.html +4 -2
- package/assets/motion/dial-knob.html +4 -2
- package/assets/motion/dock-magnify.html +4 -2
- package/assets/motion/download-ring.html +4 -2
- package/assets/motion/expand-card.html +4 -2
- package/assets/motion/flip-card.html +4 -2
- package/assets/motion/hold-pay.html +4 -2
- package/assets/motion/holo-card.html +4 -2
- package/assets/motion/keycap.html +4 -2
- package/assets/motion/like-jelly.html +4 -2
- package/assets/motion/liquid-progress.html +4 -2
- package/assets/motion/liquid-segment.html +4 -2
- package/assets/motion/live-capsule.html +4 -2
- package/assets/motion/m-actionsheet.html +84 -0
- package/assets/motion/m-address.html +113 -0
- package/assets/motion/m-buybar.html +122 -0
- package/assets/motion/m-calendar.html +135 -0
- package/assets/motion/m-capsule-nav.html +97 -0
- package/assets/motion/m-cart.html +162 -0
- package/assets/motion/m-category.html +154 -0
- package/assets/motion/m-chat.html +125 -0
- package/assets/motion/m-coupon.html +84 -0
- package/assets/motion/m-dialog.html +102 -0
- package/assets/motion/m-empty.html +121 -0
- package/assets/motion/m-filter.html +171 -0
- package/assets/motion/m-goods.html +151 -0
- package/assets/motion/m-grid.html +98 -0
- package/assets/motion/m-login.html +127 -0
- package/assets/motion/m-msglist.html +88 -0
- package/assets/motion/m-order.html +111 -0
- package/assets/motion/m-profile.html +110 -0
- package/assets/motion/m-pull.html +199 -0
- package/assets/motion/m-settings.html +81 -0
- package/assets/motion/m-sku.html +114 -0
- package/assets/motion/m-swiper.html +163 -0
- package/assets/motion/m-timeline.html +109 -0
- package/assets/motion/m-wheel.html +182 -0
- package/assets/motion/marker-highlight.html +4 -2
- package/assets/motion/marquee-logos.html +4 -2
- package/assets/motion/mp-cartbar.html +158 -0
- package/assets/motion/mp-checkin.html +121 -0
- package/assets/motion/mp-form.html +128 -0
- package/assets/motion/mp-group.html +148 -0
- package/assets/motion/mp-invite.html +119 -0
- package/assets/motion/mp-points.html +143 -0
- package/assets/motion/mp-queue.html +136 -0
- package/assets/motion/mp-rate.html +166 -0
- package/assets/motion/mp-seckill.html +140 -0
- package/assets/motion/mp-store.html +137 -0
- package/assets/motion/mp-vip.html +126 -0
- package/assets/motion/mp-wizard.html +174 -0
- package/assets/motion/otp-code.html +7 -4
- package/assets/motion/password-eye.html +4 -2
- package/assets/motion/ruler-slider.html +4 -2
- package/assets/motion/search-expand.html +4 -2
- package/assets/motion/send-fly.html +4 -2
- package/assets/motion/skeleton-shine.html +4 -2
- package/assets/motion/star-rate.html +4 -2
- package/assets/motion/success-check.html +4 -2
- package/assets/motion/suggest-chips.html +4 -2
- package/assets/motion/swipe-row.html +4 -2
- package/assets/motion/tabbar-bounce.html +4 -2
- package/assets/motion/tactile-controls.html +4 -2
- package/assets/motion/text-scramble.html +4 -2
- package/assets/motion/toast-stack.html +4 -2
- package/assets/motion/token-stream.html +4 -2
- package/assets/motion/um-bell.html +106 -0
- package/assets/motion/um-chips.html +132 -0
- package/assets/motion/um-coin.html +119 -0
- package/assets/motion/um-hue.html +128 -0
- package/assets/motion/um-ink-switch.html +129 -0
- package/assets/motion/um-leaf-tabs.html +138 -0
- package/assets/motion/um-plan.html +110 -0
- package/assets/motion/um-radial.html +104 -0
- package/assets/motion/um-stroke-check.html +86 -0
- package/assets/motion/um-swipe-confirm.html +182 -0
- package/assets/motion/um-tide.html +180 -0
- package/assets/motion/voice-orb.html +4 -2
- package/assets/motion/web-404.html +95 -0
- package/assets/motion/web-cmdk.html +167 -0
- package/assets/motion/web-dropdown.html +94 -0
- package/assets/motion/web-faq.html +84 -0
- package/assets/motion/web-footer.html +109 -0
- package/assets/motion/web-hero.html +98 -0
- package/assets/motion/web-navbar.html +149 -0
- package/assets/motion/web-newsletter.html +124 -0
- package/assets/motion/web-pagination.html +132 -0
- package/assets/motion/web-pricing.html +110 -0
- package/assets/motion/web-testimonial.html +129 -0
- package/assets/motion/web-upload.html +160 -0
- package/lib/client.js +76 -17
- package/lib/index.js +6 -2
- package/lib/motion.js +11 -2
- package/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
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":"chart-gantt","zh":"进度甘特","en":"Gantt Chart","cat":"chart","desc":"四周发版排期甘特条配今日标线,划过看工期与进度,点任务条推进完成度","desc_en":"Four-week Gantt schedule with today marker; hover for duration and tap a bar to advance progress","needs":"js","play":"press","hint":"划过或点条","hint_en":"Hover or tap bar","source":null,"prompt":"进度甘特图:宽 296px 高 168px、圆角 16px 的 --color-surface 卡片。顶部标题配右上动态工期胶囊,时间轴分 4 周竖向网格并叠一条 --color-danger 虚线表示今日。下方 4 行错落排布需求、设计、开发、上线任务条,四色读 --color-success / --color-primary / --color-warning 与主色混紫,条内以深浅叠层表达完成比例。划过任务条弹出工期进度气泡并更新顶栏,点击任务条可平滑推进完成度。","prompt_en":"Project Gantt chart, 296x168 --color-surface card with 16px radius. Header pairs title with a live schedule pill above a 4-week grid and a dashed --color-danger today line. Four staggered task bars read --color-success, --color-primary, --color-warning, and a primary-violet mix with inner completion fills. Hovering pops duration and progress tooltips; tapping a bar smoothly advances its completion."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 进度甘特 四周排期条与点击推进完成度。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success / --color-warning / --color-danger */
|
|
18
|
+
.c-chart-gantt{box-sizing:border-box;width:296px;height:168px;padding:11px 14px 10px;border-radius:16px;display:flex;flex-direction:column;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(20,20,19,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.28);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
19
|
+
.c-chart-gantt .gt-hd{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px}
|
|
20
|
+
.c-chart-gantt .gt-hd b{font-size:13px;font-weight:600}
|
|
21
|
+
.c-chart-gantt .gt-pill{padding:2px 7px;border-radius:99px;font-size:10px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--color-muted,#76756f);background:color-mix(in srgb,var(--color-text,#141413) 7%,transparent);transition:background-color .16s,color .16s}
|
|
22
|
+
.c-chart-gantt.is-hi .gt-pill{background:var(--color-text,#141413);color:var(--color-surface,#fff)}
|
|
23
|
+
.c-chart-gantt .gt-wks{display:grid;grid-template-columns:repeat(4,1fr);margin-left:38px;margin-bottom:4px;font-size:9.5px;color:var(--color-muted,#76756f);text-align:center}
|
|
24
|
+
.c-chart-gantt .gt-body{position:relative;flex:1;display:flex;flex-direction:column;justify-content:space-between}
|
|
25
|
+
.c-chart-gantt .gt-grid{position:absolute;left:38px;right:0;top:0;bottom:0;display:grid;grid-template-columns:repeat(4,1fr);pointer-events:none}
|
|
26
|
+
.c-chart-gantt .gt-grid i{border-left:1px dashed var(--color-line,rgba(20,20,19,.1))}
|
|
27
|
+
.c-chart-gantt .gt-today{position:absolute;top:-2px;bottom:-2px;left:calc(38px + (100% - 38px) * .56);width:1.5px;background:var(--color-danger,#ff375f);opacity:.78;pointer-events:none;z-index:2}
|
|
28
|
+
.c-chart-gantt .gt-today::before{content:"";position:absolute;top:-2px;left:-2.5px;width:6.5px;height:6.5px;border-radius:50%;background:var(--color-danger,#ff375f)}
|
|
29
|
+
.c-chart-gantt .gt-row{position:relative;display:flex;align-items:center;height:23px;z-index:1}
|
|
30
|
+
.c-chart-gantt .gt-row.is-on,.c-chart-gantt .gt-row:hover{z-index:5}
|
|
31
|
+
.c-chart-gantt .gt-lb{flex:none;width:38px;font-size:11px;font-weight:500;color:var(--color-muted,#76756f);transition:color .15s}
|
|
32
|
+
.c-chart-gantt .gt-row.is-on .gt-lb{color:var(--color-text,#141413);font-weight:600}
|
|
33
|
+
.c-chart-gantt .gt-lane{position:relative;flex:1;height:18px}
|
|
34
|
+
.c-chart-gantt .gt-bar{position:absolute;top:0;height:18px;border:0;padding:0;border-radius:6px;background:color-mix(in srgb,var(--gc) 24%,var(--color-surface,#fff));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--gc) 44%,transparent);cursor:pointer;display:flex;align-items:center;justify-content:flex-end;transition:transform .26s cubic-bezier(.3,1.35,.5,1),box-shadow .16s}
|
|
35
|
+
.c-chart-gantt .gt-row.is-on .gt-bar,.c-chart-gantt .gt-bar:hover{transform:translateY(-1.5px);box-shadow:inset 0 0 0 1.2px var(--gc),0 4px 10px -3px color-mix(in srgb,var(--gc) 60%,transparent);z-index:4}
|
|
36
|
+
.c-chart-gantt .gt-bar:active{transform:scale(.96)}
|
|
37
|
+
.c-chart-gantt .gt-bar:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
|
|
38
|
+
.c-chart-gantt .gt-fill{position:absolute;inset:0;border-radius:5px;background:var(--gc);transform-origin:left;transform:scaleX(var(--gp));transition:transform .42s cubic-bezier(.3,1.3,.5,1);pointer-events:none}
|
|
39
|
+
.c-chart-gantt .gt-pct{position:relative;z-index:1;padding-right:5px;font-size:9.5px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--color-text,#141413);pointer-events:none}
|
|
40
|
+
.c-chart-gantt .gt-bar.is-darktxt .gt-pct{color:#fff;text-shadow:0 1px 2px rgba(0,0,0,.22)}
|
|
41
|
+
.c-chart-gantt .gt-tip{position:absolute;left:50%;bottom:calc(100% + 5px);padding:2.5px 6px;border-radius:6px;font-style:normal;white-space:nowrap;font-size:9.5px;font-weight:600;line-height:1.25;font-variant-numeric:tabular-nums;background:var(--color-text,#141413);color:var(--color-surface,#fff);box-shadow:0 4px 10px -2px rgba(0,0,0,.24);visibility:hidden;opacity:0;transform:translate(-50%,3px);transition:opacity .14s,transform .18s,visibility .14s;pointer-events:none;z-index:6}
|
|
42
|
+
.c-chart-gantt .gt-dn .gt-tip{bottom:auto;top:calc(100% + 5px)}
|
|
43
|
+
.c-chart-gantt .gt-l .gt-tip{left:0;transform:translate(0,-3px)}
|
|
44
|
+
.c-chart-gantt .gt-r .gt-tip{left:auto;right:0;transform:translate(0,3px)}
|
|
45
|
+
.c-chart-gantt .gt-row.is-on .gt-tip,.c-chart-gantt .gt-bar:hover .gt-tip{visibility:visible;opacity:1;transform:translate(-50%,0)}
|
|
46
|
+
.c-chart-gantt .gt-l.is-on .gt-tip,.c-chart-gantt .gt-l .gt-bar:hover .gt-tip,.c-chart-gantt .gt-r.is-on .gt-tip,.c-chart-gantt .gt-r .gt-bar:hover .gt-tip{transform:translate(0,0)}
|
|
47
|
+
@media (prefers-reduced-motion:reduce){.c-chart-gantt *{transition:none!important}}
|
|
48
|
+
</style>
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
<div class="stage-fit">
|
|
52
|
+
<div class="c-chart-gantt" data-comp="chart-gantt">
|
|
53
|
+
<div class="gt-hd"><b>发版排期</b><span class="gt-pill">第3周 进行中</span></div>
|
|
54
|
+
<div class="gt-wks"><span>第1周</span><span>第2周</span><span>第3周</span><span>第4周</span></div>
|
|
55
|
+
<div class="gt-body" aria-label="四周发版任务甘特图">
|
|
56
|
+
<div class="gt-grid" aria-hidden="true"><i></i><i></i><i></i><i></i></div>
|
|
57
|
+
<i class="gt-today" aria-hidden="true"></i>
|
|
58
|
+
<div class="gt-row gt-dn gt-l" data-i="0"><span class="gt-lb">需求</span><div class="gt-lane"><button class="gt-bar is-darktxt" type="button" data-i="0" style="left:0%;width:30%;--gc:var(--color-success,#30b35a);--gp:1.00" aria-label="需求进度 100%"><i class="gt-fill"></i><span class="gt-pct">100%</span><em class="gt-tip">需求 第1到2周 3天 100%</em></button></div></div>
|
|
59
|
+
<div class="gt-row" data-i="1"><span class="gt-lb">设计</span><div class="gt-lane"><button class="gt-bar is-darktxt" type="button" data-i="1" style="left:20%;width:36%;--gc:var(--color-primary,#0a84ff);--gp:1.00" aria-label="设计进度 100%"><i class="gt-fill"></i><span class="gt-pct">100%</span><em class="gt-tip">设计 第1到3周 4天 100%</em></button></div></div>
|
|
60
|
+
<div class="gt-row" data-i="2"><span class="gt-lb">开发</span><div class="gt-lane"><button class="gt-bar" type="button" data-i="2" style="left:42%;width:40%;--gc:var(--color-warning,#ffb340);--gp:0.65" aria-label="开发进度 65%"><i class="gt-fill"></i><span class="gt-pct">65%</span><em class="gt-tip">开发 第2到4周 5天 65%</em></button></div></div>
|
|
61
|
+
<div class="gt-row gt-r" data-i="3"><span class="gt-lb">上线</span><div class="gt-lane"><button class="gt-bar" type="button" data-i="3" style="left:72%;width:28%;--gc:color-mix(in srgb,var(--color-primary,#0a84ff) 46%,#a855f7);--gp:0.00" aria-label="上线进度 0%"><i class="gt-fill"></i><span class="gt-pct">0%</span><em class="gt-tip">上线 第3到4周 3天 0%</em></button></div></div>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<script data-comp>
|
|
66
|
+
/* 进度甘特:划过任务条显示工期与完成度并同步顶栏;点击任务条按档位推进完成度 */
|
|
67
|
+
(() => {
|
|
68
|
+
const M = [['需求', '第1到2周', '3天', 100], ['设计', '第1到3周', '4天', 100], ['开发', '第2到4周', '5天', 65], ['上线', '第3到4周', '3天', 0]]
|
|
69
|
+
document.querySelectorAll('.c-chart-gantt').forEach((el) => {
|
|
70
|
+
const rows = [...el.querySelectorAll('.gt-row')]
|
|
71
|
+
const bars = [...el.querySelectorAll('.gt-bar')]
|
|
72
|
+
const pill = el.querySelector('.gt-pill')
|
|
73
|
+
const P = M.map((m) => m[3])
|
|
74
|
+
const paint = (i) => {
|
|
75
|
+
const p = P[i]; const b = bars[i]
|
|
76
|
+
b.style.setProperty('--gp', (p / 100).toFixed(2))
|
|
77
|
+
b.classList.toggle('is-darktxt', p >= 70)
|
|
78
|
+
b.querySelector('.gt-pct').textContent = p + '%'
|
|
79
|
+
b.querySelector('.gt-tip').textContent = M[i][0] + ' ' + M[i][1] + ' ' + M[i][2] + ' ' + p + '%'
|
|
80
|
+
}
|
|
81
|
+
const focus = (i) => {
|
|
82
|
+
const on = i >= 0
|
|
83
|
+
el.classList.toggle('is-hi', on)
|
|
84
|
+
el.dataset.idx = on ? String(i) : ''
|
|
85
|
+
rows.forEach((r, k) => r.classList.toggle('is-on', k === i))
|
|
86
|
+
pill.textContent = on ? M[i][0] + ' ' + M[i][2] + ' ' + P[i] + '%' : '第3周 进行中'
|
|
87
|
+
}
|
|
88
|
+
const step = (i) => { P[i] = P[i] >= 100 ? 35 : (P[i] < 50 ? 50 : 100); paint(i); focus(i) }
|
|
89
|
+
bars.forEach((b, i) => {
|
|
90
|
+
paint(i)
|
|
91
|
+
b.addEventListener('pointerenter', () => focus(i))
|
|
92
|
+
b.addEventListener('pointerleave', () => focus(-1))
|
|
93
|
+
b.addEventListener('click', () => step(i))
|
|
94
|
+
})
|
|
95
|
+
el.gtReset = () => { M.forEach((m, i) => { P[i] = m[3]; paint(i) }); focus(-1) }
|
|
96
|
+
el.gtFocus = focus; el.gtStep = step
|
|
97
|
+
})
|
|
98
|
+
})()
|
|
99
|
+
</script>
|
|
100
|
+
<script data-stage>
|
|
101
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
102
|
+
(() => {
|
|
103
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
104
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
105
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
106
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
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)
|
|
111
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
112
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
113
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
114
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
115
|
+
// ===== 只改这一段 =====
|
|
116
|
+
const DEMO = {
|
|
117
|
+
settle () { el.gtReset() },
|
|
118
|
+
loop (later) {
|
|
119
|
+
later(() => el.gtFocus(1), 400)
|
|
120
|
+
later(() => el.gtStep(2), 1850)
|
|
121
|
+
later(() => el.gtStep(3), 3250)
|
|
122
|
+
later(() => el.gtReset(), 4250)
|
|
123
|
+
later(() => DEMO.loop(later), 4950)
|
|
124
|
+
},
|
|
125
|
+
stop () { el.gtFocus(-1) },
|
|
126
|
+
}
|
|
127
|
+
// =====================
|
|
128
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
129
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
130
|
+
addEventListener('message', (e) => {
|
|
131
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
132
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
133
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
134
|
+
})
|
|
135
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
136
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
137
|
+
})()
|
|
138
|
+
</script>
|
|
139
|
+
</body>
|
|
140
|
+
</html>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>仪表盘</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"chart-gauge","zh":"仪表盘","en":"Speed Gauge","cat":"chart","desc":"三色阈值半圆仪表盘,划过表盘指针实时跟手偏转,状态与数值联动","desc_en":"Three-zone semi-circle gauge; hovering sweeps the needle and updates the live readout","needs":"js","play":"hover","hint":"划过表盘","hint_en":"Hover gauge","source":null,"prompt":"半圆仪表盘:宽 296px 高 168px、圆角 16px 的 --color-surface 卡片。顶部标题与状态徽章,主体为 220×118 内联 SVG 半圆弧,按安全(--color-success)、偏高(--color-warning)、告警(--color-danger)三段留隙描边,内圈排 21 道刻度线,中心配弹簧回弹指针,下方清朗排布百分比与响应耗时。鼠标划过表盘实时联动指针、读数和状态色,移开后平稳回到 74%。","prompt_en":"Semi-circle gauge, 296x168 --color-surface card with 16px radius. Header pairs title with a status pill above a 220x118 inline SVG split into three clearly gapped threshold arcs (--color-success, --color-warning, --color-danger), 21 ticks, and a spring-damped needle, with percentage and latency neatly below the pivot. Hovering scrubs needle and readout live; leaving returns to 74%."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 仪表盘 三段阈值半圆弧与实时跟手指针。读 --color-surface / --color-text / --color-muted / --color-line / --color-success / --color-warning / --color-danger */
|
|
18
|
+
.c-chart-gauge{--gg-ang:43.2deg;--gg-c:var(--color-warning,#ffb340);box-sizing:border-box;width:296px;height:168px;padding:11px 14px 9px;border-radius:16px;display:flex;flex-direction:column;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(20,20,19,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.28);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
19
|
+
.c-chart-gauge .cg-hd{display:flex;align-items:center;justify-content:space-between}
|
|
20
|
+
.c-chart-gauge .cg-hd b{font-size:13px;font-weight:600}
|
|
21
|
+
.c-chart-gauge .cg-st{padding:2px 8px;border-radius:99px;font-size:10.5px;font-weight:600;color:color-mix(in srgb,var(--gg-c) 82%,var(--color-text,#141413));background:color-mix(in srgb,var(--gg-c) 17%,transparent);transition:color .2s,background-color .2s}
|
|
22
|
+
.c-chart-gauge .cg-dial{position:relative;flex:1;display:flex;flex-direction:column;align-items:center;cursor:ew-resize}
|
|
23
|
+
.c-chart-gauge .cg-svg{width:220px;height:96px;overflow:visible;display:block;margin-top:2px}
|
|
24
|
+
.c-chart-gauge .cg-arc{fill:none;stroke-width:10.5;stroke-linecap:round}
|
|
25
|
+
.c-chart-gauge .cg-tk{stroke:color-mix(in srgb,var(--color-text,#141413) 18%,transparent);stroke-width:1.1;stroke-linecap:round}
|
|
26
|
+
.c-chart-gauge .cg-tm{stroke:color-mix(in srgb,var(--color-text,#141413) 40%,transparent);stroke-width:1.6}
|
|
27
|
+
.c-chart-gauge .cg-ndl{transform-origin:110px 82px;transform:rotate(var(--gg-ang));transition:transform .38s cubic-bezier(.25,1.25,.45,1)}
|
|
28
|
+
.c-chart-gauge .cg-hub{fill:var(--color-surface,#fff);stroke:var(--gg-c);stroke-width:2.5;transition:stroke .2s}
|
|
29
|
+
.c-chart-gauge .cg-read{margin-top:1px;display:flex;align-items:baseline;gap:8px;pointer-events:none}
|
|
30
|
+
.c-chart-gauge .cg-num{font-size:21px;font-weight:700;line-height:1.05;font-variant-numeric:tabular-nums}
|
|
31
|
+
.c-chart-gauge .cg-sub{font-size:10.5px;color:var(--color-muted,#76756f);font-variant-numeric:tabular-nums}
|
|
32
|
+
.c-chart-gauge .cg-ends{position:absolute;top:76px;left:22px;right:22px;display:flex;justify-content:space-between;font-size:9.5px;color:var(--color-muted,#76756f);font-variant-numeric:tabular-nums;pointer-events:none}
|
|
33
|
+
@media (prefers-reduced-motion:reduce){.c-chart-gauge *{transition:none!important}}
|
|
34
|
+
</style>
|
|
35
|
+
</head>
|
|
36
|
+
<body>
|
|
37
|
+
<div class="stage-fit">
|
|
38
|
+
<div class="c-chart-gauge" data-comp="chart-gauge">
|
|
39
|
+
<div class="cg-hd"><b>服务负载</b><span class="cg-st">偏高</span></div>
|
|
40
|
+
<div class="cg-dial" aria-label="服务负载仪表盘">
|
|
41
|
+
<svg class="cg-svg" viewBox="0 0 220 96" aria-hidden="true">
|
|
42
|
+
<path class="cg-arc" stroke="var(--color-success,#30b35a)" d="M42.00,82.00 A68,68 0 0,1 119.46,14.66"/>
|
|
43
|
+
<path class="cg-arc" stroke="var(--color-warning,#ffb340)" d="M133.26,18.10 A68,68 0 0,1 167.67,45.97"/>
|
|
44
|
+
<path class="cg-arc" stroke="var(--color-danger,#ff375f)" d="M173.90,58.74 A68,68 0 0,1 178.00,82.00"/>
|
|
45
|
+
<line class="cg-tk cg-tm" x1="59.0" y1="82.0" x2="52.0" y2="82.0"/><line class="cg-tk" x1="56.7" y1="73.6" x2="52.7" y2="72.9"/><line class="cg-tk" x1="58.6" y1="65.3" x2="54.8" y2="64.1"/><line class="cg-tk" x1="61.9" y1="57.5" x2="58.3" y2="55.7"/><line class="cg-tk" x1="66.3" y1="50.3" x2="63.1" y2="47.9"/><line class="cg-tk cg-tm" x1="73.9" y1="45.9" x2="69.0" y2="41.0"/><line class="cg-tk" x1="78.3" y1="38.3" x2="75.9" y2="35.1"/><line class="cg-tk" x1="85.5" y1="33.9" x2="83.7" y2="30.3"/><line class="cg-tk" x1="93.3" y1="30.6" x2="92.1" y2="26.8"/><line class="cg-tk" x1="101.6" y1="28.7" x2="100.9" y2="24.7"/><line class="cg-tk cg-tm" x1="110.0" y1="31.0" x2="110.0" y2="24.0"/><line class="cg-tk" x1="118.4" y1="28.7" x2="119.1" y2="24.7"/><line class="cg-tk" x1="126.7" y1="30.6" x2="127.9" y2="26.8"/><line class="cg-tk" x1="134.5" y1="33.9" x2="136.3" y2="30.3"/><line class="cg-tk" x1="141.7" y1="38.3" x2="144.1" y2="35.1"/><line class="cg-tk cg-tm" x1="146.1" y1="45.9" x2="151.0" y2="41.0"/><line class="cg-tk" x1="153.7" y1="50.3" x2="156.9" y2="47.9"/><line class="cg-tk" x1="158.1" y1="57.5" x2="161.7" y2="55.7"/><line class="cg-tk" x1="161.4" y1="65.3" x2="165.2" y2="64.1"/><line class="cg-tk" x1="163.3" y1="73.6" x2="167.3" y2="72.9"/><line class="cg-tk cg-tm" x1="161.0" y1="82.0" x2="168.0" y2="82.0"/>
|
|
46
|
+
<g class="cg-ndl"><path d="M107.8 82 L110 26 L112.2 82 Z" fill="var(--color-text,#141413)"/></g>
|
|
47
|
+
<circle class="cg-hub" cx="110" cy="82" r="5.5"/>
|
|
48
|
+
</svg>
|
|
49
|
+
<div class="cg-ends"><span>0</span><span>100</span></div>
|
|
50
|
+
<div class="cg-read"><strong class="cg-num">74%</strong><span class="cg-sub">响应 58ms</span></div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
<script data-comp>
|
|
55
|
+
/* 仪表盘:划过表盘按横向/角度位置更新百分比、指针转角、响应耗时与阈值状态色 */
|
|
56
|
+
(() => {
|
|
57
|
+
const C_OK = 'var(--color-success,#30b35a)'
|
|
58
|
+
const C_WARN = 'var(--color-warning,#ffb340)'
|
|
59
|
+
const C_BAD = 'var(--color-danger,#ff375f)'
|
|
60
|
+
document.querySelectorAll('.c-chart-gauge').forEach((el) => {
|
|
61
|
+
const dial = el.querySelector('.cg-dial')
|
|
62
|
+
const st = el.querySelector('.cg-st')
|
|
63
|
+
const num = el.querySelector('.cg-num')
|
|
64
|
+
const sub = el.querySelector('.cg-sub')
|
|
65
|
+
const setVal = (v) => {
|
|
66
|
+
const p = Math.max(0, Math.min(100, Math.round(v)))
|
|
67
|
+
el.dataset.val = String(p)
|
|
68
|
+
el.style.setProperty('--gg-ang', (-90 + p * 1.8).toFixed(1) + 'deg')
|
|
69
|
+
const c = p < 60 ? C_OK : (p < 85 ? C_WARN : C_BAD)
|
|
70
|
+
el.style.setProperty('--gg-c', c)
|
|
71
|
+
st.textContent = p < 60 ? '正常' : (p < 85 ? '偏高' : '告警')
|
|
72
|
+
num.textContent = p + '%'
|
|
73
|
+
sub.textContent = '响应 ' + Math.round(18 + p * 0.54) + 'ms'
|
|
74
|
+
}
|
|
75
|
+
dial.addEventListener('pointermove', (e) => {
|
|
76
|
+
const r = dial.getBoundingClientRect()
|
|
77
|
+
const f = (e.clientX - r.left - 18) / Math.max(1, r.width - 36)
|
|
78
|
+
setVal(f * 100)
|
|
79
|
+
})
|
|
80
|
+
dial.addEventListener('pointerleave', () => setVal(74))
|
|
81
|
+
el.ggSet = setVal
|
|
82
|
+
setVal(74)
|
|
83
|
+
})
|
|
84
|
+
})()
|
|
85
|
+
</script>
|
|
86
|
+
<script data-stage>
|
|
87
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
88
|
+
(() => {
|
|
89
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
90
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
91
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
92
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
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)
|
|
97
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
98
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
99
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
100
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
101
|
+
// ===== 只改这一段 =====
|
|
102
|
+
const DEMO = {
|
|
103
|
+
settle () { el.ggSet(74) },
|
|
104
|
+
loop (later) {
|
|
105
|
+
later(() => el.ggSet(36), 500)
|
|
106
|
+
later(() => el.ggSet(91), 1550)
|
|
107
|
+
later(() => el.ggSet(54), 2650)
|
|
108
|
+
later(() => el.ggSet(74), 3600)
|
|
109
|
+
later(() => DEMO.loop(later), 4400)
|
|
110
|
+
},
|
|
111
|
+
stop () {},
|
|
112
|
+
}
|
|
113
|
+
// =====================
|
|
114
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
115
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
116
|
+
addEventListener('message', (e) => {
|
|
117
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
118
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
119
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
120
|
+
})
|
|
121
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
122
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
123
|
+
})()
|
|
124
|
+
</script>
|
|
125
|
+
</body>
|
|
126
|
+
</html>
|
|
@@ -0,0 +1,121 @@
|
|
|
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":"chart-heat","zh":"热力日历","en":"Heatmap Calendar","cat":"chart","desc":"十五周打卡热力方阵,五档色阶一目了然,划过格子浮出日期和次数","desc_en":"15-week activity calendar with five intensity steps; hover any cell for date and count","needs":"js","play":"hover","hint":"划过格子","hint_en":"Hover cells","source":null,"prompt":"热力日历:宽 296px 高 168px、圆角 16px 的 --color-surface 卡片。顶部标题与 5 档色阶图例(--color-success 按 0% 到 100% 混色,空档自动适配深浅色)。主体为 15 周 × 7 天共 105 枚 13×12 圆角方格,带月份与周几简标。划过任一格子时当前格放大 1.28 倍并加高亮描边,卡片内共享高对比浮卡自动贴边避让,显示具体日期与打卡次数。","prompt_en":"Activity heatmap calendar, 296x168 --color-surface card with 16px radius. Header pairs title with a 5-step --color-success intensity legend. Below sits a 15x7 grid of 105 rounded 13x12 cells with month and weekday labels. Hovering any cell pops it to 1.28x with a crisp ring and positions an edge-clamped high-contrast tooltip showing the exact date and count."}</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
|
+
/* 热力日历 15周打卡方阵与五档色阶浮卡。读 --color-surface / --color-text / --color-muted / --color-line / --color-success */
|
|
18
|
+
.c-chart-heat{box-sizing:border-box;width:296px;height:168px;padding:11px 14px 10px;border-radius:16px;display:flex;flex-direction:column;position:relative;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(20,20,19,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.28);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
19
|
+
.c-chart-heat .ch-hd{display:flex;align-items:center;justify-content:space-between;margin-bottom:5px}
|
|
20
|
+
.c-chart-heat .ch-hd b{font-size:13px;font-weight:600}
|
|
21
|
+
.c-chart-heat .ch-leg{display:flex;align-items:center;gap:3px;font-size:9.5px;color:var(--color-muted,#76756f)}
|
|
22
|
+
.c-chart-heat .ch-leg i{width:9px;height:9px;border-radius:2.5px;display:inline-block}
|
|
23
|
+
.c-chart-heat .ch-mos{display:flex;justify-content:space-between;padding:0 2px 3px 22px;font-size:9.5px;color:var(--color-muted,#76756f)}
|
|
24
|
+
.c-chart-heat .ch-wrap{position:relative;flex:1;display:flex;align-items:center;gap:6px}
|
|
25
|
+
.c-chart-heat .ch-wds{width:16px;height:102px;display:grid;grid-template-rows:repeat(7,12px);gap:3px;font-size:9px;line-height:12px;color:var(--color-muted,#76756f);text-align:right}
|
|
26
|
+
.c-chart-heat .ch-grid{position:relative;display:grid;grid-auto-flow:column;grid-template-columns:repeat(15,13px);grid-template-rows:repeat(7,12px);gap:3px}
|
|
27
|
+
.c-chart-heat .ch-grid i{width:13px;height:12px;border-radius:3px;cursor:pointer;transition:transform .22s linear(0,.07,.245,.475,.716,.931,1.1,1.212,1.267,1.272,1.239,1.184,1.118,1.054,.999,.958,.934,.925,.928,.94,.956,.975,.992,1.005,1.015,1.02,1.021,1.019,1.015,1.01,1.005,1.001,.997,.995,.994,.994,.995,.996,.998,.999,1),box-shadow .15s}
|
|
28
|
+
.c-chart-heat .ch-l0{background:color-mix(in srgb,var(--color-text,#141413) 8%,transparent)}
|
|
29
|
+
.c-chart-heat .ch-l1{background:color-mix(in srgb,var(--color-success,#30b35a) 26%,var(--color-surface,#fff))}
|
|
30
|
+
.c-chart-heat .ch-l2{background:color-mix(in srgb,var(--color-success,#30b35a) 50%,var(--color-surface,#fff))}
|
|
31
|
+
.c-chart-heat .ch-l3{background:color-mix(in srgb,var(--color-success,#30b35a) 76%,var(--color-surface,#fff))}
|
|
32
|
+
.c-chart-heat .ch-l4{background:var(--color-success,#30b35a)}
|
|
33
|
+
.c-chart-heat .ch-grid i.is-on{position:relative;z-index:3;transform:scale(1.28);box-shadow:0 0 0 1.5px var(--color-surface,#fff),0 0 0 3px var(--color-success,#30b35a)}
|
|
34
|
+
.c-chart-heat .ch-tip{position:absolute;left:140px;top:36px;padding:3px 7px;border-radius:6px;white-space:nowrap;font-size:10px;font-weight:600;line-height:1.25;font-variant-numeric:tabular-nums;background:var(--color-text,#141413);color:var(--color-surface,#fff);box-shadow:0 4px 10px -2px rgba(0,0,0,.24);visibility:hidden;opacity:0;transform:translate(-50%,3px);transition:opacity .14s,transform .18s,visibility .14s;pointer-events:none;z-index:5}
|
|
35
|
+
.c-chart-heat.is-on .ch-tip{visibility:visible;opacity:1;transform:translate(-50%,0)}
|
|
36
|
+
@media (prefers-reduced-motion:reduce){.c-chart-heat *{transition:none!important}}
|
|
37
|
+
</style>
|
|
38
|
+
</head>
|
|
39
|
+
<body>
|
|
40
|
+
<div class="stage-fit">
|
|
41
|
+
<div class="c-chart-heat" data-comp="chart-heat">
|
|
42
|
+
<div class="ch-hd"><b>打卡热力</b><div class="ch-leg"><span>少</span><i class="ch-l0"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l4"></i><span>多</span></div></div>
|
|
43
|
+
<div class="ch-mos"><span>9月</span><span>10月</span><span>11月</span><span>12月</span></div>
|
|
44
|
+
<div class="ch-wrap">
|
|
45
|
+
<div class="ch-wds"><span>一</span><span></span><span>三</span><span></span><span>五</span><span></span><span>日</span></div>
|
|
46
|
+
<div class="ch-grid" aria-label="近十五周每日活跃热力"><i class="ch-l0"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l1"></i><i class="ch-l0"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l0"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l4"></i><i class="ch-l3"></i><i class="ch-l4"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l0"></i><i class="ch-l0"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l3"></i><i class="ch-l4"></i><i class="ch-l3"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l3"></i><i class="ch-l4"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l0"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l3"></i><i class="ch-l4"></i><i class="ch-l4"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l3"></i><i class="ch-l4"></i><i class="ch-l3"></i><i class="ch-l1"></i><i class="ch-l0"></i><i class="ch-l2"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l1"></i><i class="ch-l2"></i><i class="ch-l3"></i><i class="ch-l4"></i><i class="ch-l3"></i><i class="ch-l2"></i><i class="ch-l1"></i></div>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="ch-tip">11月12日 14次</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<script data-comp>
|
|
52
|
+
/* 热力日历:划过格子高亮并按格位自动避让边距显示日期与次数 */
|
|
53
|
+
(() => {
|
|
54
|
+
const N = [0,2,5,3,6,4,1,1,4,8,6,9,3,0,2,6,11,9,7,5,2,0,3,5,4,8,2,1,3,7,12,10,14,6,2,1,5,9,6,8,4,0,0,2,4,7,5,3,1,2,8,13,11,9,7,3,1,6,10,8,12,5,2,0,4,7,5,6,2,1,3,9,15,12,11,6,2,1,5,8,7,9,4,1,2,7,11,10,13,8,3,0,4,6,8,7,3,1,2,6,9,12,10,5,2]
|
|
55
|
+
const MD = [[9, 30], [10, 31], [11, 30], [12, 31]]
|
|
56
|
+
const fmt = (i) => { let k = i; for (const [m, d] of MD) { if (k < d) return m + '月' + (k + 1) + '日'; k -= d } return '' }
|
|
57
|
+
document.querySelectorAll('.c-chart-heat').forEach((el) => {
|
|
58
|
+
const grid = el.querySelector('.ch-grid')
|
|
59
|
+
const cells = [...grid.children]
|
|
60
|
+
const tip = el.querySelector('.ch-tip')
|
|
61
|
+
let cur = -1
|
|
62
|
+
const pick = (i) => {
|
|
63
|
+
if (cur >= 0) cells[cur].classList.remove('is-on')
|
|
64
|
+
cur = i
|
|
65
|
+
el.classList.toggle('is-on', i >= 0)
|
|
66
|
+
el.dataset.idx = i >= 0 ? String(i) : ''
|
|
67
|
+
if (i < 0) return
|
|
68
|
+
cells[i].classList.add('is-on')
|
|
69
|
+
tip.textContent = fmt(i) + ' ' + N[i] + '次'
|
|
70
|
+
const col = Math.floor(i / 7); const row = i % 7
|
|
71
|
+
tip.style.left = Math.max(52, Math.min(244, 42 + col * 16)) + 'px'
|
|
72
|
+
tip.style.top = (row < 2 ? 78 + row * 15 : 22 + row * 15) + 'px'
|
|
73
|
+
}
|
|
74
|
+
grid.addEventListener('pointerover', (e) => { const idx = cells.indexOf(e.target); if (idx >= 0) pick(idx) })
|
|
75
|
+
grid.addEventListener('pointerleave', () => pick(-1))
|
|
76
|
+
el.chPick = pick
|
|
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 DEMO = {
|
|
97
|
+
settle () { el.chPick(-1) },
|
|
98
|
+
loop (later) {
|
|
99
|
+
later(() => el.chPick(16), 400)
|
|
100
|
+
later(() => el.chPick(32), 1450)
|
|
101
|
+
later(() => el.chPick(72), 2450)
|
|
102
|
+
later(() => el.chPick(88), 3450)
|
|
103
|
+
later(() => el.chPick(-1), 4150)
|
|
104
|
+
later(() => DEMO.loop(later), 4750)
|
|
105
|
+
},
|
|
106
|
+
stop () { el.chPick(-1) },
|
|
107
|
+
}
|
|
108
|
+
// =====================
|
|
109
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
110
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
111
|
+
addEventListener('message', (e) => {
|
|
112
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
113
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
114
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
115
|
+
})
|
|
116
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
117
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
118
|
+
})()
|
|
119
|
+
</script>
|
|
120
|
+
</body>
|
|
121
|
+
</html>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>指标卡</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"chart-kpi","zh":"指标卡","en":"KPI Card","cat":"chart","desc":"核心数字配环比涨跌与迷你趋势线,划过曲线查看每日营收","desc_en":"Headline KPI with delta badge and mini sparkline; hover to inspect daily values","needs":"css","play":"hover","hint":"划过曲线","hint_en":"Hover sparkline","source":{"name":"daisyUI","url":"https://github.com/saadeghi/daisyui/blob/master/packages/daisyui/src/components/stat.css","license":"MIT","author":"2020 Pouya Saadeghi"},"prompt":"数据指标卡:宽 296px 高 168px、圆角 16px 的 --color-surface 卡片,参照 daisyUI stat 的标题、大数字和环比副文层次排版。左上小标题与右上 --color-success 涨幅胶囊,中间 26px 等宽大数字与对比差值,下半部为 264×52 内联 SVG 曲线和 14% 透明面积填充。上方叠加 7 个等宽纯 CSS 悬停区,划过时出现竖向引导线、带外环的 --color-primary 节点圆点,以及高对比气泡显示当日金额。","prompt_en":"KPI metric card, 296x168 --color-surface card with 16px radius, adapted from daisyUI stat hierarchy (title, 26px tabular value, comparison subtext) paired with a --color-success growth pill. The lower 264x52 inline SVG plots a smooth 7-day curve and translucent fill under 7 pure-CSS hover columns that reveal a vertical guide, ringed --color-primary dot, and high-contrast daily value pill."}</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
|
+
/* 指标卡 改写自 daisyUI(MIT,© 2020 Pouya Saadeghi,https://github.com/saadeghi/daisyui)的 stat.css:指标标题、核心数值与说明行的信息层级,并扩展纯 CSS 交互迷你趋势线与悬停气泡。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success */
|
|
19
|
+
.c-chart-kpi{box-sizing:border-box;width:296px;height:168px;padding:13px 16px 11px;border-radius:16px;display:flex;flex-direction:column;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(20,20,19,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.28);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-chart-kpi .kp-top{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
21
|
+
.c-chart-kpi .kp-title{font-size:12px;font-weight:500;color:var(--color-muted,#76756f)}
|
|
22
|
+
.c-chart-kpi .kp-delta{display:inline-flex;align-items:center;gap:2px;padding:2px 7px;border-radius:99px;font-size:11px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--color-success,#30b35a);background:color-mix(in srgb,var(--color-success,#30b35a) 14%,transparent)}
|
|
23
|
+
.c-chart-kpi .kp-val{margin-top:3px;font-size:26px;font-weight:700;line-height:1.12;letter-spacing:-.02em;font-variant-numeric:tabular-nums}
|
|
24
|
+
.c-chart-kpi .kp-sub{margin-top:2px;font-size:11px;color:var(--color-muted,#76756f);font-variant-numeric:tabular-nums}
|
|
25
|
+
.c-chart-kpi .kp-spark{position:relative;margin-top:auto;width:264px;height:52px}
|
|
26
|
+
.c-chart-kpi .kp-svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}
|
|
27
|
+
.c-chart-kpi .kp-area{fill:var(--color-primary,#0a84ff);fill-opacity:.14}
|
|
28
|
+
.c-chart-kpi .kp-line{fill:none;stroke:var(--color-primary,#0a84ff);stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
|
|
29
|
+
.c-chart-kpi .kp-hits{position:absolute;inset:0;display:flex}
|
|
30
|
+
.c-chart-kpi .kp-hit{position:relative;flex:1;height:100%;cursor:crosshair;outline:none}
|
|
31
|
+
.c-chart-kpi .kp-guide{position:absolute;left:50%;top:4px;bottom:0;width:1px;background:color-mix(in srgb,var(--color-primary,#0a84ff) 40%,transparent);opacity:0;transform:translateX(-.5px);transition:opacity .16s;pointer-events:none}
|
|
32
|
+
.c-chart-kpi .kp-dot{position:absolute;left:50%;top:var(--y);width:8px;height:8px;border-radius:50%;background:var(--color-primary,#0a84ff);box-shadow:0 0 0 2px var(--color-surface,#fff),0 0 0 4px color-mix(in srgb,var(--color-primary,#0a84ff) 28%,transparent);opacity:0;transform:translate(-50%,-50%) scale(.5);transition:opacity .16s,transform .32s linear(0,.07,.245,.475,.716,.931,1.1,1.212,1.267,1.272,1.239,1.184,1.118,1.054,.999,.958,.934,.925,.928,.94,.956,.975,.992,1.005,1.015,1.02,1.021,1.019,1.015,1.01,1.005,1.001,.997,.995,.994,.994,.995,.996,.998,.999,1);pointer-events:none}
|
|
33
|
+
.c-chart-kpi .kp-peak .kp-dot{opacity:1;transform:translate(-50%,-50%) scale(.82)}
|
|
34
|
+
.c-chart-kpi .kp-hits:hover .kp-peak:not(:hover) .kp-dot{opacity:.35}
|
|
35
|
+
.c-chart-kpi .kp-tip{position:absolute;left:50%;bottom:calc(100% - var(--y) + 9px);padding:3px 7px;border-radius:6px;white-space:nowrap;font-size:10.5px;font-weight:600;line-height:1.25;font-variant-numeric:tabular-nums;background:var(--color-text,#141413);color:var(--color-surface,#fff);box-shadow:0 4px 10px -2px rgba(0,0,0,.22);visibility:hidden;opacity:0;transform:translate(-50%,4px);transition:opacity .16s,transform .22s cubic-bezier(.2,.9,.3,1),visibility .16s;pointer-events:none;z-index:3}
|
|
36
|
+
.c-chart-kpi .kp-l .kp-tip{left:0;transform:translate(0,4px)}
|
|
37
|
+
.c-chart-kpi .kp-r .kp-tip{left:auto;right:0;transform:translate(0,4px)}
|
|
38
|
+
.c-chart-kpi .kp-hit:hover .kp-guide,.c-chart-kpi .kp-hit:focus-visible .kp-guide,.c-chart-kpi .kp-hit.is-hi .kp-guide{opacity:1}
|
|
39
|
+
.c-chart-kpi .kp-hit:hover .kp-dot,.c-chart-kpi .kp-hit:focus-visible .kp-dot,.c-chart-kpi .kp-hit.is-hi .kp-dot{opacity:1;transform:translate(-50%,-50%) scale(1.12)}
|
|
40
|
+
.c-chart-kpi .kp-hit:hover .kp-tip,.c-chart-kpi .kp-hit:focus-visible .kp-tip,.c-chart-kpi .kp-hit.is-hi .kp-tip{visibility:visible;opacity:1;transform:translate(-50%,0)}
|
|
41
|
+
.c-chart-kpi .kp-l:hover .kp-tip,.c-chart-kpi .kp-l:focus-visible .kp-tip,.c-chart-kpi .kp-l.is-hi .kp-tip,.c-chart-kpi .kp-r:hover .kp-tip,.c-chart-kpi .kp-r:focus-visible .kp-tip,.c-chart-kpi .kp-r.is-hi .kp-tip{transform:translate(0,0)}
|
|
42
|
+
.c-chart-kpi .kp-foot{display:flex;justify-content:space-between;margin-top:4px;font-size:10px;color:var(--color-muted,#76756f)}
|
|
43
|
+
@media (prefers-reduced-motion:reduce){.c-chart-kpi *{transition:none!important}}
|
|
44
|
+
</style>
|
|
45
|
+
</head>
|
|
46
|
+
<body>
|
|
47
|
+
<div class="stage-fit">
|
|
48
|
+
<div class="c-chart-kpi" data-comp="chart-kpi">
|
|
49
|
+
<div class="kp-top"><span class="kp-title">本周营收</span><span class="kp-delta"><svg width="10" height="10" viewBox="0 0 12 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 8.5L6 4.5L8.5 7L10.5 3.5M8 3.5h2.5V6"/></svg>+14.8%</span></div>
|
|
50
|
+
<div class="kp-val">¥129,460</div>
|
|
51
|
+
<div class="kp-sub">较上周增加 ¥16,680</div>
|
|
52
|
+
<div class="kp-spark" aria-label="近七日营收趋势">
|
|
53
|
+
<svg class="kp-svg" viewBox="0 0 264 52" aria-hidden="true"><path class="kp-area" d="M18.9,40.4 C25.1,38.8 44.0,31.3 56.6,30.8 C69.1,30.3 81.7,38.1 94.3,37.2 C106.9,36.3 119.4,27.1 132.0,25.6 C144.6,24.1 157.1,29.4 169.7,28.4 C182.3,27.4 194.9,22.0 207.4,19.6 C220.0,17.2 238.9,15.1 245.1,14.2 L245.1,52 L18.9,52 Z"/><path class="kp-line" d="M18.9,40.4 C25.1,38.8 44.0,31.3 56.6,30.8 C69.1,30.3 81.7,38.1 94.3,37.2 C106.9,36.3 119.4,27.1 132.0,25.6 C144.6,24.1 157.1,29.4 169.7,28.4 C182.3,27.4 194.9,22.0 207.4,19.6 C220.0,17.2 238.9,15.1 245.1,14.2"/></svg>
|
|
54
|
+
<div class="kp-hits">
|
|
55
|
+
<span class="kp-hit kp-l" style="--y:40.4px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周一 ¥15,400</b></span>
|
|
56
|
+
<span class="kp-hit" style="--y:30.8px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周二 ¥17,800</b></span>
|
|
57
|
+
<span class="kp-hit" style="--y:37.2px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周三 ¥16,200</b></span>
|
|
58
|
+
<span class="kp-hit" style="--y:25.6px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周四 ¥19,100</b></span>
|
|
59
|
+
<span class="kp-hit" style="--y:28.4px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周五 ¥18,400</b></span>
|
|
60
|
+
<span class="kp-hit" style="--y:19.6px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周六 ¥20,600</b></span>
|
|
61
|
+
<span class="kp-hit kp-r kp-peak" style="--y:14.2px" tabindex="0"><i class="kp-guide"></i><i class="kp-dot"></i><b class="kp-tip">周日 ¥21,960</b></span>
|
|
62
|
+
</div>
|
|
63
|
+
</div>
|
|
64
|
+
<div class="kp-foot"><span>周一</span><span>周四</span><span>周日</span></div>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<script data-stage>
|
|
68
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
69
|
+
(() => {
|
|
70
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
71
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
72
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
73
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
74
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
75
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
76
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
77
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
78
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
79
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
80
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
81
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
82
|
+
// ===== 只改这一段 =====
|
|
83
|
+
const hits = [...el.querySelectorAll('.kp-hit')]
|
|
84
|
+
const mark = (k) => hits.forEach((h, i) => h.classList.toggle('is-hi', i === k))
|
|
85
|
+
const DEMO = {
|
|
86
|
+
settle () { mark(-1) },
|
|
87
|
+
loop (later) {
|
|
88
|
+
later(() => mark(1), 400)
|
|
89
|
+
later(() => mark(3), 1450)
|
|
90
|
+
later(() => mark(5), 2450)
|
|
91
|
+
later(() => mark(6), 3450)
|
|
92
|
+
later(() => mark(-1), 4150)
|
|
93
|
+
later(() => DEMO.loop(later), 4750)
|
|
94
|
+
},
|
|
95
|
+
stop () { mark(-1) },
|
|
96
|
+
}
|
|
97
|
+
// =====================
|
|
98
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
99
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
100
|
+
addEventListener('message', (e) => {
|
|
101
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
102
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
103
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
104
|
+
})
|
|
105
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
106
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
107
|
+
})()
|
|
108
|
+
</script>
|
|
109
|
+
</body>
|
|
110
|
+
</html>
|