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,129 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>用户评价墙</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"web-testimonial","zh":"用户评价墙","en":"Testimonial Wall","cat":"web","desc":"两列评价卡片墙配五星与头像,点分页切换下一组用户评价","desc_en":"Two-column review wall with ratings and avatars; tap dots to flip to the next pair","needs":"js","play":"press","hint":"点圆点翻页","hint_en":"Tap dots to flip","source":{"name":"HyperUI","url":"https://github.com/markmead/hyperui/blob/main/public/examples/marketing/testimonials/2.html","license":"MIT","author":"Mark Mead"},"prompt":"两列用户评价墙:宽 298px,照 HyperUI testimonials/2.html 的多栏卡片结构,去掉外链照片改用渐变首字圆形头像。每张圆角 14px 的 --color-surface 卡片含 5 颗 --color-warning 星标、简短评价正文与底部 22px 头像加虚构姓名职位。下方分页圆点与切换按钮支持在两组共 4 条评价间切换,切页时两张卡片错峰淡入上移(0.28s)。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning。","prompt_en":"Two-column testimonial wall, 298px wide, adapted from HyperUI testimonials/2.html using CSS-gradient monogram avatars instead of external photos. Each 14px-radius --color-surface card shows five --color-warning stars, a short review quote, and a 22px avatar with fictional name and role. Bottom pagination dots and a next button flip between 2 pairs (4 quotes total) with staggered 0.28s fade-up motion. Reads --color-surface/text/muted/line/primary/warning."}</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
|
+
/* 用户评价墙 改写自 HyperUI(MIT,© Mark Mead,https://github.com/markmead/hyperui)的 marketing/testimonials/2.html:多列引言卡片与底部作者栏排布;去 Unsplash 外链图改用渐变首字头像并加分组翻页。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-warning */
|
|
19
|
+
.c-web-testimonial{box-sizing:border-box;width:298px;display:grid;gap:8px;font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-web-testimonial .tm-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
|
|
21
|
+
.c-web-testimonial .tm-card{box-sizing:border-box;height:132px;padding:10px 10px 9px;border-radius:14px;display:flex;flex-direction:column;justify-content:space-between;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3)}
|
|
22
|
+
.c-web-testimonial .tm-grid.is-in .tm-card{animation:web-testimonial-in .28s cubic-bezier(.2,.9,.3,1) both}
|
|
23
|
+
.c-web-testimonial .tm-grid.is-in .tm-card:nth-child(2){animation-delay:.06s}
|
|
24
|
+
.c-web-testimonial .tm-stars{display:flex;gap:1.5px;color:var(--color-warning,#ffb340)}
|
|
25
|
+
.c-web-testimonial .tm-stars svg{width:10px;height:10px;fill:currentColor}
|
|
26
|
+
.c-web-testimonial blockquote{margin:5px 0 0;font-size:11px;line-height:1.48;color:var(--color-text,#141413)}
|
|
27
|
+
.c-web-testimonial .tm-who{display:flex;align-items:center;gap:6px;margin-top:6px}
|
|
28
|
+
.c-web-testimonial .tm-av{flex:none;width:22px;height:22px;border-radius:50%;display:grid;place-items:center;font-style:normal;font-size:10px;font-weight:700;color:#fff;background:var(--av)}
|
|
29
|
+
.c-web-testimonial .tm-meta{min-width:0;display:grid}
|
|
30
|
+
.c-web-testimonial .tm-meta b{font-size:10.5px;line-height:13px;font-weight:600}
|
|
31
|
+
.c-web-testimonial .tm-meta span{font-size:9.5px;line-height:12px;color:var(--color-muted,#76756f);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
32
|
+
.c-web-testimonial .tm-bar{display:flex;align-items:center;justify-content:space-between;padding:0 2px;height:22px}
|
|
33
|
+
.c-web-testimonial .tm-dots{display:flex;gap:5px;align-items:center}
|
|
34
|
+
.c-web-testimonial .tm-dot{width:6px;height:6px;padding:0;border:0;border-radius:3px;background:color-mix(in srgb,var(--color-text,#141413) 20%,transparent);cursor:pointer;transition:width .28s cubic-bezier(.3,1.4,.5,1),background-color .22s}
|
|
35
|
+
.c-web-testimonial .tm-dot.is-on{width:18px;background:var(--color-primary,#0a84ff)}
|
|
36
|
+
.c-web-testimonial .tm-next{height:22px;padding:0 9px;border:0;border-radius:11px;font:600 10.5px/1 var(--font-sans,system-ui);color:var(--color-text,#141413);background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.12)),0 1px 2px rgba(0,0,0,.05);cursor:pointer;transition:transform .16s}
|
|
37
|
+
.c-web-testimonial .tm-next:active{transform:scale(.93)}
|
|
38
|
+
.c-web-testimonial button:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
|
|
39
|
+
@keyframes web-testimonial-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
|
|
40
|
+
@media (prefers-reduced-motion:reduce){.c-web-testimonial *{animation:none!important;transition:none!important}}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<div class="stage-fit">
|
|
45
|
+
<div class="c-web-testimonial" data-comp="web-testimonial">
|
|
46
|
+
<div class="tm-grid">
|
|
47
|
+
<article class="tm-card"><div><span class="tm-stars" aria-label="五星好评"><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg></span><blockquote>「一套改完整个落地页只花了半下午,深色效果几乎不用微调。」</blockquote></div><div class="tm-who"><i class="tm-av" style="--av:linear-gradient(135deg,#0a84ff,#5e5ce6)">林</i><div class="tm-meta"><b>林夏</b><span>产品设计</span></div></div></article>
|
|
48
|
+
<article class="tm-card"><div><span class="tm-stars" aria-label="五星好评"><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg></span><blockquote>「默认间距和字号都很克制,给客户看初稿一遍就过了。」</blockquote></div><div class="tm-who"><i class="tm-av" style="--av:linear-gradient(135deg,#30b35a,#14b8a6)">周</i><div class="tm-meta"><b>周明远</b><span>前端负责</span></div></div></article>
|
|
49
|
+
</div>
|
|
50
|
+
<div class="tm-bar">
|
|
51
|
+
<div class="tm-dots"><button class="tm-dot is-on" type="button" data-i="0" aria-label="第一组评价"></button><button class="tm-dot" type="button" data-i="1" aria-label="第二组评价"></button></div>
|
|
52
|
+
<button class="tm-next" type="button">换一批 →</button>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
<script data-comp>
|
|
57
|
+
/* 用户评价墙:在两组共 4 条评价之间切换,错峰淡入上移 */
|
|
58
|
+
(() => {
|
|
59
|
+
const STARS = `<span class="tm-stars" aria-label="五星好评"><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg><svg viewBox="0 0 12 12"><path d="M6 1l1.5 3.1 3.4.5-2.5 2.4.6 3.4L6 8.8 3 10.4l.6-3.4L1.1 4.6l3.4-.5z"/></svg></span>`
|
|
60
|
+
const PAGES = [
|
|
61
|
+
[
|
|
62
|
+
['「一套改完整个落地页只花了半下午,深色效果几乎不用微调。」', '林', '林夏', '产品设计', 'linear-gradient(135deg,#0a84ff,#5e5ce6)'],
|
|
63
|
+
['「默认间距和字号都很克制,给客户看初稿一遍就过了。」', '周', '周明远', '前端负责', 'linear-gradient(135deg,#30b35a,#14b8a6)'],
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
['「纯单文件直接复制就能跑,再也不用先折腾半天构建环境。」', '陈', '陈安宁', '独立站长', 'linear-gradient(135deg,#f97316,#ff375f)'],
|
|
67
|
+
['「组件体积小又自带无障碍焦点,放进现有后台毫无违和感。」', '沈', '沈青', '运营主管', 'linear-gradient(135deg,#8b5cf6,#ec4899)'],
|
|
68
|
+
],
|
|
69
|
+
]
|
|
70
|
+
document.querySelectorAll('.c-web-testimonial').forEach((el) => {
|
|
71
|
+
const grid = el.querySelector('.tm-grid')
|
|
72
|
+
const dots = [...el.querySelectorAll('.tm-dot')]
|
|
73
|
+
let cur = 0
|
|
74
|
+
const show = (i, anim = true) => {
|
|
75
|
+
cur = i
|
|
76
|
+
dots.forEach((d, k) => d.classList.toggle('is-on', k === i))
|
|
77
|
+
grid.innerHTML = PAGES[i].map(([q, ch, name, role, av]) =>
|
|
78
|
+
`<article class="tm-card"><div>${STARS}<blockquote>${q}</blockquote></div><div class="tm-who"><i class="tm-av" style="--av:${av}">${ch}</i><div class="tm-meta"><b>${name}</b><span>${role}</span></div></div></article>`
|
|
79
|
+
).join('')
|
|
80
|
+
if (anim) { grid.classList.remove('is-in'); void grid.offsetWidth; grid.classList.add('is-in') }
|
|
81
|
+
}
|
|
82
|
+
el.addEventListener('click', (e) => {
|
|
83
|
+
const d = e.target.closest('.tm-dot'); if (d) return show(Number(d.dataset.i))
|
|
84
|
+
if (e.target.closest('.tm-next')) return show((cur + 1) % PAGES.length)
|
|
85
|
+
})
|
|
86
|
+
el.tmSet = (i) => show(i, false)
|
|
87
|
+
})
|
|
88
|
+
})()
|
|
89
|
+
</script>
|
|
90
|
+
<script data-stage>
|
|
91
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
92
|
+
(() => {
|
|
93
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
94
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
95
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
96
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
97
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
98
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
99
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
100
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
101
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
102
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
103
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
104
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
105
|
+
// ===== 只改这一段 =====
|
|
106
|
+
const next = el.querySelector('.tm-next')
|
|
107
|
+
const DEMO = {
|
|
108
|
+
settle () { el.tmSet(0) },
|
|
109
|
+
loop (later) {
|
|
110
|
+
later(() => next.click(), 700)
|
|
111
|
+
later(() => next.click(), 3400)
|
|
112
|
+
later(() => DEMO.loop(later), 4800)
|
|
113
|
+
},
|
|
114
|
+
stop () {},
|
|
115
|
+
}
|
|
116
|
+
// =====================
|
|
117
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
118
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
119
|
+
addEventListener('message', (e) => {
|
|
120
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
121
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
122
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
123
|
+
})
|
|
124
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
125
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
126
|
+
})()
|
|
127
|
+
</script>
|
|
128
|
+
</body>
|
|
129
|
+
</html>
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>拖放上传</title>
|
|
7
|
+
<script type="application/json" id="meta">{"id":"web-upload","zh":"拖放上传","en":"Dropzone Upload","cat":"web","desc":"支持拖入或点击文件触发模拟进度条,满百后切绿色完成态","desc_en":"Click or drop a file to simulate upload progress until it flips to a green checkmark","needs":"js","play":"press","hint":"点或拖文件","hint_en":"Tap or drop file","source":{"name":"HyperUI","url":"https://github.com/markmead/hyperui/blob/main/public/examples/application/file-uploaders/2.html","license":"MIT","author":"Mark Mead"},"prompt":"拖放文件上传卡:宽 296px 高 164px 圆角 16px 的 --color-surface 卡片,上方 88px 虚线拖放区照 HyperUI file-uploaders/2.html 排布上传图标、提示文案与选择胶囊按钮;拖入文件时虚线框变 --color-primary 高亮且图标轻跳,点击或放下文件仅做前端模拟进度(不发网络请求)。下方 46px 固定高度任务行显示文件名、百分比与 scaleX 进度条,100% 时变 --color-success「已完成 ✓」。读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success。","prompt_en":"Dropzone uploader card, 296x164, 16px-radius --color-surface card. Top 88px dashed drop area adapts HyperUI application/file-uploaders/2.html with upload SVG, prompt, and pill button; dragging highlights the dashed border in --color-primary and lifts the icon. Dropping or clicking simulates progress locally (no network upload) in the fixed 46px task row below via a scaleX bar that turns --color-success Done at 100%. Reads --color-surface/text/muted/line/primary/success."}</script>
|
|
8
|
+
<style data-stage>
|
|
9
|
+
:root{color-scheme:light;--color-bg:#efede7;--color-surface:#fff;--color-text:#141413;--color-muted:#76756f;--color-line:rgba(20,20,19,.1);--color-primary:#0a84ff;--color-danger:#ff375f;--color-warning:#ffb340;--font-sans:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Microsoft YaHei",system-ui,sans-serif}
|
|
10
|
+
:root[data-theme=dark]{color-scheme:dark;--color-bg:#17171a;--color-surface:#2c2c30;--color-text:#f5f5f4;--color-muted:#8e8d88;--color-line:rgba(255,255,255,.1)}
|
|
11
|
+
html,body{height:100%;margin:0}
|
|
12
|
+
body{display:grid;place-items:center;background:var(--color-bg);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overflow:hidden;user-select:none;-webkit-user-select:none}
|
|
13
|
+
.paused *{animation-play-state:paused!important}
|
|
14
|
+
.stage-fit{position:absolute;left:50%;top:50%;width:max-content;display:grid;place-items:center;transform:translate(-50%,-50%) scale(var(--fit,1))}
|
|
15
|
+
</style>
|
|
16
|
+
<style data-comp>
|
|
17
|
+
/* 拖放上传 改写自 HyperUI(MIT,© Mark Mead,https://github.com/markmead/hyperui)的 application/file-uploaders/2.html:图标、说明与浏览按钮居中上传区;去 Tailwind,加虚线拖放反馈与模拟进度条(不真实上传)。
|
|
18
|
+
读 --color-surface / --color-text / --color-muted / --color-line / --color-primary / --color-success */
|
|
19
|
+
.c-web-upload{--up-p:.72;box-sizing:border-box;width:296px;height:164px;padding:11px;border-radius:16px;display:grid;grid-template-rows:88px 1fr;gap:8px;background:var(--color-surface,#fff);box-shadow:0 0 0 .5px var(--color-line,rgba(0,0,0,.1)),0 2px 4px rgba(0,0,0,.05),0 14px 30px -14px rgba(0,0,0,.3);font-family:var(--font-sans,system-ui);-webkit-tap-highlight-color:transparent;color:var(--color-text,#141413)}
|
|
20
|
+
.c-web-upload .up-zone{box-sizing:border-box;width:100%;height:88px;padding:8px 12px;border:1.5px dashed color-mix(in srgb,var(--color-text,#141413) 20%,transparent);border-radius:11px;background:color-mix(in srgb,var(--color-text,#141413) 3%,transparent);display:grid;justify-items:center;align-content:center;gap:3px;cursor:pointer;color:inherit;font:inherit;transition:border-color .2s,background-color .2s,transform .16s}
|
|
21
|
+
.c-web-upload .up-zone:hover,.c-web-upload.is-drag .up-zone{border-color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-primary,#0a84ff) 9%,transparent)}
|
|
22
|
+
.c-web-upload .up-zone:active{transform:scale(.98)}
|
|
23
|
+
.c-web-upload .up-zone:focus-visible{outline:2px solid var(--color-primary,#0a84ff);outline-offset:2px}
|
|
24
|
+
.c-web-upload .up-ic{width:24px;height:24px;border-radius:7px;display:grid;place-items:center;color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-primary,#0a84ff) 13%,transparent);transition:transform .28s cubic-bezier(.3,1.5,.5,1)}
|
|
25
|
+
.c-web-upload.is-drag .up-ic{transform:translateY(-3px) scale(1.08)}
|
|
26
|
+
.c-web-upload .up-ic svg{width:14px;height:14px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
|
27
|
+
.c-web-upload .up-zone b{font-size:12px;font-weight:600;line-height:16px}
|
|
28
|
+
.c-web-upload .up-zone span{font-size:10px;color:var(--color-muted,#76756f);line-height:14px}
|
|
29
|
+
.c-web-upload .up-row{box-sizing:border-box;padding:7px 9px;border-radius:10px;background:color-mix(in srgb,var(--color-text,#141413) 4%,transparent);display:grid;grid-template-columns:26px 1fr;gap:8px;align-items:center}
|
|
30
|
+
.c-web-upload .up-file{width:26px;height:26px;border-radius:7px;display:grid;place-items:center;font-style:normal;font-size:9px;font-weight:800;color:var(--color-primary,#0a84ff);background:color-mix(in srgb,var(--color-primary,#0a84ff) 14%,transparent);transition:color .22s,background-color .22s}
|
|
31
|
+
.c-web-upload.is-done .up-file{color:var(--color-success,#30b35a);background:color-mix(in srgb,var(--color-success,#30b35a) 16%,transparent)}
|
|
32
|
+
.c-web-upload .up-meta{min-width:0;display:grid;gap:5px}
|
|
33
|
+
.c-web-upload .up-hd{display:flex;align-items:center;justify-content:space-between;gap:6px;font-size:11px}
|
|
34
|
+
.c-web-upload .up-name{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
35
|
+
.c-web-upload .up-pct{flex:none;font-size:10.5px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--color-primary,#0a84ff);transition:color .22s}
|
|
36
|
+
.c-web-upload.is-done .up-pct{color:var(--color-success,#30b35a)}
|
|
37
|
+
.c-web-upload .up-track{height:4px;border-radius:2px;overflow:hidden;background:color-mix(in srgb,var(--color-text,#141413) 11%,transparent)}
|
|
38
|
+
.c-web-upload .up-bar{display:block;height:100%;border-radius:2px;background:var(--color-primary,#0a84ff);transform-origin:left;transform:scaleX(var(--up-p));transition:background-color .25s}
|
|
39
|
+
.c-web-upload.is-done .up-bar{background:var(--color-success,#30b35a)}
|
|
40
|
+
@media (prefers-reduced-motion:reduce){.c-web-upload *{transition:none!important}}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
<body>
|
|
44
|
+
<div class="stage-fit">
|
|
45
|
+
<div class="c-web-upload" data-comp="web-upload">
|
|
46
|
+
<button class="up-zone" type="button">
|
|
47
|
+
<i class="up-ic"><svg viewBox="0 0 16 16"><path d="M8 10.5V3.5M5 6.2L8 3.2l3 3M2.8 11v1.2a1.3 1.3 0 0 0 1.3 1.3h7.8a1.3 1.3 0 0 0 1.3-1.3V11"/></svg></i>
|
|
48
|
+
<b>拖放文件到这里,或点此选择</b>
|
|
49
|
+
<span>支持 PNG、PDF,单文件限 20 MB</span>
|
|
50
|
+
</button>
|
|
51
|
+
<div class="up-row">
|
|
52
|
+
<i class="up-file">PDF</i>
|
|
53
|
+
<div class="up-meta">
|
|
54
|
+
<div class="up-hd"><span class="up-name">页面方案终稿.pdf</span><span class="up-pct" aria-live="polite">72%</span></div>
|
|
55
|
+
<div class="up-track"><i class="up-bar"></i></div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
<script data-comp>
|
|
61
|
+
/* 拖放上传:仅模拟前端进度与状态,不发送任何网络请求 */
|
|
62
|
+
(() => {
|
|
63
|
+
const SAMPLES = [
|
|
64
|
+
['页面方案终稿.pdf', 'PDF'],
|
|
65
|
+
['品牌配色规范.png', 'PNG'],
|
|
66
|
+
['首屏插画导出.svg', 'SVG'],
|
|
67
|
+
]
|
|
68
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
69
|
+
document.querySelectorAll('.c-web-upload').forEach((el) => {
|
|
70
|
+
const zone = el.querySelector('.up-zone')
|
|
71
|
+
const nameEl = el.querySelector('.up-name'), extEl = el.querySelector('.up-file'), pctEl = el.querySelector('.up-pct')
|
|
72
|
+
let raf = 0, sampleIdx = 0
|
|
73
|
+
const stopAnim = () => { cancelAnimationFrame(raf); raf = 0 }
|
|
74
|
+
const paint = (p, fileName, ext) => {
|
|
75
|
+
const v = Math.max(0, Math.min(1, p))
|
|
76
|
+
if (fileName) nameEl.textContent = fileName
|
|
77
|
+
if (ext) extEl.textContent = ext
|
|
78
|
+
el.style.setProperty('--up-p', v.toFixed(3))
|
|
79
|
+
const done = v >= 1
|
|
80
|
+
el.classList.toggle('is-done', done)
|
|
81
|
+
pctEl.textContent = done ? '已完成 ✓' : Math.round(v * 100) + '%'
|
|
82
|
+
}
|
|
83
|
+
const startFake = (fileName, ext) => {
|
|
84
|
+
stopAnim(); el.classList.remove('is-drag')
|
|
85
|
+
if (reduced) return paint(1, fileName, ext)
|
|
86
|
+
paint(0.06, fileName, ext)
|
|
87
|
+
const t0 = performance.now(), dur = 1150
|
|
88
|
+
const step = (t) => {
|
|
89
|
+
const k = Math.min(1, (t - t0) / dur)
|
|
90
|
+
const ease = 1 - Math.pow(1 - k, 2.4)
|
|
91
|
+
paint(0.06 + ease * 0.94)
|
|
92
|
+
if (k < 1) raf = requestAnimationFrame(step); else raf = 0
|
|
93
|
+
}
|
|
94
|
+
raf = requestAnimationFrame(step)
|
|
95
|
+
}
|
|
96
|
+
zone.addEventListener('click', () => {
|
|
97
|
+
sampleIdx = (sampleIdx + 1) % SAMPLES.length
|
|
98
|
+
const [n, x] = SAMPLES[sampleIdx]
|
|
99
|
+
startFake(n, x)
|
|
100
|
+
})
|
|
101
|
+
zone.addEventListener('dragenter', (e) => { e.preventDefault(); el.classList.add('is-drag') })
|
|
102
|
+
zone.addEventListener('dragover', (e) => { e.preventDefault(); el.classList.add('is-drag') })
|
|
103
|
+
zone.addEventListener('dragleave', () => el.classList.remove('is-drag'))
|
|
104
|
+
zone.addEventListener('drop', (e) => {
|
|
105
|
+
e.preventDefault(); el.classList.remove('is-drag')
|
|
106
|
+
const f = e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files[0]
|
|
107
|
+
if (f) {
|
|
108
|
+
const ext = (f.name.split('.').pop() || 'FILE').slice(0, 4).toUpperCase()
|
|
109
|
+
startFake(f.name, ext)
|
|
110
|
+
} else {
|
|
111
|
+
const [n, x] = SAMPLES[sampleIdx]
|
|
112
|
+
startFake(n, x)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
el.upSet = (p, n, x, drag = false) => { stopAnim(); el.classList.toggle('is-drag', drag); paint(p, n, x) }
|
|
116
|
+
el.upRun = (n, x) => startFake(n, x)
|
|
117
|
+
el.upStop = () => { stopAnim(); el.classList.remove('is-drag') }
|
|
118
|
+
})
|
|
119
|
+
})()
|
|
120
|
+
</script>
|
|
121
|
+
<script data-stage>
|
|
122
|
+
/* 演示舞台:每个组件都一样,只改 DEMO 那一段。组件按 340×212 设计,卡片小了整体等比缩小。 */
|
|
123
|
+
(() => {
|
|
124
|
+
const q = new URLSearchParams(location.search); const root = document.documentElement
|
|
125
|
+
root.dataset.theme = (q.get('theme') || (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')) === 'dark' ? 'dark' : 'light'
|
|
126
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
127
|
+
const el = document.querySelector('.stage-fit > [data-comp]')
|
|
128
|
+
// 桌面版里框常常先报 0 宽高、之后变大却不触发 resize:读到 0 不能记下来(会一直缩没),框变化和外层发消息时再算
|
|
129
|
+
const fit = () => { if (innerWidth > 0 && innerHeight > 0) root.style.setProperty('--fit', Math.min(1, innerWidth / 340, innerHeight / 212).toFixed(3)) }
|
|
130
|
+
fit(); addEventListener('resize', fit); addEventListener('load', fit); addEventListener('message', fit)
|
|
131
|
+
if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(root)
|
|
132
|
+
let playing = !q.has('still'); let hovering = false; let timers = []
|
|
133
|
+
const later = (fn, ms) => timers.push(setTimeout(() => { if (playing && !hovering) fn() }, ms)) // 演示用的定时器:用户一来就全部作废
|
|
134
|
+
const stop = () => { timers.forEach(clearTimeout); timers = []; DEMO.stop() }
|
|
135
|
+
const go = (ms) => { stop(); if (playing && !hovering && !reduced) later(() => DEMO.loop(later), ms) }
|
|
136
|
+
// ===== 只改这一段 =====
|
|
137
|
+
const DEMO = {
|
|
138
|
+
settle () { el.upSet(0.72, '页面方案终稿.pdf', 'PDF', false) },
|
|
139
|
+
loop (later) {
|
|
140
|
+
el.upSet(0.12, '品牌配色规范.png', 'PNG', true)
|
|
141
|
+
later(() => el.upRun('品牌配色规范.png', 'PNG'), 650)
|
|
142
|
+
later(() => el.upSet(0.72, '页面方案终稿.pdf', 'PDF', false), 3400)
|
|
143
|
+
later(() => DEMO.loop(later), 4500)
|
|
144
|
+
},
|
|
145
|
+
stop () { el.upStop() },
|
|
146
|
+
}
|
|
147
|
+
// =====================
|
|
148
|
+
document.body.addEventListener('pointerenter', () => { hovering = true; stop() })
|
|
149
|
+
document.body.addEventListener('pointerleave', () => { hovering = false; go(1400) })
|
|
150
|
+
addEventListener('message', (e) => {
|
|
151
|
+
const d = e.data; if (!d || typeof d !== 'object') return
|
|
152
|
+
if (d.theme === 'light' || d.theme === 'dark') root.dataset.theme = d.theme
|
|
153
|
+
if (typeof d.ddpPlay === 'boolean') { playing = d.ddpPlay; root.classList.toggle('paused', !playing); if (playing) go(400); else stop() }
|
|
154
|
+
})
|
|
155
|
+
try { parent.postMessage({ ddpMotionReady: 1 }, '*') } catch (e) { /* 单独打开时没有外层 */ }
|
|
156
|
+
if (reduced || q.has('still')) DEMO.settle(); else go(600)
|
|
157
|
+
})()
|
|
158
|
+
</script>
|
|
159
|
+
</body>
|
|
160
|
+
</html>
|
package/lib/client.js
CHANGED
|
@@ -1001,7 +1001,7 @@ window.__ModuleLoader__.load({
|
|
|
1001
1001
|
compUseText: '〔组件 {name}〕写法:{usage}(文件 components/{name}.html,改它所有用到的屏都跟着变)',
|
|
1002
1002
|
libMotion: '组件',
|
|
1003
1003
|
mtAll: '全部',
|
|
1004
|
-
mtCatAi: 'AI 交互', mtCatButton: '按钮', mtCatInput: '输入', mtCatSlider: '滑块旋钮', mtCatNav: '导航', mtCatCard: '卡片', mtCatGesture: '手势', mtCatLoading: '加载反馈', mtCatText: '文字数字',
|
|
1004
|
+
mtCatMobile: 'App 界面', mtCatShop: '小程序和电商', mtCatWeb: '网页', mtCatChart: '数据图表', mtCatAi: 'AI 交互', mtCatButton: '按钮', mtCatInput: '输入', mtCatSlider: '滑块旋钮', mtCatNav: '导航', mtCatCard: '卡片', mtCatGesture: '手势', mtCatLoading: '加载反馈', mtCatText: '文字数字',
|
|
1005
1005
|
mtPutTip: '加入对话,AI 照着做进设计',
|
|
1006
1006
|
mtPutDone: '已加入对话',
|
|
1007
1007
|
mtPutOk: '已加入',
|
|
@@ -2508,7 +2508,7 @@ window.__ModuleLoader__.load({
|
|
|
2508
2508
|
compUseText: '[Component {name}] Usage: {usage} (file components/{name}.html; changing it updates every screen that uses it)',
|
|
2509
2509
|
libMotion: 'Components',
|
|
2510
2510
|
mtAll: 'All',
|
|
2511
|
-
mtCatAi: 'AI UI', mtCatButton: 'Buttons', mtCatInput: 'Inputs', mtCatSlider: 'Sliders & knobs', mtCatNav: 'Navigation', mtCatCard: 'Cards', mtCatGesture: 'Gestures', mtCatLoading: 'Loading & feedback', mtCatText: 'Text & numbers',
|
|
2511
|
+
mtCatMobile: 'App UI', mtCatShop: 'Mini programs & shop', mtCatWeb: 'Web', mtCatChart: 'Charts', mtCatAi: 'AI UI', mtCatButton: 'Buttons', mtCatInput: 'Inputs', mtCatSlider: 'Sliders & knobs', mtCatNav: 'Navigation', mtCatCard: 'Cards', mtCatGesture: 'Gestures', mtCatLoading: 'Loading & feedback', mtCatText: 'Text & numbers',
|
|
2512
2512
|
mtPutTip: 'Add this component to chat',
|
|
2513
2513
|
mtPutDone: 'Added to chat',
|
|
2514
2514
|
mtPutOk: 'Added',
|
|
@@ -4796,6 +4796,14 @@ body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg::before{box-shadow:var(--d
|
|
|
4796
4796
|
.ddp .ddp-homebar .seg button:hover{color:var(--dd-t1)}
|
|
4797
4797
|
.ddp .ddp-homebar .seg button.on{background:transparent;box-shadow:none;color:var(--dd-t1);font-weight:600}
|
|
4798
4798
|
.ddp .ddp-homebar .seg:not(.on) button.on{background:var(--dd-segon)}
|
|
4799
|
+
.ddp .ddp-homebar .seg.seg{background:var(--dd-f2);box-shadow:inset 0 0 0 1px var(--dd-line2)}
|
|
4800
|
+
.ddp .ddp-homebar .seg.seg::before,body:not([data-ds-dark-theme]) .ddp .ddp-homebar .seg.seg::before{background:linear-gradient(135deg,#2f5fe8,#7c3aed);box-shadow:0 8px 18px -8px #4f46e5}
|
|
4801
|
+
.ddp .ddp-homebar .seg.seg button{display:inline-flex;align-items:center;gap:6px;color:var(--dd-t1);font-weight:550}
|
|
4802
|
+
.ddp .ddp-homebar .seg.seg button svg{flex:none;width:15px;height:15px;opacity:.85}
|
|
4803
|
+
.ddp .ddp-homebar .seg.seg button.on{color:#fff;font-weight:650}
|
|
4804
|
+
.ddp .ddp-homebar .seg.seg button.on svg{opacity:1}
|
|
4805
|
+
.ddp .ddp-homebar .seg.seg:not(.on) button.on{background:linear-gradient(135deg,#2f5fe8,#7c3aed)}
|
|
4806
|
+
@container (max-width:480px){.ddp .ddp-homebar .seg.seg button svg{display:none}}
|
|
4799
4807
|
.ddp .ddp-homeback{margin:0 -6px 0 0;max-width:100%;height:32px;padding:0 10px 0 6px;border-radius:9px;color:var(--dd-t2);font-size:13px;transition:background var(--dd-d1),color var(--dd-d1)}
|
|
4800
4808
|
.ddp .ddp-homeback:hover{background:var(--dd-f1);color:var(--dd-t1)}
|
|
4801
4809
|
.ddp .ddp-homeback svg{width:14px;height:14px}
|
|
@@ -5798,6 +5806,21 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
5798
5806
|
.ddp :is(.ddp-swf1,.ddp-library-page .ddp-mkkinds .ks)>button:hover:not(:disabled){background:var(--dd-f3);color:var(--dd-t1);box-shadow:inset 0 .5px 0 rgba(255,255,255,.07)}
|
|
5799
5807
|
.ddp :is(.ddp-swf1,.ddp-library-page .ddp-mkkinds .ks)>button.on,.ddp :is(.ddp-swf1,.ddp-library-page .ddp-mkkinds .ks)>button.on:hover:not(:disabled){background:var(--dd-au);color:var(--dd-on-au);box-shadow:0 1px 2px rgba(0,0,0,.14),0 6px 16px -8px rgba(0,0,0,.5)}
|
|
5800
5808
|
.ddp :is(.ddp-swf1,.ddp-library-page .ddp-mkkinds .ks)>button em{opacity:.5}
|
|
5809
|
+
/* 选项要一眼分得清(11-29 用户反馈:单调、对比低):筛选标签带本类颜色,选中实色白字 */
|
|
5810
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button{background:color-mix(in srgb,var(--c) 11%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--c) 42%,transparent);color:var(--dd-t1);font-weight:550}
|
|
5811
|
+
body[data-ds-dark-theme] .ddp .ddp-swf1.ddp-swf1.ddp-swf1>button{background:color-mix(in srgb,var(--c) 24%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--c) 70%,#fff 8%)}
|
|
5812
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button:hover:not(:disabled){background:color-mix(in srgb,var(--c) 22%,transparent);color:var(--dd-t1)}
|
|
5813
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button::before{content:'';flex:none;width:7px;height:7px;border-radius:50%;background:var(--c)}
|
|
5814
|
+
body[data-ds-dark-theme] .ddp .ddp-swf1.ddp-swf1.ddp-swf1>button::before{background:color-mix(in srgb,var(--c) 55%,#fff)}
|
|
5815
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button[data-k=""]::before{display:none}
|
|
5816
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button em{opacity:1;color:var(--dd-t2);font-size:11.5px;font-variant-numeric:tabular-nums}
|
|
5817
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on,body[data-ds-dark-theme] .ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on:hover:not(:disabled),.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on:hover:not(:disabled),body[data-ds-dark-theme] .ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on{background:var(--c);color:#fff;box-shadow:inset 0 0 0 1px rgba(255,255,255,.18),0 8px 18px -9px var(--c);font-weight:650}
|
|
5818
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on::before,body[data-ds-dark-theme] .ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on::before{background:#fff}
|
|
5819
|
+
.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on em{color:#fff}
|
|
5820
|
+
body[data-ds-dark-theme] .ddp .ddp-swf1.ddp-swf1.ddp-swf1>button:hover:not(:disabled):not(.on){background:color-mix(in srgb,var(--c) 34%,transparent)}
|
|
5821
|
+
/* 彩色页签和筛选的键盘焦点:画在按钮里侧(页签条会裁掉外圈),选中的实底上用白圈 */
|
|
5822
|
+
.ddp .ddp-homebar .seg.seg button:focus-visible,.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button:focus-visible,.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button:focus-visible{outline:2px solid var(--dd-t1);outline-offset:-3px}
|
|
5823
|
+
.ddp .ddp-homebar .seg.seg button.on:focus-visible,.ddp .ddp-swf1.ddp-swf1.ddp-swf1>button.on:focus-visible,.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button.on:focus-visible{outline-color:#fff}
|
|
5801
5824
|
.ddp .ddp-swcomm{margin-top:36px}
|
|
5802
5825
|
.ddp .ddp-swcomm>h3{display:flex;align-items:baseline;gap:6px;margin:0 2px 14px;font-size:17px;font-weight:700;letter-spacing:-.015em;color:var(--dd-t1)}
|
|
5803
5826
|
.ddp .ddp-swcomm>h3 em{font-style:normal;font-size:12px;font-weight:500;color:var(--dd-t3)}
|
|
@@ -5908,6 +5931,15 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
5908
5931
|
.ddp .ddp-mkbar .dd-seg.ddp-assetseg{display:inline-flex;flex-wrap:wrap;overflow:clip;box-sizing:border-box;max-width:100%;min-width:0}
|
|
5909
5932
|
.ddp .ddp-mkbar :is(.ddp-assetseg,.ddp-mineseg)::before{left:0;top:0;bottom:auto;height:var(--h,30px);width:var(--w,0px);transform-origin:left center;transform:translate(var(--x,0px),var(--y,2px))}
|
|
5910
5933
|
.ddp .ddp-assetseg small{display:inline-block;min-width:2ch;text-align:center;font-variant-numeric:tabular-nums}
|
|
5934
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg{background:var(--dd-f2);box-shadow:inset 0 0 0 1px var(--dd-line2)}
|
|
5935
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg::before,body:not([data-ds-dark-theme]) .ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg::before{background:var(--seg-c);box-shadow:0 8px 18px -9px var(--seg-c);transition:translate var(--dd-d2) var(--dd-out),width var(--dd-d2) var(--dd-out),transform var(--dd-d2) var(--dd-out),background-color var(--dd-d2)}
|
|
5936
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button{display:inline-flex;align-items:center;justify-content:center;gap:5px;color:var(--dd-t1);font-weight:550}
|
|
5937
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button svg{flex:none;width:14px;height:14px;color:var(--tab-c)}
|
|
5938
|
+
body[data-ds-dark-theme] .ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button svg{color:color-mix(in srgb,var(--tab-c) 50%,#fff)}
|
|
5939
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button.on,.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button.on svg,body[data-ds-dark-theme] .ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button.on svg{color:#fff;font-weight:650}
|
|
5940
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button small{margin-left:1px;padding:0 5px;border-radius:6px;background:var(--dd-f2);color:var(--dd-t2);font-size:11px;line-height:16px;opacity:1}
|
|
5941
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button.on small{background:rgba(0,0,0,.2);color:#fff}
|
|
5942
|
+
@container (max-width:420px){.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button svg{display:none}}
|
|
5911
5943
|
.ddp-opening-thumb{position:absolute;z-index:12;transform-origin:0 0;pointer-events:none;object-fit:cover;object-position:top;border-radius:8px;background:var(--dd-s1)}
|
|
5912
5944
|
.ddp-pages{position:relative;isolation:isolate;flex:1;min-height:0;overflow:clip}
|
|
5913
5945
|
.ddp-page{position:absolute;inset:0;display:flex;flex-direction:column;min-height:0}
|
|
@@ -5946,7 +5978,9 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
5946
5978
|
}
|
|
5947
5979
|
@container (max-width:370px){
|
|
5948
5980
|
.ddp .ddp-assetbrowser .ddp-assetgrid{grid-template-columns:1fr}
|
|
5949
|
-
.ddp .ddp-mkbar .dd-seg.ddp-assetseg>button{padding:0
|
|
5981
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg>button{padding:0 6px}
|
|
5982
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button{gap:3px}
|
|
5983
|
+
.ddp .ddp-mkbar .dd-seg.ddp-assetseg.ddp-assetseg>button small{padding:0 4px}
|
|
5950
5984
|
.ddp .ddp-mkbar .ddp-assetseg:lang(en)>button{padding-inline:3px}
|
|
5951
5985
|
}
|
|
5952
5986
|
/* All library items share the same visual hit areas and detail toolbar. */
|
|
@@ -13894,6 +13928,7 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
13894
13928
|
const mkRevoked = (v, id, rev) => !!v && (v.revoked || []).some((r) => r.id === id && (!r.rev || !rev || r.rev === rev))
|
|
13895
13929
|
|
|
13896
13930
|
const ASSET_TABS = [['templates', 'mkTypeTpl'], ['styles', 'swHead'], ['components', 'libMotion'], ['systems', 'mkTypeSys']]
|
|
13931
|
+
const ASSET_LOOK = { templates: ['canvas', '#2f5fe8'], styles: ['palette', '#a21caf'], components: ['sparkle', '#0f766e'], systems: ['sizes', '#c2410c'] }
|
|
13897
13932
|
const HOME_TABS = [['', 'homeTab'], ['assets', 'libAssets'], ['mine', 'libMine']]
|
|
13898
13933
|
const PAL_TABS = [['', 'homeTab'], ...ASSET_TABS, ['works', 'libWorks'], ['inspire', 'libInspire'], ['brand', 'lookBrand']]
|
|
13899
13934
|
const isAssetTab = (tab) => ASSET_TABS.some(([k]) => k === tab)
|
|
@@ -14208,7 +14243,7 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
14208
14243
|
const segRef = useTabIndicator(tab)
|
|
14209
14244
|
return h('header', { className: 'ddp-homebar' + (lead ? ' led' : '') },
|
|
14210
14245
|
h('div', { className: 'lf' }, lead || null, h('div', { className: 'nm' }, art('brand-mark', 30, 30, { className: 'mk', loading: 'eager' }), h('b', null, t('title')))),
|
|
14211
|
-
h('div', { className: 'seg on', ref: segRef, role: 'tablist', onKeyDown: onKey }, ...HOME_TABS.map(([k, key]) => h('button', { key: k || 'home', role: 'tab', 'aria-selected': tabOn(tab, k), tabIndex: tabOn(tab, k) ? 0 : -1, className: tabOn(tab, k) ? 'on' : '', onClick: () => onTab(k) }, t(key)))),
|
|
14246
|
+
h('div', { className: 'seg on', ref: segRef, role: 'tablist', onKeyDown: onKey }, ...HOME_TABS.map(([k, key]) => h('button', { key: k || 'home', role: 'tab', 'aria-selected': tabOn(tab, k), tabIndex: tabOn(tab, k) ? 0 : -1, className: tabOn(tab, k) ? 'on' : '', onClick: () => onTab(k) }, h(I[k === 'assets' ? 'sparkle' : k === 'mine' ? 'star' : 'home']), t(key)))),
|
|
14212
14247
|
h('div', { className: 'rt' }, actions, back ? h('button', { className: 'ddp-homeback', ...tipA(back.label, '', 'Esc'), onClick: back.run }, h(I.close), h('span', null, back.label)) : null))
|
|
14213
14248
|
}
|
|
14214
14249
|
|
|
@@ -14792,14 +14827,14 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
14792
14827
|
|
|
14793
14828
|
|
|
14794
14829
|
// ── 首页「组件库」(2.0):assets/motion 里一个文件一个能摸的动效组件,卡片里直接跑(iframe,沙盒),看得见的才动 ──
|
|
14795
|
-
const MT_CAT = { ai: 'mtCatAi', button: 'mtCatButton', input: 'mtCatInput', slider: 'mtCatSlider', nav: 'mtCatNav', card: 'mtCatCard', gesture: 'mtCatGesture', loading: 'mtCatLoading', text: 'mtCatText' }
|
|
14830
|
+
const MT_CAT = { mobile: 'mtCatMobile', shop: 'mtCatShop', web: 'mtCatWeb', chart: 'mtCatChart', ai: 'mtCatAi', button: 'mtCatButton', input: 'mtCatInput', slider: 'mtCatSlider', nav: 'mtCatNav', card: 'mtCatCard', gesture: 'mtCatGesture', loading: 'mtCatLoading', text: 'mtCatText' }
|
|
14796
14831
|
const motionStore = { list: null, p: null }
|
|
14797
14832
|
function loadMotion() {
|
|
14798
14833
|
if (motionStore.list) return Promise.resolve(motionStore.list)
|
|
14799
14834
|
if (!motionStore.p) motionStore.p = getJson('motion').then((d) => (motionStore.list = Array.isArray(d.list) ? d.list : []), (e) => { motionStore.p = null; throw e })
|
|
14800
14835
|
return motionStore.p
|
|
14801
14836
|
}
|
|
14802
|
-
const motionSrc = (c, th) => `${API}motion?f=${c.id}.html&theme=${th}`
|
|
14837
|
+
const motionSrc = (c, th) => `${API}motion?f=${c.id}.html&theme=${th}${c.rev ? '&r=' + c.rev : ''}`
|
|
14803
14838
|
const oneLine = (s) => String(s || '').replace(/\s*\n\s*/g, ' ').trim()
|
|
14804
14839
|
/** 「放进对话」:名字、一句话、配方、源码在哪;要脚本的多一句分享包会删脚本 */
|
|
14805
14840
|
function motionText(t, c) {
|
|
@@ -14818,12 +14853,30 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
14818
14853
|
}, [])
|
|
14819
14854
|
return d
|
|
14820
14855
|
}
|
|
14821
|
-
/**
|
|
14856
|
+
/** 只有屏幕附近(上下约一屏半)的卡片才挂组件页:一百多张全开着太吃内存,桌面版也更容易渲染成空白。
|
|
14857
|
+
rootMargin 只对滚动容器本身起作用,所以根要用最近的滚动祖先 */
|
|
14858
|
+
function useNear(ref, always) {
|
|
14859
|
+
const [near, setNear] = useState(!!always)
|
|
14860
|
+
useEffect(() => {
|
|
14861
|
+
const el = ref.current
|
|
14862
|
+
if (always || !el || typeof IntersectionObserver !== 'function') { setNear(true); return undefined }
|
|
14863
|
+
let root = el.parentElement
|
|
14864
|
+
while (root && !/(auto|scroll)/.test(getComputedStyle(root).overflowY)) root = root.parentElement
|
|
14865
|
+
const io = new IntersectionObserver((es) => setNear(es[es.length - 1].isIntersecting), { root, rootMargin: '900px 0px' })
|
|
14866
|
+
io.observe(el)
|
|
14867
|
+
return () => io.disconnect()
|
|
14868
|
+
}, [always])
|
|
14869
|
+
return near
|
|
14870
|
+
}
|
|
14871
|
+
/** 一块活的演示:src 只用挂上那一刻的主题(之后换深浅发消息、不重载);载好了补发一次主题和「该不该动」 */
|
|
14822
14872
|
function MotionStage({ t, c, dark, io, vis, interactive = false }) {
|
|
14823
14873
|
const [flip, setFlip] = useState(false)
|
|
14824
14874
|
const th = dark !== flip ? 'dark' : 'light'
|
|
14825
14875
|
const fr = useRef(null)
|
|
14876
|
+
const box = useRef(null)
|
|
14877
|
+
const near = useNear(box, interactive)
|
|
14826
14878
|
const first = useRef(th)
|
|
14879
|
+
if (!near) first.current = th
|
|
14827
14880
|
const post = (m) => { const f = fr.current; try { if (f && f.contentWindow) f.contentWindow.postMessage(m, '*') } catch { /* 还没载好:onLoad 再发 */ } }
|
|
14828
14881
|
useEffect(() => { post({ theme: th }) }, [th])
|
|
14829
14882
|
// 组件页挂好收消息后会喊一声 ddpMotionReady:这时补发主题和「该不该动」(载入中途换深浅,那条消息会丢)
|
|
@@ -14843,10 +14896,10 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
14843
14896
|
if (!f || !io) return undefined
|
|
14844
14897
|
io.observe(f)
|
|
14845
14898
|
return () => io.unobserve(f)
|
|
14846
|
-
}, [io])
|
|
14847
|
-
return h('div', { className: 'ddp-mtst' + (th === 'light' ? ' light' : '') + (interactive ? ' big' : '') },
|
|
14848
|
-
h('iframe', { ref: fr, tabIndex: interactive ? undefined : -1, 'aria-hidden': interactive ? undefined : true, src: motionSrc(c, first.current),
|
|
14849
|
-
onLoad: () => { post({ theme: th }); post({ ddpPlay: vis ? vis.get(fr.current) !== false : true }) } }),
|
|
14899
|
+
}, [io, near])
|
|
14900
|
+
return h('div', { ref: box, className: 'ddp-mtst' + (th === 'light' ? ' light' : '') + (interactive ? ' big' : '') },
|
|
14901
|
+
near ? h('iframe', { ref: fr, tabIndex: interactive ? undefined : -1, 'aria-hidden': interactive ? undefined : true, src: motionSrc(c, first.current), sandbox: 'allow-scripts', title: t('lang') === 'en' ? c.en : c.zh,
|
|
14902
|
+
onLoad: () => { post({ theme: th }); post({ ddpPlay: vis ? vis.get(fr.current) !== false : true }) } }) : null,
|
|
14850
14903
|
interactive ? h('button', { className: 'tog', ...tipA(t('mtFlip')), onClick: () => setFlip(!flip) }, h(th === 'light' ? I.moon : I.sun)) : null)
|
|
14851
14904
|
}
|
|
14852
14905
|
/** 一组 iframe 的可见性:看得见的才动(离开视野、页签切走都停) */
|
|
@@ -14945,9 +14998,14 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
14945
14998
|
typeof e.style === 'string' ? e.style : '', ...(e.tags || []), names(d.metadata?.categories, e.categories), names(d.metadata?.tags, e.tags)]))
|
|
14946
14999
|
.map((e) => ({ item: e, group: e.kind }))
|
|
14947
15000
|
}
|
|
15001
|
+
// 筛选标签的颜色:同一类到哪都一个色,深到白字看得清(≥4.5:1);没登记的按顺序轮
|
|
15002
|
+
const CHIP_C = { '': '#2f5fe8', mobile: '#15803d', shop: '#c2410c', chart: '#a21caf', ai: '#6d28d9', button: '#1d4ed8', input: '#0e7490', slider: '#b45309', nav: '#4338ca', card: '#be185d', gesture: '#a16207', loading: '#0f766e', text: '#b91c1c',
|
|
15003
|
+
web: '#1d4ed8', app: '#6d28d9', miniprogram: '#15803d', desktop: '#4338ca', tablet: '#0e7490', poster: '#be185d', slides: '#b45309', email: '#0f766e', diagram: '#a16207', embedded: '#b91c1c',
|
|
15004
|
+
min: '#475569', mat: '#0e7490', trend: '#be185d', biz: '#1d4ed8', east: '#b91c1c', community: '#6d28d9' }
|
|
15005
|
+
const CHIP_CYCLE = ['#1d4ed8', '#6d28d9', '#0e7490', '#b45309', '#be185d', '#0f766e', '#4338ca', '#15803d']
|
|
14948
15006
|
function AssetFilterChips({ t, options, value, onChange }) {
|
|
14949
15007
|
return h('div', { className: 'ddp-swf1', role: 'group', 'aria-label': t('assetFilters') },
|
|
14950
|
-
...options.map(([key, label, count]) => h('button', { key, type: 'button', 'aria-pressed': value === key, className: value === key ? 'on' : '',
|
|
15008
|
+
...options.map(([key, label, count], i) => h('button', { key, type: 'button', 'aria-pressed': value === key, className: value === key ? 'on' : '', 'data-k': key, style: { '--c': Object.hasOwn(CHIP_C, key) ? CHIP_C[key] : CHIP_CYCLE[i % CHIP_CYCLE.length] },
|
|
14951
15009
|
onClick: () => onChange(key === value ? '' : key) }, t(label), h('em', null, count))))
|
|
14952
15010
|
}
|
|
14953
15011
|
function AssetOptions({ t, compact, chips, filterName, filtered, sorts, sort, setSort, catalog }) {
|
|
@@ -15042,8 +15100,8 @@ body[data-ds-dark-theme] .ddp .ddp-library-page .ddp-frm .fw>i{background-color:
|
|
|
15042
15100
|
: tab === 'components' ? (motion.list || []).some((x) => x.id === cur) : mk && (tab === 'templates' ? mk.designs : mk.systems).some((x) => x.id === cur))
|
|
15043
15101
|
? h('button', { className: 'dd-bt ghost', onClick: () => open('') }, h(I.back), t('fpBack')) : null,
|
|
15044
15102
|
cur ? null : h('div', { className: 'ddp-mkbar' + (compact ? ' compact' : '') },
|
|
15045
|
-
h('div', { className: 'dd-seg mktabs ddp-assetseg', role: 'tablist', lang: t('lang'), 'aria-label': t('libAssets'), ref: segRef },
|
|
15046
|
-
...ASSET_TABS.map(([k, label], i) => h('button', { key: k, role: 'tab', 'aria-selected': tab === k, className: tab === k ? 'on' : '', onClick: () => setTab(k) }, t(label), h('small', null, counts[i] == null ? '…' : counts[i])))),
|
|
15103
|
+
h('div', { className: 'dd-seg mktabs ddp-assetseg', role: 'tablist', lang: t('lang'), 'aria-label': t('libAssets'), ref: segRef, style: { '--seg-c': (ASSET_LOOK[tab] || ASSET_LOOK.templates)[1] } },
|
|
15104
|
+
...ASSET_TABS.map(([k, label], i) => h('button', { key: k, role: 'tab', 'aria-selected': tab === k, className: tab === k ? 'on' : '', style: { '--tab-c': ASSET_LOOK[k][1] }, onClick: () => setTab(k) }, h(I[ASSET_LOOK[k][0]]), t(label), h('small', null, counts[i] == null ? '…' : counts[i])))),
|
|
15047
15105
|
h('label', { className: 'dd-q mkq' }, h(I.search), h('input', { type: 'search', value: q, placeholder: search, 'aria-label': search, onChange: (e) => setQ(e.target.value) })),
|
|
15048
15106
|
(sorts.length > 0 || (compact && chips)) && h(AssetOptions, { key: tab, t, compact, chips: compact && chips, filterName, filtered: !!filter,
|
|
15049
15107
|
sorts, sort, setSort, catalog: market ? catalog : null }),
|
package/lib/index.js
CHANGED
|
@@ -2078,15 +2078,19 @@ export function apply(ctx) {
|
|
|
2078
2078
|
}
|
|
2079
2079
|
|
|
2080
2080
|
/** GET ?session= → 设计目录里写死的颜色有多少(试穿风格「就用这个」之后提示:这些不跟着变)、有没有深色版 */
|
|
2081
|
+
// 组件页地址带上内容指纹:响应缓存一小时,升级插件后不能还拿旧的那份(不能用文件时间:npm 打包把时间全固定成 1985 年)
|
|
2082
|
+
const motionRev = (id) => { try { return crypto.createHash('sha1').update(fs.readFileSync(path.join(MOTION_DIR, id + '.html'))).digest('hex').slice(0, 10) } catch { return '0' } }
|
|
2081
2083
|
// GET motion → 组件库清单(带源码在哪,「放进对话」时告诉模型);GET motion?f=like-jelly.html → 那个组件(只认清单里的 id)。
|
|
2082
2084
|
// 组件是我们自己写的,但会跑脚本:响应头 CSP sandbox 让它是不透明来源,直接在标签页打开也碰不到 DSH 的登录和接口
|
|
2083
2085
|
function motionRoute(req, res) {
|
|
2084
2086
|
if (!admit(req, res)) return
|
|
2085
2087
|
const f = new URL(req.url, 'http://x').searchParams.get('f')
|
|
2086
|
-
if (f == null) return json(res, 200, { list: listMotion().map((c) => ({ ...c, file: path.join(MOTION_DIR, c.id + '.html') })) })
|
|
2088
|
+
if (f == null) return json(res, 200, { list: listMotion().map((c) => ({ ...c, file: path.join(MOTION_DIR, c.id + '.html'), rev: motionRev(c.id) })) })
|
|
2087
2089
|
const code = /^[a-z][a-z0-9-]{1,40}\.html$/.test(f) ? motionFile(f.slice(0, -5)) : null
|
|
2088
2090
|
if (code == null) return json(res, 404, { error: 'no such component' })
|
|
2089
|
-
|
|
2091
|
+
// 深色时一开始就带上主题:舞台脚本在页尾才设,晚一步会先闪一下浅底
|
|
2092
|
+
const dark = new URL(req.url, 'http://x').searchParams.get('theme') === 'dark'
|
|
2093
|
+
const buf = Buffer.from(dark ? code.replace('<html ', '<html data-theme="dark" ') : code, 'utf8')
|
|
2090
2094
|
res.writeHead(200, {
|
|
2091
2095
|
'Content-Type': 'text/html; charset=utf-8',
|
|
2092
2096
|
'Content-Length': buf.length,
|
package/lib/motion.js
CHANGED
|
@@ -7,9 +7,9 @@ import path from 'node:path'
|
|
|
7
7
|
import { fileURLToPath } from 'node:url'
|
|
8
8
|
|
|
9
9
|
export const MOTION_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'assets', 'motion')
|
|
10
|
-
export const MOTION_CATS = ['ai', 'button', 'input', 'slider', 'nav', 'card', 'gesture', 'loading', 'text']
|
|
10
|
+
export const MOTION_CATS = ['mobile', 'shop', 'web', 'chart', 'ai', 'button', 'input', 'slider', 'nav', 'card', 'gesture', 'loading', 'text']
|
|
11
11
|
const FIRST = ['like-jelly', 'dock-magnify', 'dial-knob', 'token-stream']
|
|
12
|
-
const OK_SRC = ['magicuidesign/magicui', 'codse/animata', 'nolly-studio/cult-ui', 'ibelick/motion-primitives', 'uiverse-io/galaxy', 'tobiasahlin/SpinKit', 'educlopez/smoothui', 'unovue/inspira-ui', 'vineethtrv/css-loader', 'emilkowalski/sonner', 'emilkowalski/vaul', 'pacocoursey/cmdk', 'origin-space/originui', 'shadcn-ui/ui']
|
|
12
|
+
const OK_SRC = ['magicuidesign/magicui', 'codse/animata', 'nolly-studio/cult-ui', 'ibelick/motion-primitives', 'uiverse-io/galaxy', 'tobiasahlin/SpinKit', 'educlopez/smoothui', 'unovue/inspira-ui', 'youzan/vant', 'youzan/vant-weapp', 'guanmo-ai/ui-moments', 'framework7io/framework7', 'konstaui/konsta', 'saadeghi/daisyui', 'markmead/hyperui', 'ChartsCSS/charts.css', 'dip/cmdk', 'Tencent/weui', 'Tencent/tdesign-miniprogram', 'Tencent/tdesign-miniprogram-starter-retail', 'vineethtrv/css-loader', 'emilkowalski/sonner', 'emilkowalski/vaul', 'pacocoursey/cmdk', 'origin-space/originui', 'shadcn-ui/ui']
|
|
13
13
|
const ID_RE = /^[a-z][a-z0-9-]{1,40}$/
|
|
14
14
|
|
|
15
15
|
export function readMeta (code) {
|
|
@@ -69,7 +69,16 @@ export function lintMotion (raw, id) {
|
|
|
69
69
|
}
|
|
70
70
|
const kb = Buffer.byteLength(code.replace(/<script type="application\/json" id="meta">[\s\S]*?<\/script>/, '')) / 1024; const cap = meta.source ? 16 : 12 // meta(中英说明、配方)不算
|
|
71
71
|
if (kb > cap) bad.push(`文件 ${kb.toFixed(1)}KB,超过 ${cap}KB`)
|
|
72
|
+
// 下面三条是桌面版 / 真实打字踩过的坑
|
|
73
|
+
const markup = (code.match(/class="stage-fit"[\s\S]*?(?=<script)/) || [''])[0]
|
|
74
|
+
const script = (code.match(/<script data-comp>([\s\S]*?)<\/script>/) || ['', ''])[1]
|
|
75
|
+
const typing = /<textarea\b|contenteditable|<input\b(?![^>]*type="(?:checkbox|radio|range|color|file)")[^>]*>/.test(markup)
|
|
76
|
+
if (/type="submit"|addEventListener\(\s*['"]submit['"]|requestSubmit|\.submit\(\)/.test(code) || /<form\b(?:(?!<\/form>)[\s\S])*?<button\b(?![^>]*\btype=)/.test(markup)) bad.push('别靠表单提交:组件页在沙盒里,submit 事件根本不触发;按钮写 type="button",回车在 keydown 里处理')
|
|
77
|
+
if (typing && /\binnerHTML\s*\+?=/.test(script)) bad.push('有输入框的组件别用 innerHTML:用户打的字会被当网页代码;用 createElement + textContent,或把内容写在页面里只切显示')
|
|
78
|
+
if (typing && /['"]Enter['"]/.test(script) && !/isComposing/.test(script)) bad.push('管回车要挡住拼音没上屏的那一下:if (e.isComposing) 时不算确认')
|
|
79
|
+
if ((/<[a-z][^>]*\shidden(?=[\s>=/])/.test(markup) || /\.hidden\s*=|(?:set|toggle)Attribute\(\s*['"]hidden/.test(script)) && !/\[hidden\]\s*\{[^}]*display\s*:\s*none\s*!important/.test(code)) bad.push('用了 hidden 就要写 [hidden]{display:none!important}:不然后面某条 display 会把它盖掉,藏不住')
|
|
72
80
|
for (const t of ['<style data-stage>', '<style data-comp>', '<script data-stage>', 'class="stage-fit"', '只改这一段']) if (!code.includes(t)) bad.push('缺 ' + t)
|
|
81
|
+
if (!code.includes('if (innerWidth > 0 && innerHeight > 0)') || !code.includes('new ResizeObserver(fit).observe(root)')) bad.push('舞台缩放要挡住 0 宽高、框变化时重算(桌面版会卡成空白)')
|
|
73
82
|
if (!new RegExp(`class="c-${id}[" ]`).test(code) || !code.includes(`data-comp="${id}"`)) bad.push('根元素 class / data-comp 不对')
|
|
74
83
|
if (!/@media\s*\(prefers-reduced-motion:\s*reduce\)/.test(code)) bad.push('缺减少动效')
|
|
75
84
|
if (/localStorage|sessionStorage|indexedDB/.test(code)) bad.push('用了浏览器存储')
|