@whzxc/agent-design-gallery 0.14.1 → 0.16.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.md +29 -16
- package/package.json +2 -1
- package/public/access.css +15 -2
- package/public/app.js +1284 -521
- package/public/arrangement-worker.js +7 -7
- package/public/arrangement.js +35 -30
- package/public/assets.js +85 -48
- package/public/auth.js +59 -4
- package/public/boards.js +129 -0
- package/public/comment-anchors.js +50 -0
- package/public/comments.css +400 -0
- package/public/comments.js +1106 -0
- package/public/context-menu.js +97 -0
- package/public/frame-identity.js +51 -14
- package/public/hub.css +25 -3
- package/public/hub.html +10 -2
- package/public/hub.js +127 -23
- package/public/icons.js +9 -0
- package/public/index.html +26 -10
- package/public/instance-actions.js +9 -2
- package/public/layout.js +156 -86
- package/public/motion-flow.js +28 -0
- package/public/motion-identity.js +100 -0
- package/public/motion-paint.js +332 -0
- package/public/motion-scene.js +165 -0
- package/public/motion-specimens.js +335 -0
- package/public/player.css +270 -0
- package/public/player.js +753 -0
- package/public/recent-updates.js +535 -0
- package/public/selection.js +1 -1
- package/public/style.css +91 -154
- package/public/switcher.css +5 -4
- package/public/switcher.js +109 -34
- package/public/token-catalog.js +8 -3
- package/public/tokens.css +20 -1
- package/public/view-boards.css +131 -0
- package/public/view-boards.js +350 -0
- package/public/view-route.js +1 -2
- package/src/boards/board.mjs +30 -0
- package/src/boards/motion-board.mjs +202 -0
- package/src/boards/token-board.mjs +200 -0
- package/src/cli-output.mjs +10 -5
- package/src/cli.mjs +89 -35
- package/src/comments.mjs +293 -0
- package/src/http.mjs +7 -5
- package/src/hub/project-link.mjs +41 -0
- package/src/hub/registry.mjs +5 -0
- package/src/hub.mjs +14 -10
- package/src/link.mjs +13 -1
- package/src/recent-frames.mjs +295 -0
- package/src/recent-history.mjs +100 -0
- package/src/recent-job.mjs +63 -0
- package/src/recent-worker.mjs +171 -0
- package/src/server.mjs +285 -110
- package/src/service.mjs +46 -12
- package/src/toolkit/arch-git.mjs +8 -14
- package/src/toolkit/arch.mjs +3 -2
- package/src/toolkit/asset-rules.mjs +24 -1
- package/src/toolkit/browser.mjs +1 -13
- package/src/toolkit/build-store.mjs +9 -1
- package/src/toolkit/build-worker.mjs +6 -0
- package/src/toolkit/build.mjs +22 -16
- package/src/toolkit/commands.mjs +105 -9
- package/src/toolkit/compare.mjs +13 -11
- package/src/toolkit/config.mjs +2 -2
- package/{public/review.js → src/toolkit/diff-document.mjs} +137 -43
- package/src/toolkit/diff-inputs.mjs +97 -52
- package/src/toolkit/diff.mjs +198 -43
- package/src/toolkit/frame-declarations.mjs +36 -0
- package/src/toolkit/git-blobs.mjs +50 -0
- package/src/toolkit/impact-inputs.mjs +11 -19
- package/src/toolkit/impact-selection.mjs +27 -12
- package/src/toolkit/impact.mjs +49 -15
- package/src/toolkit/implementation-map.mjs +17 -6
- package/src/toolkit/input-generation.mjs +15 -0
- package/src/toolkit/inspect-output.mjs +1 -1
- package/src/toolkit/inspect.d.ts +9 -1
- package/src/toolkit/inspect.mjs +25 -1
- package/src/toolkit/motion-check.mjs +382 -0
- package/src/toolkit/motion-css.mjs +105 -0
- package/src/toolkit/motion-flows.mjs +95 -0
- package/src/toolkit/motion-impact.mjs +87 -0
- package/src/toolkit/motion-inventory.mjs +202 -0
- package/src/toolkit/motion-label.mjs +111 -0
- package/src/toolkit/motion-patterns.mjs +216 -0
- package/src/toolkit/motion-primitives.mjs +94 -0
- package/src/toolkit/motion-queries.mjs +169 -0
- package/src/toolkit/motion.mjs +300 -0
- package/src/toolkit/move-pairing.mjs +140 -0
- package/src/toolkit/owner.mjs +19 -6
- package/src/toolkit/play-endpoint.mjs +66 -0
- package/src/toolkit/project-index.mjs +4 -4
- package/src/toolkit/recent-structure.mjs +201 -0
- package/src/toolkit/results.mjs +3 -3
- package/src/toolkit/review-document.mjs +440 -0
- package/src/toolkit/review-embed-document.mjs +671 -0
- package/src/toolkit/review-filmstrip.mjs +76 -0
- package/src/toolkit/review-groups.mjs +29 -0
- package/src/toolkit/review-motion-card.mjs +51 -0
- package/src/toolkit/review-motion.mjs +159 -0
- package/src/toolkit/review-observation.mjs +131 -0
- package/src/toolkit/review-playback.js +123 -0
- package/src/toolkit/review-sheet.mjs +125 -0
- package/src/toolkit/review-specimens.mjs +60 -0
- package/src/toolkit/review.mjs +240 -0
- package/src/toolkit/runtime.mjs +8 -2
- package/src/toolkit/theme.mjs +16 -0
- package/src/viewer-cache.mjs +48 -12
- package/public/annotations.js +0 -816
- package/public/labels.js +0 -122
- package/src/annotations.mjs +0 -238
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { dataFetch } from './auth.js';
|
|
2
|
+
|
|
3
|
+
const reduced = matchMedia('(prefers-reduced-motion: reduce)');
|
|
4
|
+
const clamp = (value, lower, upper) => Math.min(upper, Math.max(lower, value));
|
|
5
|
+
const shapes = stage => [...stage.querySelectorAll('[data-motion-shape]')];
|
|
6
|
+
function parameters(stage) {
|
|
7
|
+
const dark = stage.closest('[data-theme="dark"]');
|
|
8
|
+
return JSON.parse(stage.dataset.preview)[dark ? 'dark' : 'light'];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function states(effect, on, off, index) {
|
|
12
|
+
const opacity = (a, b) => [{ opacity: a }, { opacity: b }];
|
|
13
|
+
const transform = (from, to, a = 1, b = 1) => [
|
|
14
|
+
{ transform: from, opacity: a }, { transform: to, opacity: b },
|
|
15
|
+
];
|
|
16
|
+
switch (effect) {
|
|
17
|
+
case 'expand': return [{ height: '2px', opacity: off.opacity }, { height: '58px', opacity: 1 }];
|
|
18
|
+
case 'size': return [{ width: '40px', height: '24px' }, { width: '105px', height: '66px' }];
|
|
19
|
+
case 'slide': return transform('translateX(' + (off.distance ?? '20px') + ')', 'translateX(0)', off.opacity);
|
|
20
|
+
case 'pop': return transform('scale(' + off.scale + ')', 'scale(1)', off.opacity);
|
|
21
|
+
case 'stagger': return transform('translateY(' + (off.distance ?? '20px') + ')', 'translateY(0)', off.opacity);
|
|
22
|
+
case 'crossfade': return opacity(index ? 0 : 1, index ? 1 : 0);
|
|
23
|
+
case 'pulse': return transform('scale(' + on.scale + ')', 'scale(1)', .35);
|
|
24
|
+
default: return opacity(off.opacity, 1);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function animateStage(stage) {
|
|
29
|
+
const { enter, exit } = parameters(stage);
|
|
30
|
+
const effect = stage.dataset.effect;
|
|
31
|
+
if (effect === 'follow' || reduced.matches) return [];
|
|
32
|
+
if (effect === 'avoid') {
|
|
33
|
+
return shapes(stage).slice(1).map((node, i) => node.animate([
|
|
34
|
+
{ transform: 'translateY(0)', offset: 0, easing: enter.easing },
|
|
35
|
+
{ transform: 'translateY(' + (i ? 12 : -12) + 'px)', offset: .35, easing: exit.easing },
|
|
36
|
+
{ transform: 'translateY(' + (i ? 12 : -12) + 'px)', offset: .55, easing: exit.easing },
|
|
37
|
+
{ transform: 'translateY(0)', offset: .85 },
|
|
38
|
+
{ transform: 'translateY(0)', offset: 1 },
|
|
39
|
+
], { duration: enter.duration + exit.duration + 850, iterations: Infinity }));
|
|
40
|
+
}
|
|
41
|
+
if (['aurora','shimmer','spin'].includes(effect)) {
|
|
42
|
+
const aurora = effect === 'aurora';
|
|
43
|
+
const animated = stage.querySelector(aurora ? '[data-motion-aurora]' : '[data-motion-shape]');
|
|
44
|
+
const frames = effect !== 'shimmer' ? [{transform:'rotate(0turn)'},{transform:'rotate(1turn)'}]
|
|
45
|
+
: [{backgroundPosition:'100% 0'},{backgroundPosition:'0% 0'}];
|
|
46
|
+
return [animated.animate(frames, { duration: Math.max(1, enter.duration), easing: enter.easing, iterations: Infinity })];
|
|
47
|
+
}
|
|
48
|
+
if (effect === 'pulse' && stage.dataset.action === 'loop') {
|
|
49
|
+
return shapes(stage).map(node => node.animate([
|
|
50
|
+
{ transform: 'scale(1)', opacity: 1 },
|
|
51
|
+
{ transform: 'scale(' + enter.scale + ')', opacity: .35 },
|
|
52
|
+
{ transform: 'scale(1)', opacity: 1 },
|
|
53
|
+
], { duration: Math.max(1, enter.duration), easing: enter.easing, iterations: Infinity }));
|
|
54
|
+
}
|
|
55
|
+
const first = stage.dataset.action === 'exit' ? exit : enter;
|
|
56
|
+
const second = stage.dataset.action === 'exit' ? enter : exit;
|
|
57
|
+
const pulse = effect === 'pulse';
|
|
58
|
+
const hold = pulse ? 0 : 450;
|
|
59
|
+
const stagger = effect === 'stagger' ? first.stagger : 0;
|
|
60
|
+
const total = Math.max(1, first.duration + second.duration + 2 * hold + 2 * stagger);
|
|
61
|
+
return shapes(stage).map((node, i) => {
|
|
62
|
+
const [from, to] = states(effect, first, first, i);
|
|
63
|
+
const [exitFrom, exitTo] = states(effect, second, second, i);
|
|
64
|
+
const reverse = stage.dataset.action === 'exit';
|
|
65
|
+
const start = reverse ? to : from, end = reverse ? from : to;
|
|
66
|
+
const returnStart = reverse ? exitFrom : exitTo, returnEnd = reverse ? exitTo : exitFrom;
|
|
67
|
+
const delay = i * stagger;
|
|
68
|
+
return node.animate([
|
|
69
|
+
{ ...start, offset: 0 },
|
|
70
|
+
{ ...start, offset: delay / total, easing: first.easing },
|
|
71
|
+
{ ...end, offset: (delay + first.duration) / total },
|
|
72
|
+
{ ...returnStart, offset: (delay + first.duration + hold) / total, easing: second.easing },
|
|
73
|
+
{ ...returnEnd, offset: (delay + first.duration + hold + second.duration) / total },
|
|
74
|
+
{ ...returnEnd, offset: 1 },
|
|
75
|
+
], { duration: total, iterations: Infinity });
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function openDialog(title, body) {
|
|
80
|
+
const dialog = document.createElement('dialog');
|
|
81
|
+
dialog.className = 'motion-consumer-dialog';
|
|
82
|
+
dialog.setAttribute('aria-label', title);
|
|
83
|
+
const heading = document.createElement('h2');
|
|
84
|
+
heading.textContent = title;
|
|
85
|
+
const close = document.createElement('button');
|
|
86
|
+
close.type = 'button';
|
|
87
|
+
close.textContent = 'Close';
|
|
88
|
+
close.onclick = () => dialog.close();
|
|
89
|
+
dialog.append(heading, body, close);
|
|
90
|
+
document.body.append(dialog);
|
|
91
|
+
dialog.addEventListener('close', () => dialog.remove(), { once: true });
|
|
92
|
+
dialog.showModal();
|
|
93
|
+
}
|
|
94
|
+
async function showCode(link) {
|
|
95
|
+
const content = document.createElement('pre');
|
|
96
|
+
content.textContent = 'Loading…';
|
|
97
|
+
openDialog(link.textContent, content);
|
|
98
|
+
try {
|
|
99
|
+
const response = await dataFetch(link.href);
|
|
100
|
+
if (!response.ok) throw new Error('Source location is unavailable.');
|
|
101
|
+
const { lines, line } = await response.json();
|
|
102
|
+
for (const [number, source] of lines) {
|
|
103
|
+
const row = document.createElement(number === line ? 'mark' : 'span');
|
|
104
|
+
row.textContent = number + ' ' + source + '\n';
|
|
105
|
+
content.append(row);
|
|
106
|
+
}
|
|
107
|
+
content.firstChild.remove();
|
|
108
|
+
} catch (error) { content.textContent = error.message; }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function installMotionSpecimens(board) {
|
|
112
|
+
const mounted = new Map();
|
|
113
|
+
const visible = new Set();
|
|
114
|
+
const points = new WeakMap();
|
|
115
|
+
const running = new WeakMap();
|
|
116
|
+
const manualAvoid = new WeakSet();
|
|
117
|
+
let inline, page;
|
|
118
|
+
const triggerFor = card => card.querySelector('[data-motion-toggle]');
|
|
119
|
+
const detailFor = card => card.querySelector('[data-motion-template]').content.firstElementChild.cloneNode(true);
|
|
120
|
+
const layoutChanged = node => node.dispatchEvent(new Event('motion-layout-change', {bubbles: true}));
|
|
121
|
+
|
|
122
|
+
function closeInline({ focus = true } = {}) {
|
|
123
|
+
if (!inline) return;
|
|
124
|
+
const { card, panel } = inline;
|
|
125
|
+
inline = null;
|
|
126
|
+
panel.remove();
|
|
127
|
+
const trigger = triggerFor(card);
|
|
128
|
+
card.removeAttribute('data-expanded');
|
|
129
|
+
trigger.setAttribute('aria-expanded', 'false');
|
|
130
|
+
trigger.removeAttribute('aria-controls');
|
|
131
|
+
if (focus && card.isConnected) trigger.focus({preventScroll: true});
|
|
132
|
+
layoutChanged(card);
|
|
133
|
+
mount();
|
|
134
|
+
}
|
|
135
|
+
function toggleInline(card) {
|
|
136
|
+
if (inline?.card === card) {
|
|
137
|
+
closeInline();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
closeInline({focus: false});
|
|
141
|
+
const grid = card.parentElement;
|
|
142
|
+
const cards = [...grid.children];
|
|
143
|
+
const columns = Number(getComputedStyle(grid).getPropertyValue('--motion-columns'));
|
|
144
|
+
const rowEnd = Math.min(cards.length, (Math.floor(cards.indexOf(card) / columns) + 1) * columns);
|
|
145
|
+
const panel = detailFor(card);
|
|
146
|
+
cards[rowEnd - 1].after(panel);
|
|
147
|
+
inline = {card, panel};
|
|
148
|
+
card.setAttribute('data-expanded', '');
|
|
149
|
+
const trigger = triggerFor(card);
|
|
150
|
+
trigger.setAttribute('aria-expanded', 'true');
|
|
151
|
+
trigger.setAttribute('aria-controls', panel.id);
|
|
152
|
+
trigger.focus({preventScroll: true});
|
|
153
|
+
layoutChanged(card);
|
|
154
|
+
mount();
|
|
155
|
+
}
|
|
156
|
+
function openPage() {
|
|
157
|
+
const id = new URLSearchParams(location.search).get('pattern');
|
|
158
|
+
if (!id || page?.isConnected) return;
|
|
159
|
+
const card = board.querySelector(`[data-motion-pattern="${CSS.escape(id)}"]`);
|
|
160
|
+
if (!card) return;
|
|
161
|
+
const dialog = document.createElement('dialog');
|
|
162
|
+
const detail = detailFor(card);
|
|
163
|
+
dialog.dataset.motionPage = id;
|
|
164
|
+
dialog.setAttribute('aria-labelledby', detail.getAttribute('aria-labelledby'));
|
|
165
|
+
dialog.append(detail);
|
|
166
|
+
dialog.addEventListener('wheel', event => event.stopPropagation(), {passive: true});
|
|
167
|
+
dialog.addEventListener('close', () => {
|
|
168
|
+
if (!dialog.isConnected) return;
|
|
169
|
+
dialog.remove();
|
|
170
|
+
page = null;
|
|
171
|
+
const url = new URL(location.href);
|
|
172
|
+
url.searchParams.delete('pattern');
|
|
173
|
+
history.replaceState(history.state, '', url);
|
|
174
|
+
const focus = card.closest('details:not([open])')?.querySelector('summary') ?? triggerFor(card);
|
|
175
|
+
focus.focus({preventScroll: true});
|
|
176
|
+
mount();
|
|
177
|
+
}, {once: true});
|
|
178
|
+
card.closest('[data-adg-board]').append(dialog);
|
|
179
|
+
page = dialog;
|
|
180
|
+
dialog.showModal();
|
|
181
|
+
}
|
|
182
|
+
function sync(stage) {
|
|
183
|
+
for (const animation of mounted.get(stage) ?? []) animation.cancel();
|
|
184
|
+
mounted.set(stage, visible.has(stage) && !manualAvoid.has(stage) ? animateStage(stage) : []);
|
|
185
|
+
}
|
|
186
|
+
const intersection = new IntersectionObserver(entries => {
|
|
187
|
+
for (const { target, isIntersecting } of entries) {
|
|
188
|
+
if (!mounted.has(target)) continue;
|
|
189
|
+
if (isIntersecting) visible.add(target);
|
|
190
|
+
else visible.delete(target);
|
|
191
|
+
sync(target);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
function mount() {
|
|
195
|
+
if (inline && !inline.panel.isConnected) inline = null;
|
|
196
|
+
openPage();
|
|
197
|
+
for (const [stage, animations] of mounted) if (!board.contains(stage)) {
|
|
198
|
+
for (const animation of animations) animation.cancel();
|
|
199
|
+
intersection.unobserve(stage);
|
|
200
|
+
mounted.delete(stage);
|
|
201
|
+
visible.delete(stage);
|
|
202
|
+
}
|
|
203
|
+
for (const stage of board.querySelectorAll('[data-motion-stage]')) if (!mounted.has(stage)) {
|
|
204
|
+
mounted.set(stage, []);
|
|
205
|
+
intersection.observe(stage);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Token markup is replaced as a unit. Camera updates never recreate specimens.
|
|
209
|
+
new MutationObserver(mount).observe(board, { childList: true });
|
|
210
|
+
const reset = () => {
|
|
211
|
+
for (const stage of mounted.keys()) {
|
|
212
|
+
sync(stage);
|
|
213
|
+
for (const node of shapes(stage)) running.get(node)?.cancel();
|
|
214
|
+
if (stage.dataset.effect === 'follow' && reduced.matches) {
|
|
215
|
+
shapes(stage)[0].style.removeProperty('transform');
|
|
216
|
+
points.delete(stage);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
reduced.addEventListener('change', reset);
|
|
221
|
+
new MutationObserver(reset).observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
|
|
222
|
+
mount();
|
|
223
|
+
|
|
224
|
+
function follow(stage, x, y) {
|
|
225
|
+
const node = shapes(stage)[0];
|
|
226
|
+
const from = getComputedStyle(node).transform;
|
|
227
|
+
const to = 'translate(' + x + 'px,' + y + 'px)';
|
|
228
|
+
node.style.transform = to;
|
|
229
|
+
running.get(node)?.cancel();
|
|
230
|
+
points.set(stage, [x,y]);
|
|
231
|
+
if (!reduced.matches) {
|
|
232
|
+
const { duration, easing } = parameters(stage).enter;
|
|
233
|
+
running.set(node, node.animate([{ transform: from }, { transform: to }], { duration, easing }));
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
board.addEventListener('pointerdown', event => {
|
|
237
|
+
if (event.target.closest('[data-motion-pattern], [data-motion-detail], [data-motion-unadopted] summary'))
|
|
238
|
+
event.stopPropagation();
|
|
239
|
+
});
|
|
240
|
+
board.addEventListener('toggle', event => {
|
|
241
|
+
if (inline?.card.closest('[data-motion-unadopted]') === event.target && !event.target.open) closeInline({focus: false});
|
|
242
|
+
}, true);
|
|
243
|
+
document.addEventListener('keydown', event => {
|
|
244
|
+
if (event.key !== 'Escape' || event.defaultPrevented || !inline?.panel.isConnected ||
|
|
245
|
+
document.querySelector('dialog[open], :popover-open')) return;
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
closeInline();
|
|
248
|
+
});
|
|
249
|
+
board.addEventListener('pointermove', event => {
|
|
250
|
+
const stage = event.target.closest('[data-effect=follow]');
|
|
251
|
+
if (!stage || reduced.matches) return;
|
|
252
|
+
const box = stage.getBoundingClientRect();
|
|
253
|
+
const x = ((event.clientX - box.left) / box.width - .5) * (stage.clientWidth - 20);
|
|
254
|
+
const y = ((event.clientY - box.top) / box.height - .5) * (stage.clientHeight - 20);
|
|
255
|
+
follow(stage, x, y);
|
|
256
|
+
});
|
|
257
|
+
board.addEventListener('keydown', event => {
|
|
258
|
+
const stage = event.target.closest('[data-effect=follow]');
|
|
259
|
+
const steps = { ArrowLeft: [-1,0], ArrowRight: [1,0], ArrowUp: [0,-1], ArrowDown: [0,1] };
|
|
260
|
+
if (!stage || !Object.hasOwn(steps, event.key)) return;
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
event.stopPropagation();
|
|
263
|
+
if (reduced.matches) return;
|
|
264
|
+
const [x,y] = points.get(stage) ?? [0,0];
|
|
265
|
+
const [dx,dy] = steps[event.key];
|
|
266
|
+
const maxX = (stage.clientWidth - 20) / 2, maxY = (stage.clientHeight - 20) / 2;
|
|
267
|
+
follow(stage, clamp(x + dx * 12, -maxX, maxX), clamp(y + dy * 12, -maxY, maxY));
|
|
268
|
+
});
|
|
269
|
+
board.addEventListener('click', event => {
|
|
270
|
+
const card = event.target.closest('[data-motion-pattern]');
|
|
271
|
+
if (card) {
|
|
272
|
+
event.stopPropagation();
|
|
273
|
+
toggleInline(card);
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const detail = event.target.closest('[data-motion-detail]');
|
|
277
|
+
if (!detail) return;
|
|
278
|
+
const stage = detail.querySelector('[data-motion-stage]');
|
|
279
|
+
if (event.target.closest('[data-motion-close]')) {
|
|
280
|
+
const dialog = detail.closest('[data-motion-page]');
|
|
281
|
+
if (dialog) dialog.close();
|
|
282
|
+
else closeInline();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
if (event.target.closest('[data-motion-replay]')) {
|
|
286
|
+
for (const node of shapes(stage)) {
|
|
287
|
+
running.get(node)?.cancel();
|
|
288
|
+
node.style.removeProperty('transform');
|
|
289
|
+
}
|
|
290
|
+
points.delete(stage);
|
|
291
|
+
manualAvoid.delete(stage);
|
|
292
|
+
const sibling = stage.querySelector('[data-motion-sibling]');
|
|
293
|
+
if (sibling) {
|
|
294
|
+
sibling.hidden = true;
|
|
295
|
+
const control = detail.querySelector('[data-motion-avoid]');
|
|
296
|
+
control.setAttribute('aria-pressed', 'false');
|
|
297
|
+
control.textContent = 'Insert sibling';
|
|
298
|
+
}
|
|
299
|
+
sync(stage);
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const avoid = event.target.closest('[data-motion-avoid]');
|
|
303
|
+
if (avoid) {
|
|
304
|
+
const [sibling, ...others] = shapes(stage);
|
|
305
|
+
const first = others.map(node => {
|
|
306
|
+
const transform = getComputedStyle(node).transform;
|
|
307
|
+
return node.offsetTop + (transform === 'none' ? 0 : new DOMMatrixReadOnly(transform).m42);
|
|
308
|
+
});
|
|
309
|
+
manualAvoid.add(stage);
|
|
310
|
+
sync(stage);
|
|
311
|
+
const insert = sibling.hidden;
|
|
312
|
+
sibling.hidden = !insert;
|
|
313
|
+
avoid.setAttribute('aria-pressed', String(insert));
|
|
314
|
+
avoid.textContent = insert ? 'Remove sibling' : 'Insert sibling';
|
|
315
|
+
const { duration, easing } = parameters(stage)[insert ? 'enter' : 'exit'];
|
|
316
|
+
others.forEach((node, i) => {
|
|
317
|
+
running.get(node)?.cancel();
|
|
318
|
+
if (!reduced.matches) running.set(node, node.animate([
|
|
319
|
+
{ transform: 'translateY(' + (first[i] - node.offsetTop) + 'px)' }, { transform: 'translateY(0)' },
|
|
320
|
+
], { duration, easing }));
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
const consumers = event.target.closest('[data-motion-consumers]');
|
|
324
|
+
if (consumers) {
|
|
325
|
+
event.stopPropagation();
|
|
326
|
+
openDialog(consumers.dataset.motionConsumers + ' consumers', consumers.nextElementSibling.content.cloneNode(true));
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
document.addEventListener('click', event => {
|
|
330
|
+
const link = event.target.closest('[data-motion-code]');
|
|
331
|
+
if (!link) return;
|
|
332
|
+
event.preventDefault();
|
|
333
|
+
void showCode(link);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
#motion-player {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
width: 100vw;
|
|
6
|
+
height: 100dvh;
|
|
7
|
+
max-width: none;
|
|
8
|
+
max-height: none;
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
border: 0;
|
|
12
|
+
color: var(--text);
|
|
13
|
+
background: radial-gradient(var(--dot) 1px, transparent 1px) 0 0/20px 20px var(--canvas);
|
|
14
|
+
font: var(--text-body) var(--font-ui);
|
|
15
|
+
}
|
|
16
|
+
#motion-player[open] {
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template: auto minmax(0, 1fr) / minmax(0, 1fr);
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
#motion-player [hidden] {
|
|
22
|
+
display: none !important;
|
|
23
|
+
}
|
|
24
|
+
.play-header {
|
|
25
|
+
padding: 12px 20px;
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: space-between;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
z-index: 1;
|
|
31
|
+
}
|
|
32
|
+
.play-header > div,
|
|
33
|
+
.play-header > nav,
|
|
34
|
+
.play-rail,
|
|
35
|
+
.play-settings,
|
|
36
|
+
.play-dock {
|
|
37
|
+
border: 1px solid var(--border);
|
|
38
|
+
border-radius: var(--radius-panel);
|
|
39
|
+
background: var(--surface);
|
|
40
|
+
box-shadow: var(--shadow-float);
|
|
41
|
+
}
|
|
42
|
+
.play-project {
|
|
43
|
+
padding: 0 12px 0 6px;
|
|
44
|
+
border-right: 1px solid var(--border);
|
|
45
|
+
font-size: var(--text-title);
|
|
46
|
+
}
|
|
47
|
+
.play-project, #motion-player button {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
gap: 8px;
|
|
52
|
+
}
|
|
53
|
+
.play-header > div,
|
|
54
|
+
.play-header > nav {
|
|
55
|
+
display: flex;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: 12px;
|
|
58
|
+
padding: 5px 8px;
|
|
59
|
+
}
|
|
60
|
+
#motion-player button {
|
|
61
|
+
min-height: var(--control-size);
|
|
62
|
+
padding: 6px 12px;
|
|
63
|
+
border-radius: var(--radius-field);
|
|
64
|
+
background: var(--surface-sunken);
|
|
65
|
+
color: var(--text);
|
|
66
|
+
font: 550 var(--text-body) var(--font-ui);
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
}
|
|
69
|
+
#motion-player button[aria-expanded='true'] { background: var(--surface-selected, var(--surface-sunken)); }
|
|
70
|
+
#motion-player button:disabled { opacity: .5; cursor: default; }
|
|
71
|
+
#motion-player button:focus-visible,
|
|
72
|
+
#motion-player input:focus-visible {
|
|
73
|
+
outline: 2px solid var(--accent);
|
|
74
|
+
outline-offset: 2px;
|
|
75
|
+
}
|
|
76
|
+
.play-header > nav {
|
|
77
|
+
flex-wrap: wrap;
|
|
78
|
+
justify-content: flex-end;
|
|
79
|
+
}
|
|
80
|
+
.play-navigation {
|
|
81
|
+
display: flex;
|
|
82
|
+
align-items: center;
|
|
83
|
+
gap: 4px;
|
|
84
|
+
}
|
|
85
|
+
.play-end {
|
|
86
|
+
font-size: var(--text-meta);
|
|
87
|
+
color: var(--text-secondary);
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
}
|
|
90
|
+
.play-end[aria-hidden='true'] { visibility: hidden; }
|
|
91
|
+
.play-header [data-control='mode'] {
|
|
92
|
+
text-align: left;
|
|
93
|
+
white-space: nowrap;
|
|
94
|
+
margin-left: 6px;
|
|
95
|
+
padding-left: 8px;
|
|
96
|
+
border-left: 1px solid var(--border);
|
|
97
|
+
}
|
|
98
|
+
.play-stage {
|
|
99
|
+
background: var(--canvas);
|
|
100
|
+
min-height: 0;
|
|
101
|
+
min-width: 0;
|
|
102
|
+
}
|
|
103
|
+
.play-stage iframe {
|
|
104
|
+
display: block;
|
|
105
|
+
visibility: hidden;
|
|
106
|
+
width: 100%;
|
|
107
|
+
height: 100%;
|
|
108
|
+
border: 0;
|
|
109
|
+
}
|
|
110
|
+
.play-rail {
|
|
111
|
+
position: absolute;
|
|
112
|
+
grid-area: 2/1;
|
|
113
|
+
z-index: 2;
|
|
114
|
+
top: 0;
|
|
115
|
+
right: 20px;
|
|
116
|
+
width: min(350px, calc(100% - 40px));
|
|
117
|
+
max-height: calc(100% - 20px);
|
|
118
|
+
overflow: auto;
|
|
119
|
+
}
|
|
120
|
+
.play-rail section,
|
|
121
|
+
.play-dock {
|
|
122
|
+
padding: 20px;
|
|
123
|
+
}
|
|
124
|
+
.play-rail section + section {
|
|
125
|
+
border-top: 1px solid var(--border);
|
|
126
|
+
}
|
|
127
|
+
.play-rail h1,
|
|
128
|
+
.play-dock h2 {
|
|
129
|
+
font-size: 22px;
|
|
130
|
+
margin: 6px 0 16px;
|
|
131
|
+
}
|
|
132
|
+
.play-rail h1 {
|
|
133
|
+
font-family: var(--font-mono);
|
|
134
|
+
overflow-wrap: anywhere;
|
|
135
|
+
}
|
|
136
|
+
.play-rail h2 {
|
|
137
|
+
font-size: 16px;
|
|
138
|
+
margin: 0;
|
|
139
|
+
}
|
|
140
|
+
.play-rail p:empty,
|
|
141
|
+
.play-dock p:empty {
|
|
142
|
+
display: none;
|
|
143
|
+
}
|
|
144
|
+
.play-actions > div {
|
|
145
|
+
border: 1px solid var(--border);
|
|
146
|
+
border-radius: var(--radius-field);
|
|
147
|
+
margin-top: 8px;
|
|
148
|
+
padding: 10px;
|
|
149
|
+
}
|
|
150
|
+
.play-rail h1 { margin: 8px 0 20px; line-height: 28px; }
|
|
151
|
+
.play-rail [data-control='path'] { margin: 8px 0 0; font-size: var(--text-meta); }
|
|
152
|
+
.play-history { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
|
|
153
|
+
.play-rail [data-control='next-context'] { margin: 4px 0 12px; color: var(--text-secondary); }
|
|
154
|
+
.play-actions { margin-top: 12px; }
|
|
155
|
+
.play-actions strong {
|
|
156
|
+
display: block;
|
|
157
|
+
margin-bottom: 6px;
|
|
158
|
+
}
|
|
159
|
+
.play-actions button {
|
|
160
|
+
max-width: 100%;
|
|
161
|
+
white-space: normal;
|
|
162
|
+
overflow-wrap: anywhere;
|
|
163
|
+
text-align: left;
|
|
164
|
+
margin: 2px;
|
|
165
|
+
}
|
|
166
|
+
.play-dock {
|
|
167
|
+
position: absolute;
|
|
168
|
+
z-index: 2;
|
|
169
|
+
bottom: 20px;
|
|
170
|
+
left: 20px;
|
|
171
|
+
width: min(640px, calc(100% - 40px));
|
|
172
|
+
max-height: calc(100% - 92px);
|
|
173
|
+
overflow: auto;
|
|
174
|
+
}
|
|
175
|
+
.play-transport,
|
|
176
|
+
.play-clock,
|
|
177
|
+
.play-dock footer {
|
|
178
|
+
display: flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: space-between;
|
|
181
|
+
gap: 10px;
|
|
182
|
+
flex-wrap: wrap;
|
|
183
|
+
}
|
|
184
|
+
#motion-player [data-control='pause'] { background: var(--accent); color: var(--on-accent); }
|
|
185
|
+
.play-transport { align-items: flex-start; }
|
|
186
|
+
.play-transport button {
|
|
187
|
+
margin-left: 5px;
|
|
188
|
+
}
|
|
189
|
+
.play-dock h2 {
|
|
190
|
+
margin: 4px 0;
|
|
191
|
+
}
|
|
192
|
+
.play-clock {
|
|
193
|
+
margin: 15px 0 8px;
|
|
194
|
+
border-top: 1px solid var(--border);
|
|
195
|
+
padding-top: 12px;
|
|
196
|
+
}
|
|
197
|
+
.play-clock input {
|
|
198
|
+
flex: 1;
|
|
199
|
+
accent-color: var(--accent);
|
|
200
|
+
}
|
|
201
|
+
.play-dock footer,
|
|
202
|
+
.play-rail small,
|
|
203
|
+
.play-dock small {
|
|
204
|
+
font-size: var(--text-meta);
|
|
205
|
+
color: var(--text-secondary);
|
|
206
|
+
}
|
|
207
|
+
.play-settings {
|
|
208
|
+
position: absolute;
|
|
209
|
+
grid-area: 2/1;
|
|
210
|
+
width: min(296px, 90vw);
|
|
211
|
+
left: 184px;
|
|
212
|
+
top: 0;
|
|
213
|
+
max-height: calc(100% - 20px);
|
|
214
|
+
overflow: auto;
|
|
215
|
+
z-index: 2;
|
|
216
|
+
padding: 15px;
|
|
217
|
+
}
|
|
218
|
+
.play-settings fieldset {
|
|
219
|
+
border: 0;
|
|
220
|
+
margin: 0;
|
|
221
|
+
display: flex;
|
|
222
|
+
gap: 2px;
|
|
223
|
+
padding: 4px;
|
|
224
|
+
background: var(--surface-sunken);
|
|
225
|
+
border-radius: var(--radius-field);
|
|
226
|
+
}
|
|
227
|
+
.play-settings fieldset + fieldset { margin-top: 10px; }
|
|
228
|
+
.play-settings legend {
|
|
229
|
+
font-weight: 600;
|
|
230
|
+
}
|
|
231
|
+
.play-settings button {
|
|
232
|
+
flex: 1;
|
|
233
|
+
}
|
|
234
|
+
#motion-player [data-control='hotspots'][aria-pressed='true'],
|
|
235
|
+
#motion-player .play-settings [aria-pressed='true'] {
|
|
236
|
+
background: var(--accent);
|
|
237
|
+
color: var(--on-accent);
|
|
238
|
+
}
|
|
239
|
+
#motion-player > [role='status']:not(:empty) {
|
|
240
|
+
position: absolute;
|
|
241
|
+
bottom: 4px;
|
|
242
|
+
right: 20px;
|
|
243
|
+
background: var(--surface);
|
|
244
|
+
padding: 4px;
|
|
245
|
+
}
|
|
246
|
+
@media (max-width: 700px) {
|
|
247
|
+
.play-header {
|
|
248
|
+
flex-wrap: wrap;
|
|
249
|
+
padding: 8px;
|
|
250
|
+
}
|
|
251
|
+
.play-header > div,
|
|
252
|
+
.play-header > nav {
|
|
253
|
+
flex-wrap: wrap;
|
|
254
|
+
gap: 4px;
|
|
255
|
+
}
|
|
256
|
+
.play-project { border: 0; }
|
|
257
|
+
.play-settings { left: 8px; }
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@media (max-width: 500px) {
|
|
261
|
+
.play-header > div {
|
|
262
|
+
display: grid;
|
|
263
|
+
justify-items: start;
|
|
264
|
+
max-inline-size: 100%;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
#motion-player > [role='status']:empty {
|
|
269
|
+
display: none;
|
|
270
|
+
}
|