@milesroxas/design-hub 0.6.0 → 0.6.2
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 +3 -3
- package/core/review/model.ts +12 -8
- package/core/review/policy.test.ts +60 -0
- package/core/review/policy.ts +13 -9
- package/core/review/service.test.ts +84 -44
- package/core/review/store.ts +11 -5
- package/dist/core/review/model.d.ts +6 -5
- package/dist/core/review/model.js +10 -6
- package/dist/core/review/policy.d.ts +4 -1
- package/dist/core/review/policy.js +4 -4
- package/dist/core/review/store.d.ts +3 -4
- package/dist/core/review/store.js +10 -5
- package/dist/scripts/bootstrap.js +1 -1
- package/dist/scripts/lib/review.js +3 -3
- package/dist/scripts/people.d.ts +4 -4
- package/dist/scripts/people.js +8 -8
- package/dist/scripts/share.js +1 -1
- package/dist/server/api.js +1 -1
- package/dist/server/dev.js +3 -3
- package/dist/server/local.d.ts +2 -2
- package/dist/server/local.js +4 -4
- package/kit/dials.css +9 -8
- package/kit/dials.tsx +39 -20
- package/kit/ui/Menu.tsx +14 -4
- package/kit/ui/ui.css +16 -3
- package/package.json +1 -1
- package/shell/review/Bar.tsx +5 -4
- package/shell/review/People.tsx +21 -15
- package/shell/review/Review.tsx +2 -1
- package/shell/review/ThreadCard.tsx +24 -21
- package/shell/review/client.ts +4 -4
- package/shell/review/review.css +7 -1
- package/skills/miles-deploy/SKILL.md +4 -4
- package/skills/miles-design-hub/SKILL.md +1 -1
- package/skills/miles-review/SKILL.md +2 -2
package/dist/scripts/people.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
// The people who comment on the deployed prototypes. The first
|
|
4
|
-
// invited from here; after that,
|
|
5
|
-
import {
|
|
3
|
+
// The people who comment on the deployed prototypes. The first Studio person
|
|
4
|
+
// is invited from here; after that, Studio invites from the People tab.
|
|
5
|
+
import { PERSON_KINDS } from '../core/review/model.js';
|
|
6
6
|
import { CliError } from './lib/cli.js';
|
|
7
7
|
import { cliActor, cliReview } from './lib/review.js';
|
|
8
8
|
export const spec = {
|
|
@@ -18,11 +18,11 @@ export const spec = {
|
|
|
18
18
|
flags: {
|
|
19
19
|
name: { type: 'string', description: 'For invite: their name as it shows on comments.' },
|
|
20
20
|
team: { type: 'string', description: "For invite: the studio, or the client's company." },
|
|
21
|
-
|
|
21
|
+
kind: {
|
|
22
22
|
type: 'string',
|
|
23
|
-
default: '
|
|
24
|
-
choices:
|
|
25
|
-
description: '
|
|
23
|
+
default: 'client',
|
|
24
|
+
choices: PERSON_KINDS,
|
|
25
|
+
description: 'client comments, replies and resolves any thread; studio also deletes any comment, sorts and invites.',
|
|
26
26
|
},
|
|
27
27
|
site: { type: 'string', description: 'The deployed URL, so the invite link prints whole.' },
|
|
28
28
|
local: {
|
|
@@ -54,7 +54,7 @@ export async function main({ positionals: [action = 'list', id], flags }) {
|
|
|
54
54
|
const { person, token } = await review.invite(actor, {
|
|
55
55
|
name: flags.name,
|
|
56
56
|
team: flags.team,
|
|
57
|
-
|
|
57
|
+
kind: flags.kind,
|
|
58
58
|
});
|
|
59
59
|
return { store, person: strip(person), ...linkFor(token, flags.site) };
|
|
60
60
|
}
|
package/dist/scripts/share.js
CHANGED
|
@@ -156,7 +156,7 @@ function handover(url) {
|
|
|
156
156
|
share: { url, password: env.GATE_PASSWORD ?? null, open: opens() },
|
|
157
157
|
review,
|
|
158
158
|
next: review === 'on'
|
|
159
|
-
? `Send the handover (miles-deploy). First share with comments: design-hub people invite --name "<user>" --
|
|
159
|
+
? `Send the handover (miles-deploy). First share with comments: design-hub people invite --name "<user>" --kind studio --site ${url}.`
|
|
160
160
|
: 'Send the handover (miles-deploy). Never send GATE_SECRET.',
|
|
161
161
|
};
|
|
162
162
|
}
|
package/dist/server/api.js
CHANGED
|
@@ -62,7 +62,7 @@ async function command(op, b, { review, actor }) {
|
|
|
62
62
|
case 'comment.triage':
|
|
63
63
|
return { comment: await review.retriage(actor, { ...at(), triage: b.triage, states: b.states }) };
|
|
64
64
|
case 'people.invite':
|
|
65
|
-
return link(await review.invite(actor, { name: b.name, team: b.team,
|
|
65
|
+
return link(await review.invite(actor, { name: b.name, team: b.team, kind: b.kind }));
|
|
66
66
|
case 'people.reissue':
|
|
67
67
|
return link(await review.reissue(actor, str(b.id)));
|
|
68
68
|
case 'people.revoke':
|
package/dist/server/dev.js
CHANGED
|
@@ -5,7 +5,7 @@ import { API_PATH, handleReview } from './api.js';
|
|
|
5
5
|
import { checks } from './checks.js';
|
|
6
6
|
import { readEnv } from './env.js';
|
|
7
7
|
import { fileKV } from './file-kv.js';
|
|
8
|
-
import { LOCAL_STORE,
|
|
8
|
+
import { LOCAL_STORE, localStudio } from './local.js';
|
|
9
9
|
import { ROOT } from './paths.js';
|
|
10
10
|
// Connect strips the mount path from req.url; originalUrl keeps the query the handler reads.
|
|
11
11
|
async function toRequest(req) {
|
|
@@ -40,8 +40,8 @@ export function devReview() {
|
|
|
40
40
|
const review = createReview(kv, {
|
|
41
41
|
triage: jevTriager(readEnv(ROOT).TYPESAFE_API_KEY ?? '', checks),
|
|
42
42
|
});
|
|
43
|
-
const actor =
|
|
44
|
-
// The local
|
|
43
|
+
const actor = localStudio();
|
|
44
|
+
// The local Studio person is in the people list like anyone else, so the people panel shows them.
|
|
45
45
|
void kv.hset(KEY.people, actor.id, JSON.stringify(actor));
|
|
46
46
|
server.middlewares.use(API_PATH, (req, res, nextMiddleware) => {
|
|
47
47
|
toRequest(req)
|
package/dist/server/local.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Person } from '../core/review/model.ts';
|
|
2
2
|
export declare const LOCAL_STORE: string;
|
|
3
|
-
/** Whoever runs this machine's dev server or CLI:
|
|
4
|
-
export declare const
|
|
3
|
+
/** Whoever runs this machine's dev server or CLI: Studio, because they hold the store itself. */
|
|
4
|
+
export declare const localStudio: (id?: string, team?: string) => Person;
|
package/dist/server/local.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
// The review store and identity on this machine, shared by the dev server
|
|
3
|
-
// and the CLI: .design-hub/review.json, and a local
|
|
3
|
+
// and the CLI: .design-hub/review.json, and a local Studio person named from git.
|
|
4
4
|
import { execFileSync } from 'node:child_process';
|
|
5
5
|
import { join } from 'node:path';
|
|
6
6
|
import { STATE_DIR } from './paths.js';
|
|
@@ -13,12 +13,12 @@ function gitName() {
|
|
|
13
13
|
return '';
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
/** Whoever runs this machine's dev server or CLI:
|
|
17
|
-
export const
|
|
16
|
+
/** Whoever runs this machine's dev server or CLI: Studio, because they hold the store itself. */
|
|
17
|
+
export const localStudio = (id = 'local', team = 'Local') => ({
|
|
18
18
|
id,
|
|
19
19
|
name: gitName() || 'You',
|
|
20
20
|
team,
|
|
21
|
-
|
|
21
|
+
kind: 'studio',
|
|
22
22
|
createdAt: new Date(0).toISOString(),
|
|
23
23
|
revokedAt: null,
|
|
24
24
|
epoch: 0,
|
package/kit/dials.css
CHANGED
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
.dial-hint:not(.is-on) { transition-duration: 90ms; }
|
|
29
29
|
:root[data-motion="reduce"] .dial-hint { transform: none; transition: opacity 120ms var(--ease-hover); }
|
|
30
30
|
|
|
31
|
-
/* The
|
|
32
|
-
buttons so
|
|
33
|
-
.dial-
|
|
31
|
+
/* The panel's last rows, All prototypes and the walkthrough: drawn as DialKit's
|
|
32
|
+
own buttons so they read as part of the panel. The walkthrough's arrow says new tab. */
|
|
33
|
+
.dial-link {
|
|
34
34
|
display: flex;
|
|
35
35
|
align-items: center;
|
|
36
36
|
justify-content: space-between;
|
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
text-decoration: none;
|
|
48
48
|
transition: background-color var(--dur-hover) var(--ease-hover), color var(--dur-hover) var(--ease-hover), transform var(--dur-press-out) var(--ease-press);
|
|
49
49
|
}
|
|
50
|
-
.dial-
|
|
51
|
-
.dial-
|
|
52
|
-
.dial-
|
|
53
|
-
|
|
50
|
+
.dial-link + .dial-link { margin-top: 4px; }
|
|
51
|
+
.dial-link:hover { background: var(--dial-surface-hover); color: var(--dial-text-primary); }
|
|
52
|
+
.dial-link:active { transform: scale(0.97); }
|
|
53
|
+
.dial-link:focus-visible { outline: 2px solid var(--dial-focus-ring); outline-offset: -2px; }
|
|
54
|
+
:root[data-motion="reduce"] .dial-link:active { transform: none; }
|
|
54
55
|
/* The panel has no bottom padding, so the last row brings its own. */
|
|
55
|
-
.dialkit-folder-root > .dialkit-folder-content:has(> .dial-
|
|
56
|
+
.dialkit-folder-root > .dialkit-folder-content:has(> .dial-link) { padding-bottom: 12px; }
|
|
56
57
|
|
|
57
58
|
/* DialKit draws Copy parameters and Save version at the top of every group,
|
|
58
59
|
inside its sticky header. Here they close the group instead: the header
|
package/kit/dials.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import 'dialkit/styles.css';
|
|
|
12
12
|
import './dials.css';
|
|
13
13
|
import { type RefObject, useLayoutEffect } from 'react';
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
|
-
import { iconMarkup } from './Icon';
|
|
15
|
+
import { type IconName, iconMarkup } from './Icon';
|
|
16
16
|
|
|
17
17
|
// What the panel calls itself. DialKit hard-codes its own name as the root
|
|
18
18
|
// title; the prototypes say what the thing is instead.
|
|
@@ -55,7 +55,7 @@ export function ensureDialRoot() {
|
|
|
55
55
|
// DialKit portals the panel to <body>; it appears once the first panel registers.
|
|
56
56
|
const settle = (root: HTMLElement) => {
|
|
57
57
|
retitle(root);
|
|
58
|
-
|
|
58
|
+
placeLinks(root);
|
|
59
59
|
new MutationObserver((records) => {
|
|
60
60
|
for (const { type, target } of records) {
|
|
61
61
|
// DialKit keeps the panel's scroll offset when it collapses, which pushes the trigger icon off-centre.
|
|
@@ -64,7 +64,7 @@ export function ensureDialRoot() {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
retitle(root);
|
|
67
|
-
|
|
67
|
+
placeLinks(root);
|
|
68
68
|
}).observe(root, { subtree: true, childList: true, attributeFilter: ['data-collapsed'] });
|
|
69
69
|
};
|
|
70
70
|
const found = document.body.querySelector<HTMLElement>('.dialkit-root');
|
|
@@ -92,25 +92,44 @@ function retitle(root: HTMLElement) {
|
|
|
92
92
|
if (title && title.textContent !== DIALS_TITLE) title.textContent = DIALS_TITLE;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
type PanelLink = { key: string; href: string; label: string; icon: IconName; newTab?: boolean };
|
|
96
|
+
|
|
97
|
+
// The panel's last rows, under every group: the hub's list of every prototype,
|
|
98
|
+
// then the feature's walkthrough when it has one, which stays the very last.
|
|
99
|
+
function panelLinks(): PanelLink[] {
|
|
100
|
+
const home: PanelLink = { key: 'home', href: '/', label: 'All prototypes', icon: 'grid-01' };
|
|
101
|
+
if (!guide) return [home];
|
|
102
|
+
return [
|
|
103
|
+
home,
|
|
104
|
+
{ key: 'guide', href: guide, label: 'Open the walkthrough', icon: 'arrow-up-right', newTab: true },
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function makeLink({ key, href, label, icon, newTab }: PanelLink) {
|
|
109
|
+
const link = document.createElement('a');
|
|
110
|
+
link.className = 'dial-link';
|
|
111
|
+
link.dataset.dialLink = key;
|
|
112
|
+
link.href = href;
|
|
113
|
+
if (newTab) {
|
|
114
|
+
link.target = '_blank';
|
|
115
|
+
link.rel = 'noopener';
|
|
116
|
+
}
|
|
117
|
+
link.innerHTML = `<span>${label}</span>${iconMarkup(icon, 16)}`;
|
|
118
|
+
return link;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// DialKit remounts the content on open and adds groups as panels register, so
|
|
122
|
+
// the rows are put back whenever they are missing and moved down whenever a
|
|
123
|
+
// group lands below them.
|
|
124
|
+
function placeLinks(root: HTMLElement) {
|
|
100
125
|
const content = root.querySelector('.dialkit-folder-root > .dialkit-folder-content');
|
|
101
126
|
if (!content) return;
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
link.className = 'dial-guide';
|
|
109
|
-
link.href = guide;
|
|
110
|
-
link.target = '_blank';
|
|
111
|
-
link.rel = 'noopener';
|
|
112
|
-
link.innerHTML = `<span>Open the walkthrough</span>${iconMarkup('arrow-up-right', 16)}`;
|
|
113
|
-
content.append(link);
|
|
127
|
+
const rows = panelLinks().map(
|
|
128
|
+
(l) => content.querySelector<HTMLAnchorElement>(`:scope > [data-dial-link="${l.key}"]`) ?? makeLink(l),
|
|
129
|
+
);
|
|
130
|
+
const tail = Array.from(content.children).slice(-rows.length);
|
|
131
|
+
if (rows.every((row, i) => tail[i] === row)) return;
|
|
132
|
+
content.append(...rows);
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
// Hints: what each dial does, shown on hover or focus.
|
package/kit/ui/Menu.tsx
CHANGED
|
@@ -327,6 +327,8 @@ function MenuRow({
|
|
|
327
327
|
disabled={item.disabled}
|
|
328
328
|
data-label={item.label}
|
|
329
329
|
onClick={() => onPick(item)}
|
|
330
|
+
// The pointer takes the highlight from the keyboard, so one row is lit, never two.
|
|
331
|
+
onPointerMove={(e) => e.currentTarget.focus({ preventScroll: true })}
|
|
330
332
|
>
|
|
331
333
|
{item.icon ? (
|
|
332
334
|
<span className="menu-glyph">
|
|
@@ -347,7 +349,11 @@ function MenuRow({
|
|
|
347
349
|
);
|
|
348
350
|
}
|
|
349
351
|
|
|
350
|
-
|
|
352
|
+
/** `desc` is a second, quieter line in the list; the closed control shows the label alone. */
|
|
353
|
+
const selectValueClass = (set: boolean, picked: boolean) =>
|
|
354
|
+
['select-value', !set && 'is-placeholder', picked && 'is-picked'].filter(Boolean).join(' ');
|
|
355
|
+
|
|
356
|
+
export type SelectOption = { value: string; label: string; desc?: string };
|
|
351
357
|
|
|
352
358
|
export function Select({
|
|
353
359
|
value,
|
|
@@ -371,17 +377,21 @@ export function Select({
|
|
|
371
377
|
'aria-label'?: string;
|
|
372
378
|
}) {
|
|
373
379
|
const valueId = useId();
|
|
380
|
+
// Set on the first pick, so the value settles in when it changes and not when the control mounts.
|
|
381
|
+
const picked = useRef(false);
|
|
374
382
|
const current = options.find((o) => o.value === value);
|
|
375
383
|
const menu = useMenu({
|
|
376
384
|
role: 'listbox',
|
|
377
385
|
align: 'start',
|
|
378
|
-
items: options.map((o) => ({ label: o.label, value: o.value })),
|
|
386
|
+
items: options.map((o) => ({ label: o.label, value: o.value, desc: o.desc })),
|
|
379
387
|
selected: value ?? undefined,
|
|
380
388
|
label: ariaLabel,
|
|
381
389
|
className: menuClassName,
|
|
382
390
|
width: (trigger) => Math.max(trigger.offsetWidth, width || 0),
|
|
383
391
|
onSelect: (v) => {
|
|
384
|
-
if (v
|
|
392
|
+
if (v == null || v === value) return;
|
|
393
|
+
picked.current = true;
|
|
394
|
+
onChange(v);
|
|
385
395
|
},
|
|
386
396
|
});
|
|
387
397
|
return (
|
|
@@ -399,7 +409,7 @@ export function Select({
|
|
|
399
409
|
if (!menu.isOpen) menu.open();
|
|
400
410
|
}}
|
|
401
411
|
>
|
|
402
|
-
<span id={valueId} className={current
|
|
412
|
+
<span key={value} id={valueId} className={selectValueClass(!!current, picked.current)}>
|
|
403
413
|
{current ? current.label : placeholder}
|
|
404
414
|
</span>
|
|
405
415
|
<Icon name="chevron-down" size={20} className="select-chevron" />
|
package/kit/ui/ui.css
CHANGED
|
@@ -60,9 +60,13 @@ body.has-overlay { overflow: hidden; }
|
|
|
60
60
|
.search { position: relative; }
|
|
61
61
|
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--fg-quaternary); }
|
|
62
62
|
.search .input { padding-left: 32px; }
|
|
63
|
-
.
|
|
63
|
+
/* The value starts where an input's text does. The right padding puts the chevron's ink over the check in the list below. */
|
|
64
|
+
.select { display: inline-flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 10px; cursor: pointer; text-align: left; }
|
|
64
65
|
.select-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
65
66
|
.select-value.is-placeholder { color: var(--text-placeholder); }
|
|
67
|
+
/* A picked value settles in from just below: the control answers the choice the menu took away. */
|
|
68
|
+
.select-value.is-picked { animation: select-pick var(--dur-menu) var(--ease-out); }
|
|
69
|
+
@keyframes select-pick { from { opacity: 0; transform: translateY(3px); } }
|
|
66
70
|
.select { transition: border-color var(--dur-hover) var(--ease-hover), background-color var(--dur-hover) var(--ease-hover); }
|
|
67
71
|
.select-chevron { color: var(--fg-quaternary); transition: transform var(--dur-menu) var(--ease-out); }
|
|
68
72
|
@media (hover: hover) and (pointer: fine) { .select:hover:not([aria-expanded="true"]) { background: var(--button-secondary-bg_hover); } }
|
|
@@ -155,8 +159,12 @@ body.has-overlay { overflow: hidden; }
|
|
|
155
159
|
.menu-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); border: 0; background: transparent; text-align: left; cursor: pointer; width: 100%; color: var(--text-primary); position: relative; --press-dur: var(--dur-press-out); transition: transform var(--press-dur) var(--ease-out), background-color var(--dur-hover) var(--ease-hover); }
|
|
156
160
|
.menu-item:focus-visible, .menu-item.has-open, .menu-item.is-pressed { background: var(--bg-primary_hover); box-shadow: none; }
|
|
157
161
|
@media (hover: hover) and (pointer: fine) { .menu-item:hover { background: var(--bg-primary_hover); box-shadow: none; } .menu-item:hover .menu-glyph { color: var(--fg-secondary); } }
|
|
162
|
+
/* The highlight lands at once and fades behind the pointer: a row answers before the hand settles. */
|
|
163
|
+
.menu-item:is(:hover, :focus-visible) { transition-duration: var(--press-dur), 0ms; }
|
|
158
164
|
.menu-item.is-pressed { --press-dur: var(--dur-press-in); transform: scale(0.995); }
|
|
159
165
|
.menu-item[disabled] { color: var(--text-disabled); cursor: not-allowed; }
|
|
166
|
+
/* A select's list sits under its control: 1px less padding puts each label under the value. */
|
|
167
|
+
.menu[role="listbox"] .menu-item { padding-inline: 9px; }
|
|
160
168
|
/* A menu row is a finger's target where the pointer is one. */
|
|
161
169
|
@media (pointer: coarse) { .menu-item { min-height: 44px; } }
|
|
162
170
|
.menu-glyph { color: var(--fg-quaternary); display: grid; place-items: center; }
|
|
@@ -164,9 +172,13 @@ body.has-overlay { overflow: hidden; }
|
|
|
164
172
|
.menu-item.is-danger { color: var(--text-error-primary); }
|
|
165
173
|
.menu-item.is-danger .menu-glyph { color: var(--fg-error-primary); }
|
|
166
174
|
.menu-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
|
|
175
|
+
/* One weight in every state, so choosing a row never reflows it: the check says which is chosen. */
|
|
167
176
|
.menu-label { font-weight: 500; }
|
|
168
|
-
.menu-
|
|
169
|
-
|
|
177
|
+
.menu-desc { color: var(--text-tertiary); font-size: 12px; line-height: 16px; text-wrap: pretty; }
|
|
178
|
+
/* A row with a second line: its glyph and check sit on the label's line, not between the two. */
|
|
179
|
+
.menu-item:has(.menu-desc) { align-items: flex-start; }
|
|
180
|
+
.menu-item:has(.menu-desc) .menu-text { gap: 2px; }
|
|
181
|
+
.menu-item:has(.menu-desc) :is(.menu-glyph, .menu-check, .menu-chevron) { height: 1lh; }
|
|
170
182
|
.menu-keys { display: flex; gap: 4px; margin-left: auto; flex: none; }
|
|
171
183
|
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border: 1px solid var(--border-secondary); border-radius: var(--radius-xs); font: 500 12px/18px var(--font); color: var(--text-tertiary); }
|
|
172
184
|
.kbd:has(.icon) { padding: 0; color: var(--fg-quaternary); }
|
|
@@ -230,6 +242,7 @@ body.has-overlay { overflow: hidden; }
|
|
|
230
242
|
/* ---------- motion gates ---------- */
|
|
231
243
|
:root[data-motion="reduce"] :is(.btn, .btn .icon, .select, .select-chevron, .menu-item) { transition-duration: 0ms; }
|
|
232
244
|
:root[data-motion="reduce"] .menu-item.is-pressed { transform: none; }
|
|
245
|
+
:root[data-motion="reduce"] .select-value.is-picked { animation: none; }
|
|
233
246
|
:root[data-motion="reduce"] :is(.menu, .menu[data-side], .menu.is-open, .dialog, .overlay.is-open .dialog) { transform: none; transition: opacity 160ms var(--ease-hover); }
|
|
234
247
|
:root[data-motion="reduce"] :is(.sheet, .overlay.is-open .sheet) { transform: none; transition: opacity 160ms var(--ease-hover); }
|
|
235
248
|
:root[data-motion="reduce"] .overlay-sheet:not(.is-open) .sheet { opacity: 0; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milesroxas/design-hub",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "The Design Hub product: the hub that lists and serves prototypes, the review panel and its API, the password gate, the kit, and the design-hub CLI. A project installs it and keeps only its prototypes, kit materials and docs.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/shell/review/Bar.tsx
CHANGED
|
@@ -16,7 +16,8 @@ type Props = {
|
|
|
16
16
|
onScope: (scope: Scope) => void;
|
|
17
17
|
resolved: boolean;
|
|
18
18
|
resolvedCount: number;
|
|
19
|
-
|
|
19
|
+
/** Studio only: the People entry in ⋯. */
|
|
20
|
+
canManagePeople: boolean;
|
|
20
21
|
error: string | null;
|
|
21
22
|
onStep: (by: number) => void;
|
|
22
23
|
onResolved: () => void;
|
|
@@ -26,7 +27,7 @@ type Props = {
|
|
|
26
27
|
onDismissError: () => void;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
function moreItems(resolved: boolean, resolvedCount: number,
|
|
30
|
+
function moreItems(resolved: boolean, resolvedCount: number, canManagePeople: boolean): MenuEntry[] {
|
|
30
31
|
return [
|
|
31
32
|
{
|
|
32
33
|
label: resolved ? 'Hide resolved' : 'Show resolved',
|
|
@@ -35,7 +36,7 @@ function moreItems(resolved: boolean, resolvedCount: number, editor: boolean): M
|
|
|
35
36
|
icon: 'check-circle',
|
|
36
37
|
disabled: !resolvedCount && !resolved,
|
|
37
38
|
},
|
|
38
|
-
...(
|
|
39
|
+
...(canManagePeople
|
|
39
40
|
? [{ label: 'People', desc: 'Who can comment', value: 'people', icon: 'users-01' as const }]
|
|
40
41
|
: []),
|
|
41
42
|
{ label: 'Hide comments', desc: 'Tuck the button into the edge', value: 'hide', icon: 'chevron-right' },
|
|
@@ -119,7 +120,7 @@ export function Bar(p: Props) {
|
|
|
119
120
|
label: 'Comment options',
|
|
120
121
|
width: 264,
|
|
121
122
|
align: 'end',
|
|
122
|
-
items: moreItems(p.resolved, p.resolvedCount, p.
|
|
123
|
+
items: moreItems(p.resolved, p.resolvedCount, p.canManagePeople),
|
|
123
124
|
onSelect: (v) => actions[v ?? '']?.(),
|
|
124
125
|
});
|
|
125
126
|
return (
|
package/shell/review/People.tsx
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
// The People card, for
|
|
1
|
+
// The People card, for Studio: invite someone, hand over their link, and see
|
|
2
2
|
// who can comment.
|
|
3
3
|
import { Button, Select } from '@kit/ui';
|
|
4
4
|
import { type FormEvent, useId, useRef, useState } from 'react';
|
|
5
|
-
import { INVITE_DAYS, LIMITS, type
|
|
5
|
+
import { INVITE_DAYS, LIMITS, type PersonKind } from '../../core/review/model';
|
|
6
6
|
import { Action } from './Card';
|
|
7
7
|
import { act, type Me, type ReviewStore } from './client';
|
|
8
8
|
|
|
9
9
|
type Link = { name: string; href: string };
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const KIND_NAMES: Record<PersonKind, string> = { studio: 'Studio', client: 'Client' };
|
|
12
|
+
|
|
13
|
+
const KIND_OPTIONS: { value: PersonKind; label: string; desc: string }[] = [
|
|
14
|
+
{ value: 'client', label: KIND_NAMES.client, desc: 'Comments, replies and resolves any thread' },
|
|
15
|
+
{
|
|
16
|
+
value: 'studio',
|
|
17
|
+
label: KIND_NAMES.studio,
|
|
18
|
+
desc: 'Also sorts, deletes any comment and invites',
|
|
19
|
+
},
|
|
14
20
|
];
|
|
15
21
|
|
|
16
22
|
function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link) => void }) {
|
|
17
|
-
const [
|
|
23
|
+
const [kind, setKind] = useState<PersonKind>('client');
|
|
18
24
|
const [busy, setBusy] = useState(false);
|
|
19
|
-
const
|
|
25
|
+
const kindLabel = useId();
|
|
20
26
|
const invite = (e: FormEvent<HTMLFormElement>) => {
|
|
21
27
|
e.preventDefault();
|
|
22
28
|
const form = e.currentTarget;
|
|
@@ -25,7 +31,7 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
|
|
|
25
31
|
setBusy(true);
|
|
26
32
|
act(
|
|
27
33
|
store
|
|
28
|
-
.invite(name, String(f.get('team') ?? ''),
|
|
34
|
+
.invite(name, String(f.get('team') ?? ''), kind)
|
|
29
35
|
.then((href) => {
|
|
30
36
|
onLink({ name, href });
|
|
31
37
|
form.reset();
|
|
@@ -58,15 +64,15 @@ function InviteForm({ store, onLink }: { store: ReviewStore; onLink: (link: Link
|
|
|
58
64
|
/>
|
|
59
65
|
</label>
|
|
60
66
|
<div className="field">
|
|
61
|
-
<span id={
|
|
62
|
-
|
|
67
|
+
<span id={kindLabel} className="field-label">
|
|
68
|
+
Kind
|
|
63
69
|
</span>
|
|
64
70
|
<Select
|
|
65
|
-
labelId={
|
|
71
|
+
labelId={kindLabel}
|
|
66
72
|
menuClassName="rv-menu"
|
|
67
|
-
value={
|
|
68
|
-
options={
|
|
69
|
-
onChange={(next) =>
|
|
73
|
+
value={kind}
|
|
74
|
+
options={KIND_OPTIONS}
|
|
75
|
+
onChange={(next) => setKind(next as PersonKind)}
|
|
70
76
|
/>
|
|
71
77
|
</div>
|
|
72
78
|
<Button type="submit" kind="primary" size={null} label="Create invite link" busy={busy} />
|
|
@@ -154,7 +160,7 @@ export function People({ store, me, people }: { store: ReviewStore; me: Me | nul
|
|
|
154
160
|
<div className="rv-person">
|
|
155
161
|
<strong>{p.name}</strong>
|
|
156
162
|
<span className="rv-muted">
|
|
157
|
-
{p.team} · {p.
|
|
163
|
+
{p.team} · {KIND_NAMES[p.kind]}
|
|
158
164
|
{p.revokedAt && ' · revoked'}
|
|
159
165
|
</span>
|
|
160
166
|
</div>
|
package/shell/review/Review.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import { areCommentsHidden, setCommentsHidden } from '@kit/prefs';
|
|
|
8
8
|
import { Button } from '@kit/ui';
|
|
9
9
|
import { type Dispatch, useEffect, useMemo, useReducer, useState } from 'react';
|
|
10
10
|
import { type Anchor, type Comment, isRoot } from '../../core/review/model';
|
|
11
|
+
import { can } from '../../core/review/policy';
|
|
11
12
|
import { captureAnchor, currentUrl, openAnchor, pinPoint, resumeAnchor } from './anchor';
|
|
12
13
|
import { Bar } from './Bar';
|
|
13
14
|
import { Card } from './Card';
|
|
@@ -264,7 +265,7 @@ function ModeBar({
|
|
|
264
265
|
}}
|
|
265
266
|
resolved={v.resolved}
|
|
266
267
|
resolvedCount={roots.filter((c) => c.status === 'resolved').length}
|
|
267
|
-
|
|
268
|
+
canManagePeople={can(s.me, 'people')}
|
|
268
269
|
error={s.error}
|
|
269
270
|
onResolved={() => dispatch({ type: 'resolved' })}
|
|
270
271
|
onPeople={() => {
|
|
@@ -7,6 +7,7 @@ import { Icon } from '@kit/Icon';
|
|
|
7
7
|
import { Button, type MenuEntry, useMenu } from '@kit/ui';
|
|
8
8
|
import { type KeyboardEvent, useEffect, useState } from 'react';
|
|
9
9
|
import { type Comment, KINDS, type Kind, LIMITS } from '../../core/review/model';
|
|
10
|
+
import { can } from '../../core/review/policy';
|
|
10
11
|
import { Action, Card } from './Card';
|
|
11
12
|
import { act, type Me, type ReviewStore } from './client';
|
|
12
13
|
import { Field, useTextBox } from './Field';
|
|
@@ -172,7 +173,7 @@ function Entry({
|
|
|
172
173
|
<div className="rv-msg-main">
|
|
173
174
|
<EntryHead
|
|
174
175
|
comment={comment}
|
|
175
|
-
canEdit={me
|
|
176
|
+
canEdit={can(me, 'edit', comment) && !editing}
|
|
176
177
|
onEdit={() => setEditing(true)}
|
|
177
178
|
/>
|
|
178
179
|
{editing ? (
|
|
@@ -203,19 +204,19 @@ function tagsOf(root: Comment): string[] {
|
|
|
203
204
|
|
|
204
205
|
type TriageChange = { kind: string | null; state: string | null };
|
|
205
206
|
|
|
206
|
-
/** Kind and state as checked choices, for
|
|
207
|
+
/** Kind and state as checked choices, for Studio; then the thread's rarer actions. */
|
|
207
208
|
function menuItems(
|
|
208
209
|
root: Comment,
|
|
209
210
|
states: string[],
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
canTriage: boolean,
|
|
212
|
+
canDelete: boolean,
|
|
212
213
|
show: boolean,
|
|
213
214
|
): MenuEntry[] {
|
|
214
215
|
const { kind = null, state = null } = root.triage ?? {};
|
|
215
216
|
const stateItems: MenuEntry[] = states.length
|
|
216
217
|
? [{ heading: 'State' }, ...states.map((s) => ({ label: s, value: `state:${s}`, checked: state === s }))]
|
|
217
218
|
: [];
|
|
218
|
-
const triage: MenuEntry[] =
|
|
219
|
+
const triage: MenuEntry[] = canTriage
|
|
219
220
|
? [
|
|
220
221
|
{ heading: 'Kind' },
|
|
221
222
|
...KINDS.map((k) => ({ label: KIND_LABEL[k], value: `kind:${k}`, checked: kind === k })),
|
|
@@ -226,7 +227,7 @@ function menuItems(
|
|
|
226
227
|
return [
|
|
227
228
|
...triage,
|
|
228
229
|
...(show ? [{ label: 'Show its state', value: 'show', icon: 'clock-rewind' as const }] : []),
|
|
229
|
-
...(
|
|
230
|
+
...(canDelete
|
|
230
231
|
? [{ label: 'Delete thread', value: 'delete', icon: 'trash-01' as const, danger: true }]
|
|
231
232
|
: []),
|
|
232
233
|
];
|
|
@@ -246,20 +247,20 @@ function ThreadMenu({
|
|
|
246
247
|
store,
|
|
247
248
|
root,
|
|
248
249
|
states,
|
|
249
|
-
|
|
250
|
-
|
|
250
|
+
canTriage,
|
|
251
|
+
canDelete,
|
|
251
252
|
onShow,
|
|
252
253
|
onDelete,
|
|
253
254
|
}: {
|
|
254
255
|
store: ReviewStore;
|
|
255
256
|
root: Comment;
|
|
256
257
|
states: string[];
|
|
257
|
-
|
|
258
|
-
|
|
258
|
+
canTriage: boolean;
|
|
259
|
+
canDelete: boolean;
|
|
259
260
|
onShow?: () => void;
|
|
260
261
|
onDelete: () => void;
|
|
261
262
|
}) {
|
|
262
|
-
const items = menuItems(root, states,
|
|
263
|
+
const items = menuItems(root, states, canTriage, canDelete, !!onShow);
|
|
263
264
|
const menu = useMenu({
|
|
264
265
|
className: 'rv-menu',
|
|
265
266
|
label: 'Thread options',
|
|
@@ -382,8 +383,9 @@ type HeadProps = {
|
|
|
382
383
|
index: number;
|
|
383
384
|
total: number;
|
|
384
385
|
states: string[];
|
|
385
|
-
|
|
386
|
-
|
|
386
|
+
canResolve: boolean;
|
|
387
|
+
canTriage: boolean;
|
|
388
|
+
canDelete: boolean;
|
|
387
389
|
onStep: (by: number) => void;
|
|
388
390
|
onClose: () => void;
|
|
389
391
|
onShow?: () => void;
|
|
@@ -398,8 +400,9 @@ function ThreadHead({
|
|
|
398
400
|
index,
|
|
399
401
|
total,
|
|
400
402
|
states,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
+
canResolve,
|
|
404
|
+
canTriage,
|
|
405
|
+
canDelete,
|
|
403
406
|
onStep,
|
|
404
407
|
onClose,
|
|
405
408
|
onShow,
|
|
@@ -412,13 +415,13 @@ function ThreadHead({
|
|
|
412
415
|
</span>
|
|
413
416
|
<span className="rv-about rv-ellipsis">{about(root)}</span>
|
|
414
417
|
<Stepper index={index} total={total} onStep={onStep} />
|
|
415
|
-
{
|
|
418
|
+
{canResolve && <ResolveButton store={store} root={root} />}
|
|
416
419
|
<ThreadMenu
|
|
417
420
|
store={store}
|
|
418
421
|
root={root}
|
|
419
422
|
states={states}
|
|
420
|
-
|
|
421
|
-
|
|
423
|
+
canTriage={canTriage}
|
|
424
|
+
canDelete={canDelete}
|
|
422
425
|
onShow={onShow}
|
|
423
426
|
onDelete={onDelete}
|
|
424
427
|
/>
|
|
@@ -462,7 +465,6 @@ export function ThreadCard({
|
|
|
462
465
|
onShow?: () => void;
|
|
463
466
|
}) {
|
|
464
467
|
const [confirming, setConfirming] = useState(false);
|
|
465
|
-
const editor = me?.role === 'editor';
|
|
466
468
|
const resolved = root.status === 'resolved';
|
|
467
469
|
return (
|
|
468
470
|
<Card
|
|
@@ -478,8 +480,9 @@ export function ThreadCard({
|
|
|
478
480
|
index={index}
|
|
479
481
|
total={total}
|
|
480
482
|
states={states}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
+
canResolve={can(me, 'resolve', root)}
|
|
484
|
+
canTriage={can(me, 'triage')}
|
|
485
|
+
canDelete={can(me, 'delete', root)}
|
|
483
486
|
onStep={onStep}
|
|
484
487
|
onClose={onClose}
|
|
485
488
|
onShow={onShow}
|
package/shell/review/client.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// The review UI's one store: who is signed in, this prototype's comments and,
|
|
2
|
-
// for
|
|
2
|
+
// for Studio, the people. Components read it with useSyncExternalStore and
|
|
3
3
|
// call its actions; every call goes to /api/review (server/api.ts), and each
|
|
4
4
|
// answer is merged in place, so a write never refetches the list.
|
|
5
5
|
import { useSyncExternalStore } from 'react';
|
|
6
|
-
import type { Anchor, Comment, Person,
|
|
6
|
+
import type { Anchor, Comment, Person, PersonKind } from '../../core/review/model';
|
|
7
7
|
|
|
8
8
|
export type Me = Omit<Person, 'epoch'>;
|
|
9
9
|
/** off: this site has no review store, so the UI stays out of the way. */
|
|
@@ -144,9 +144,9 @@ export function createReviewStore(prototype: string) {
|
|
|
144
144
|
}),
|
|
145
145
|
|
|
146
146
|
loadPeople: () => attempt(async () => set({ people: (await call<{ people: Me[] }>('people')).people })),
|
|
147
|
-
invite: (name: string, team: string,
|
|
147
|
+
invite: (name: string, team: string, kind: PersonKind) =>
|
|
148
148
|
attempt(async () => {
|
|
149
|
-
const r = await call<{ person: Me; link: string }>('people.invite', { name, team,
|
|
149
|
+
const r = await call<{ person: Me; link: string }>('people.invite', { name, team, kind });
|
|
150
150
|
mergePerson(r.person);
|
|
151
151
|
return new URL(r.link, location.origin).href;
|
|
152
152
|
}),
|