@luci-dev/capture 0.5.8 → 0.7.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 +1 -1
- package/dist/a11y.d.ts +3 -2
- package/dist/a11y.d.ts.map +1 -1
- package/dist/a11y.js +85 -13
- package/dist/a11y.js.map +1 -1
- package/dist/color.d.ts.map +1 -1
- package/dist/color.js +40 -8
- package/dist/color.js.map +1 -1
- package/dist/component.d.ts +22 -5
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +160 -46
- package/dist/component.js.map +1 -1
- package/dist/dom.d.ts +8 -6
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +99 -11
- package/dist/dom.js.map +1 -1
- package/dist/font.d.ts.map +1 -1
- package/dist/font.js +17 -3
- package/dist/font.js.map +1 -1
- package/dist/icon.js +12 -12
- package/dist/icon.js.map +1 -1
- package/dist/luci-capture.js +7098 -2681
- package/dist/model.d.ts +6 -7
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +13 -4
- package/dist/model.js.map +1 -1
- package/dist/page.d.ts +17 -3
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +287 -16
- package/dist/page.js.map +1 -1
- package/dist/responsive.d.ts +3 -1
- package/dist/responsive.d.ts.map +1 -1
- package/dist/responsive.js +23 -3
- package/dist/responsive.js.map +1 -1
- package/dist/section.d.ts +2 -1
- package/dist/section.d.ts.map +1 -1
- package/dist/section.js +28 -18
- package/dist/section.js.map +1 -1
- package/dist/spacing.d.ts +2 -0
- package/dist/spacing.d.ts.map +1 -1
- package/dist/spacing.js +50 -8
- package/dist/spacing.js.map +1 -1
- package/dist/states.d.ts +6 -0
- package/dist/states.d.ts.map +1 -1
- package/dist/states.js +81 -12
- package/dist/states.js.map +1 -1
- package/dist/text.d.ts +7 -1
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +175 -26
- package/dist/text.js.map +1 -1
- package/dist/ui/check.d.ts +14 -0
- package/dist/ui/check.d.ts.map +1 -1
- package/dist/ui/check.js +71 -55
- package/dist/ui/check.js.map +1 -1
- package/dist/ui/devSettings.d.ts +67 -2
- package/dist/ui/devSettings.d.ts.map +1 -1
- package/dist/ui/devSettings.js +152 -7
- package/dist/ui/devSettings.js.map +1 -1
- package/dist/ui/index.d.ts +6 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +6 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/mount.d.ts +15 -1
- package/dist/ui/mount.d.ts.map +1 -1
- package/dist/ui/mount.js +5 -0
- package/dist/ui/mount.js.map +1 -1
- package/dist/ui/onSpec.d.ts +61 -0
- package/dist/ui/onSpec.d.ts.map +1 -0
- package/dist/ui/onSpec.js +516 -0
- package/dist/ui/onSpec.js.map +1 -0
- package/dist/ui/projectLabel.d.ts +11 -0
- package/dist/ui/projectLabel.d.ts.map +1 -0
- package/dist/ui/projectLabel.js +15 -0
- package/dist/ui/projectLabel.js.map +1 -0
- package/dist/ui/remap.d.ts.map +1 -1
- package/dist/ui/remap.js +7 -3
- package/dist/ui/remap.js.map +1 -1
- package/dist/ui/specWatcher.d.ts +79 -0
- package/dist/ui/specWatcher.d.ts.map +1 -0
- package/dist/ui/specWatcher.js +702 -0
- package/dist/ui/specWatcher.js.map +1 -0
- package/dist/ui/styles.d.ts +4 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/styles.js +343 -2
- package/dist/ui/styles.js.map +1 -1
- package/dist/ui/toolbar.d.ts +15 -1
- package/dist/ui/toolbar.d.ts.map +1 -1
- package/dist/ui/toolbar.js +233 -64
- package/dist/ui/toolbar.js.map +1 -1
- package/dist/ui/tools.d.ts +5 -4
- package/dist/ui/tools.d.ts.map +1 -1
- package/dist/ui/tools.js +44 -13
- package/dist/ui/tools.js.map +1 -1
- package/dist/ui/updateBanner.d.ts +13 -0
- package/dist/ui/updateBanner.d.ts.map +1 -0
- package/dist/ui/updateBanner.js +105 -0
- package/dist/ui/updateBanner.js.map +1 -0
- package/package.json +3 -3
package/dist/ui/toolbar.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createElement as _createElement } from "preact";
|
|
1
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
3
|
/**
|
|
3
4
|
* The on-page toolbar (FR1-FR5): tool modes, the picker with hover label and arrow-key navigation,
|
|
@@ -13,53 +14,124 @@ import { elementName } from '../naming.js';
|
|
|
13
14
|
import { LUCI_UI_ATTRIBUTE } from '../dom.js';
|
|
14
15
|
import { elementAt, eligibilityOf, eventTarget, firstChildOf, hoverLabel, parentOf, scrollableAncestor, touchScreen } from './picker.js';
|
|
15
16
|
import { ButtonSpinner, Loading, nextPaint } from './loading.js';
|
|
17
|
+
import { projectLabel } from './projectLabel.js';
|
|
16
18
|
import { ModeSwitch } from './modeSwitch.js';
|
|
17
|
-
import { Button, COPY, EmptyState, Icon, IconBasket, IconCheck, IconClose, IconColour, IconComponent, IconCopy, IconDownload, IconInfo, IconPage, IconSpacing, IconSuccess, IconText, LUCI_REPO_URL, Mascot, RepoButton, Select, useShortcuts } from '@luci-dev/ui';
|
|
19
|
+
import { Button, COPY, EmptyState, Icon, IconBasket, IconCheck, IconClose, IconColour, IconComponent, IconCopy, IconDownload, IconInfo, IconOnSpec, IconPage, IconSpacing, IconSuccess, IconText, LUCI_REPO_URL, Mascot, RepoButton, Select, useShortcuts } from '@luci-dev/ui';
|
|
18
20
|
import { AppearanceControls, LuciLogo, useUiPrefs } from './theme.js';
|
|
19
|
-
import { DevSettingsPanel } from './devSettings.js';
|
|
21
|
+
import { DevSettingsPanel, FEEDBACK_SETTINGS_KEY, UpdatesSettingsSection } from './devSettings.js';
|
|
20
22
|
import { zip } from './zip.js';
|
|
21
|
-
import { CheckResultPanel, DesignChooser } from './check.js';
|
|
23
|
+
import { CheckResultPanel, DEFAULT_DIFF_OVERLAY, DiffOverlay, DesignChooser } from './check.js';
|
|
22
24
|
import { ALL_SPACING, TOOLS, captureComponent, checkAgainst, readResponsive, capturePageInSteps, captureSection, captureDistance, readComponentStates, restingValues, stateTargets, captureOne, capturePixel, captureSystem, liveSnapshot, spacingChoices } from './tools.js';
|
|
23
25
|
/** The check being watched, kept for this tab so a reload picks it up again (v0.4). */
|
|
24
26
|
const AUTO_CHECK_KEY = 'luci.autoCheck';
|
|
25
27
|
const clamp = (v, min, max) => Math.max(min, Math.min(v, Math.max(min, max)));
|
|
28
|
+
/** The page's root font size in px (16 when it can't be read): what 1rem means on this page (B-27). */
|
|
29
|
+
const pageRootFontSize = (doc) => {
|
|
30
|
+
try {
|
|
31
|
+
return parseFloat((doc.defaultView ?? window).getComputedStyle(doc.documentElement).fontSize) || 16;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return 16;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
26
37
|
/** Keep at least this much of the window between the dragged bar and its edges. */
|
|
27
38
|
const EDGE = 8;
|
|
28
|
-
/** "Save to project", then
|
|
39
|
+
/** "Save to project", then "Saved to project" with an Unsave / Remove action. */
|
|
29
40
|
function SaveButton(props) {
|
|
30
41
|
const [state, setState] = useState({});
|
|
42
|
+
const isSavedCurrent = Boolean(state.done) && (props.currentSnapshot === undefined || state.savedSnapshot === props.currentSnapshot);
|
|
31
43
|
const run = async () => {
|
|
32
44
|
setState({ busy: true });
|
|
33
45
|
try {
|
|
34
46
|
const r = await props.save();
|
|
35
|
-
setState({
|
|
47
|
+
setState({
|
|
48
|
+
done: `${r.replaced ? 'Replaced' : 'Saved'} ${r.path}`,
|
|
49
|
+
replaced: r.replaced,
|
|
50
|
+
savedSnapshot: props.currentSnapshot
|
|
51
|
+
});
|
|
36
52
|
}
|
|
37
53
|
catch (err) {
|
|
38
54
|
setState({ error: err instanceof Error ? err.message : String(err) });
|
|
39
55
|
}
|
|
40
56
|
};
|
|
57
|
+
const runUnsave = async () => {
|
|
58
|
+
if (!props.unsave)
|
|
59
|
+
return;
|
|
60
|
+
if (state.replaced && !state.confirmRemove) {
|
|
61
|
+
setState(prev => ({ ...prev, confirmRemove: true }));
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setState(prev => ({ ...prev, removing: true, confirmRemove: false, error: undefined }));
|
|
65
|
+
try {
|
|
66
|
+
await props.unsave();
|
|
67
|
+
setState({ removedMsg: 'Removed from project' });
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
setState(prev => ({ ...prev, removing: false, error: err instanceof Error ? err.message : String(err) }));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
41
73
|
const label = props.projectName ? `Save to ${props.projectName}` : 'Save to project';
|
|
42
74
|
const title = props.projectName
|
|
43
75
|
? `Into ${props.projectName}/.luci/design/, where your agent reads it`
|
|
44
76
|
: "Into the project's .luci/design/, where your agent reads it";
|
|
45
|
-
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", "data-action": "save-to-project", disabled: state.busy, title: title, onClick: () => void run(), children: state.busy ? _jsxs(_Fragment, { children: [_jsx(ButtonSpinner, {}), "Saving\u2026"] }) : label }), state.done && _jsx("span", { class: "dim", "data-part": "saved", children: state.done }), state.error && (_jsxs(_Fragment, { children: [_jsx("span", { class: "error", "data-part": "save-error", children: state.error }), props.onDownload && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "download-fallback", onClick: props.onDownload, children: "Download file instead" }))] }))] }));
|
|
77
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", class: `btn-secondary${isSavedCurrent ? ' btn-with-ico' : ''}`, "data-action": "save-to-project", "data-saved": isSavedCurrent ? 'true' : undefined, disabled: state.busy || state.removing || isSavedCurrent, title: title, onClick: (e) => { e.stopPropagation(); void run(); }, children: state.busy ? _jsxs(_Fragment, { children: [_jsx(ButtonSpinner, {}), "Saving\u2026"] }) : isSavedCurrent ? _jsxs(_Fragment, { children: [_jsx(Icon, { icon: IconSuccess, size: "compact" }), "Saved to project"] }) : label }), state.done && (_jsxs("span", { class: "row", style: { gap: '6px', alignItems: 'center' }, children: [_jsx("span", { class: "dim", "data-part": "saved", children: state.done }), props.unsave && !state.confirmRemove && (_jsx("button", { type: "button", class: "btn-danger btn-sm", "data-action": "unsave-from-project", disabled: state.busy || state.removing, onClick: (e) => { e.stopPropagation(); void runUnsave(); }, children: state.removing ? 'Removing…' : state.replaced ? 'Remove' : 'Unsave' })), props.unsave && state.confirmRemove && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", class: "btn-danger btn-sm", "data-action": "confirm-unsave", disabled: state.removing, onClick: (e) => { e.stopPropagation(); void runUnsave(); }, children: "Confirm remove" }), _jsx("button", { type: "button", class: "btn-ghost btn-sm", onClick: (e) => { e.stopPropagation(); setState(prev => ({ ...prev, confirmRemove: false })); }, children: "Cancel" })] }))] })), state.removedMsg && _jsx("span", { class: "dim", "data-part": "unsaved", children: state.removedMsg }), state.error && (_jsxs(_Fragment, { children: [_jsx("span", { class: "error", "data-part": "save-error", children: state.error }), props.onDownload && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "download-fallback", onClick: props.onDownload, children: "Download file instead" }))] }))] }));
|
|
46
78
|
}
|
|
47
79
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
80
|
+
* Grouped project actions for Capture preview: Save to project (+ Saved/Unsave/Remove states),
|
|
81
|
+
* Make it a rule, and On spec pin link — kept cleanly separated from the 4 quick icon buttons.
|
|
50
82
|
*/
|
|
51
|
-
function
|
|
52
|
-
const [
|
|
53
|
-
const
|
|
54
|
-
|
|
83
|
+
function ProjectActions(props) {
|
|
84
|
+
const [saveState, setSaveState] = useState({});
|
|
85
|
+
const [ruleState, setRuleState] = useState({});
|
|
86
|
+
const isSavedCurrent = Boolean(saveState.done) && (props.currentSnapshot === undefined || saveState.savedSnapshot === props.currentSnapshot);
|
|
87
|
+
const runSave = async () => {
|
|
88
|
+
if (!props.save)
|
|
89
|
+
return;
|
|
90
|
+
setSaveState({ busy: true });
|
|
55
91
|
try {
|
|
56
|
-
|
|
92
|
+
const r = await props.save();
|
|
93
|
+
setSaveState({
|
|
94
|
+
done: `${r.replaced ? 'Replaced' : 'Saved'} ${r.path}`,
|
|
95
|
+
replaced: r.replaced,
|
|
96
|
+
savedSnapshot: props.currentSnapshot
|
|
97
|
+
});
|
|
57
98
|
}
|
|
58
99
|
catch (err) {
|
|
59
|
-
|
|
100
|
+
setSaveState({ error: err instanceof Error ? err.message : String(err) });
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const runUnsave = async () => {
|
|
104
|
+
if (!props.unsave)
|
|
105
|
+
return;
|
|
106
|
+
if (saveState.replaced && !saveState.confirmRemove) {
|
|
107
|
+
setSaveState(prev => ({ ...prev, confirmRemove: true }));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
setSaveState(prev => ({ ...prev, removing: true, confirmRemove: false, error: undefined }));
|
|
111
|
+
try {
|
|
112
|
+
await props.unsave();
|
|
113
|
+
setSaveState({ removedMsg: 'Removed from project' });
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
setSaveState(prev => ({ ...prev, removing: false, error: err instanceof Error ? err.message : String(err) }));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const runMakeRule = async () => {
|
|
120
|
+
if (!props.makeRule)
|
|
121
|
+
return;
|
|
122
|
+
setRuleState({ busy: true });
|
|
123
|
+
try {
|
|
124
|
+
setRuleState({ done: await props.makeRule() });
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
setRuleState({ error: err instanceof Error ? err.message : String(err) });
|
|
60
128
|
}
|
|
61
129
|
};
|
|
62
|
-
|
|
130
|
+
const label = props.projectName ? `Save to ${props.projectName}` : 'Save to project';
|
|
131
|
+
const title = props.projectName
|
|
132
|
+
? `Into ${props.projectName}/.luci/design/, where your agent reads it`
|
|
133
|
+
: "Into the project's .luci/design/, where your agent reads it";
|
|
134
|
+
return (_jsxs("div", { class: "project-actions", "data-part": "project-actions", children: [_jsxs("div", { class: "project-actions-row", children: [props.save && (_jsx("button", { type: "button", class: `btn-secondary btn-sm${isSavedCurrent ? ' btn-with-ico' : ''}`, "data-action": "save-to-project", "data-saved": isSavedCurrent ? 'true' : undefined, disabled: saveState.busy || saveState.removing || isSavedCurrent, title: title, onClick: (e) => { e.stopPropagation(); void runSave(); }, children: saveState.busy ? _jsxs(_Fragment, { children: [_jsx(ButtonSpinner, {}), "Saving\u2026"] }) : isSavedCurrent ? _jsxs(_Fragment, { children: [_jsx(Icon, { icon: IconSuccess, size: "compact" }), "Saved to project"] }) : label })), saveState.done && props.unsave && !saveState.confirmRemove && (_jsx("button", { type: "button", class: "btn-danger btn-sm", "data-action": "unsave-from-project", disabled: saveState.busy || saveState.removing, onClick: (e) => { e.stopPropagation(); void runUnsave(); }, children: saveState.removing ? 'Removing…' : saveState.replaced ? 'Remove' : 'Unsave' })), saveState.done && props.unsave && saveState.confirmRemove && (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", class: "btn-danger btn-sm", "data-action": "confirm-unsave", disabled: saveState.removing, onClick: (e) => { e.stopPropagation(); void runUnsave(); }, children: "Confirm remove" }), _jsx("button", { type: "button", class: "btn-ghost btn-sm", onClick: (e) => { e.stopPropagation(); setSaveState(prev => ({ ...prev, confirmRemove: false })); }, children: "Cancel" })] })), props.makeRule && (_jsx("button", { type: "button", class: "btn-secondary btn-sm", "data-action": "make-rule", disabled: ruleState.busy || Boolean(ruleState.done), title: "Save it into the project and propose a rule for .luci/rules.md that points at it; you review the rule before it counts", onClick: (e) => { e.stopPropagation(); void runMakeRule(); }, children: ruleState.busy ? _jsxs(_Fragment, { children: [_jsx(ButtonSpinner, {}), "Proposing\u2026"] }) : ruleState.done ? 'Rule proposed' : 'Make it a rule' }))] }), (saveState.done || saveState.removedMsg) && (_jsxs("div", { class: "project-actions-meta", children: [saveState.done && _jsx("span", { class: "dim", "data-part": "saved", children: saveState.done }), saveState.removedMsg && _jsx("span", { class: "dim", "data-part": "unsaved", children: saveState.removedMsg }), saveState.done && props.onViewOnSpec && (_jsxs("button", { type: "button", class: "btn-ghost btn-sm btn-with-ico", "data-action": "view-on-spec-pin", title: "Highlight this component's On spec pin on the page", onClick: (e) => { e.stopPropagation(); props.onViewOnSpec(); }, children: [_jsx(Icon, { icon: IconOnSpec, size: "compact" }), _jsx("span", { children: "Show on page" })] }))] })), saveState.error && (_jsxs("div", { class: "project-actions-meta", children: [_jsx("span", { class: "error", "data-part": "save-error", children: saveState.error }), props.onDownload && (_jsx("button", { type: "button", class: "btn-secondary btn-sm", "data-action": "download-fallback", onClick: props.onDownload, children: "Download file instead" }))] })), ruleState.error && _jsx("span", { class: "error", "data-part": "rule-error", children: ruleState.error }), ruleState.done && (_jsxs("div", { class: "stack rule", "data-part": "rule", children: [_jsxs("span", { class: "dim", children: [ruleState.done.existed ? 'This rule is already waiting for your review' : 'Proposed for your review', " in ", _jsx("code", { children: ruleState.done.path }), " (the capture is saved too). To keep it, move this line into ", _jsx("code", { children: ".luci/rules.md" }), "; Luci never edits rules.md itself."] }), _jsx("code", { "data-part": "rule-text", children: ruleState.done.rule })] }))] }));
|
|
63
135
|
}
|
|
64
136
|
const STATE_ORDER = ['hover', 'focus', 'focus-visible', 'active', 'disabled'];
|
|
65
137
|
/** The "Capture by hand" choice that walks through every state Luci could not read. */
|
|
@@ -167,6 +239,7 @@ export function Toolbar(props) {
|
|
|
167
239
|
const trail = useRef([]);
|
|
168
240
|
const drag = useRef(null);
|
|
169
241
|
const lastPointer = useRef(null);
|
|
242
|
+
const dragCleanupRef = useRef(null);
|
|
170
243
|
// Page listeners read these, not render-time values: they must see a key press's effect at once
|
|
171
244
|
const candidateRef = useRef(null);
|
|
172
245
|
const settingsRef = useRef(settings);
|
|
@@ -201,7 +274,7 @@ export function Toolbar(props) {
|
|
|
201
274
|
return o;
|
|
202
275
|
return { ...o, capture: { ...c, responsive: r.data } };
|
|
203
276
|
};
|
|
204
|
-
const show = (given) => {
|
|
277
|
+
const show = (given, preserveRemap = false) => {
|
|
205
278
|
const r = given.ok ? { ok: true, output: withResponsive(given.output) } : given;
|
|
206
279
|
setResult(r);
|
|
207
280
|
setCopied(false);
|
|
@@ -210,6 +283,8 @@ export function Toolbar(props) {
|
|
|
210
283
|
setSettingsOpen(false);
|
|
211
284
|
setEdited(null);
|
|
212
285
|
setViewFile(null);
|
|
286
|
+
if (!preserveRemap)
|
|
287
|
+
setRemapped(null);
|
|
213
288
|
if (r.ok)
|
|
214
289
|
props.onOutput?.(r.output);
|
|
215
290
|
};
|
|
@@ -259,15 +334,50 @@ export function Toolbar(props) {
|
|
|
259
334
|
*/
|
|
260
335
|
const [watchCheck, setWatchCheck] = useState(Boolean(props.autoCheck));
|
|
261
336
|
const [checkVersion, setCheckVersion] = useState(0);
|
|
337
|
+
const [diffOverlay, setDiffOverlay] = useState(DEFAULT_DIFF_OVERLAY);
|
|
262
338
|
const [autoNote, setAutoNote] = useState(null);
|
|
339
|
+
const [checkBlink, setCheckBlink] = useState(null);
|
|
340
|
+
const checkBlinkTimer = useRef(undefined);
|
|
263
341
|
const checkingNow = useRef(false);
|
|
264
342
|
const checkRun = useRef(0);
|
|
343
|
+
const afterEditBlinkEnabled = () => {
|
|
344
|
+
try {
|
|
345
|
+
const raw = props.store
|
|
346
|
+
? props.store.getItem(FEEDBACK_SETTINGS_KEY)
|
|
347
|
+
: (typeof win.localStorage !== 'undefined' ? win.localStorage.getItem(FEEDBACK_SETTINGS_KEY) : null);
|
|
348
|
+
if (!raw)
|
|
349
|
+
return true;
|
|
350
|
+
const parsed = JSON.parse(raw);
|
|
351
|
+
return parsed.afterEditBlink !== false;
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
useEffect(() => () => { clearTimeout(checkBlinkTimer.current); }, []);
|
|
265
358
|
const session = (() => { try {
|
|
266
359
|
return win.sessionStorage;
|
|
267
360
|
}
|
|
268
361
|
catch {
|
|
269
362
|
return null;
|
|
270
363
|
} })();
|
|
364
|
+
const currentCheckPath = () => {
|
|
365
|
+
const p = doc.location.pathname;
|
|
366
|
+
if (/(?:^|\/)iframe\.html$/i.test(p)) {
|
|
367
|
+
const id = new URLSearchParams(doc.location.search).get('id')?.trim();
|
|
368
|
+
if (id && /^[a-z0-9_-]+$/i.test(id))
|
|
369
|
+
return `${p}?id=${id}`;
|
|
370
|
+
}
|
|
371
|
+
return p;
|
|
372
|
+
};
|
|
373
|
+
const formatResolved = (res) => {
|
|
374
|
+
const resolved = res && typeof res === 'object' && 'resolved' in res && Array.isArray(res.resolved)
|
|
375
|
+
? res.resolved
|
|
376
|
+
: [];
|
|
377
|
+
return resolved.length
|
|
378
|
+
? ` ${resolved.length} feedback note${resolved.length === 1 ? '' : 's'} resolved automatically (${resolved.join(', ')}).`
|
|
379
|
+
: '';
|
|
380
|
+
};
|
|
271
381
|
const forgetWatch = () => { try {
|
|
272
382
|
session?.removeItem(AUTO_CHECK_KEY);
|
|
273
383
|
}
|
|
@@ -282,7 +392,7 @@ export function Toolbar(props) {
|
|
|
282
392
|
})).catch(() => undefined);
|
|
283
393
|
if (watchCheck) {
|
|
284
394
|
try {
|
|
285
|
-
session?.setItem(AUTO_CHECK_KEY, JSON.stringify({ selector, design, path:
|
|
395
|
+
session?.setItem(AUTO_CHECK_KEY, JSON.stringify({ selector, design, path: currentCheckPath() }));
|
|
286
396
|
}
|
|
287
397
|
catch { /* storage blocked */ }
|
|
288
398
|
}
|
|
@@ -334,10 +444,15 @@ export function Toolbar(props) {
|
|
|
334
444
|
const res = await afterCheck(outcome, checkDesign, selector);
|
|
335
445
|
const n = outcome.result.differences.length;
|
|
336
446
|
const time = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
447
|
+
setAutoNote(`Checked again at ${time}: ${n ? `${n} difference${n === 1 ? '' : 's'}` : 'it matches the design'}${n !== before ? ` (was ${before})` : ''}.${formatResolved(res)}`);
|
|
448
|
+
if (afterEditBlinkEnabled()) {
|
|
449
|
+
const label = n === 0 && before > 0
|
|
450
|
+
? 'Fixed · matches design'
|
|
451
|
+
: `Updated · ${n ? `${n} diff${n === 1 ? '' : 's'}` : 'matches design'}`;
|
|
452
|
+
setCheckBlink({ el, label, key: Date.now() });
|
|
453
|
+
clearTimeout(checkBlinkTimer.current);
|
|
454
|
+
checkBlinkTimer.current = setTimeout(() => setCheckBlink(null), 950);
|
|
455
|
+
}
|
|
341
456
|
}
|
|
342
457
|
catch {
|
|
343
458
|
// A page in the middle of reloading: the next change checks again
|
|
@@ -373,7 +488,7 @@ export function Toolbar(props) {
|
|
|
373
488
|
catch {
|
|
374
489
|
saved = null;
|
|
375
490
|
}
|
|
376
|
-
if (!saved || !props.autoCheck || saved.path !==
|
|
491
|
+
if (!saved || !props.autoCheck || saved.path !== currentCheckPath())
|
|
377
492
|
return;
|
|
378
493
|
const watch = saved;
|
|
379
494
|
let tries = 0;
|
|
@@ -395,10 +510,12 @@ export function Toolbar(props) {
|
|
|
395
510
|
setPicked({ el, entry, live, eligibility: eligibilityOf(el) });
|
|
396
511
|
checkingNow.current = true;
|
|
397
512
|
void checkAgainst(live, entry, watch.design, forcedStatesReader)
|
|
398
|
-
.then(
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
513
|
+
.then(async (outcome) => {
|
|
514
|
+
if (outcome.ok) {
|
|
515
|
+
const res = await afterCheck(outcome, watch.design, watch.selector);
|
|
516
|
+
setAutoNote(`Checked again after the page reloaded.${formatResolved(res)}`);
|
|
517
|
+
}
|
|
518
|
+
})
|
|
402
519
|
.finally(() => { checkingNow.current = false; });
|
|
403
520
|
}, 250);
|
|
404
521
|
return () => clearInterval(timer);
|
|
@@ -691,14 +808,13 @@ export function Toolbar(props) {
|
|
|
691
808
|
doc.addEventListener('keydown', onKey, true);
|
|
692
809
|
return () => doc.removeEventListener('keydown', onKey, true);
|
|
693
810
|
}, [choosing, picked]);
|
|
694
|
-
// The eyedropper color can come from the shell or a test
|
|
695
811
|
useEffect(() => {
|
|
696
812
|
props.registerPixelInput?.((hex) => {
|
|
697
813
|
const live = liveSnapshot(doc);
|
|
698
814
|
setTool('color');
|
|
699
815
|
setPicking(false);
|
|
700
816
|
setPicked(null);
|
|
701
|
-
show(capturePixel(live, hex,
|
|
817
|
+
show(capturePixel(live, hex, settingsRef.current));
|
|
702
818
|
});
|
|
703
819
|
});
|
|
704
820
|
// While picking, a transparent layer above the page takes every pointer event (see the pick-layer
|
|
@@ -824,7 +940,11 @@ export function Toolbar(props) {
|
|
|
824
940
|
if (picking)
|
|
825
941
|
return;
|
|
826
942
|
const onKey = (e) => {
|
|
827
|
-
if (e.key === 'Escape' && (settingsOpen || picked || result || checkOutcome || checkOpen)) {
|
|
943
|
+
if (e.key === 'Escape' && (basketOpen || settingsOpen || picked || result || checkOutcome || checkOpen)) {
|
|
944
|
+
if (basketOpen) {
|
|
945
|
+
setBasketOpen(false);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
828
948
|
if (settingsOpen) {
|
|
829
949
|
setSettingsOpen(false);
|
|
830
950
|
return;
|
|
@@ -836,12 +956,12 @@ export function Toolbar(props) {
|
|
|
836
956
|
};
|
|
837
957
|
doc.addEventListener('keydown', onKey, true);
|
|
838
958
|
return () => doc.removeEventListener('keydown', onKey, true);
|
|
839
|
-
}, [picking, settingsOpen, picked, result, checkOutcome, checkOpen]);
|
|
959
|
+
}, [picking, basketOpen, settingsOpen, picked, result, checkOutcome, checkOpen]);
|
|
840
960
|
const copyTimer = useRef(undefined);
|
|
841
961
|
useEffect(() => () => clearTimeout(copyTimer.current), []);
|
|
842
962
|
const changeSettings = (next) => {
|
|
843
963
|
// Hand edits belong to one file format: switching it starts from the capture again
|
|
844
|
-
if ((next.style ?? '
|
|
964
|
+
if ((next.style ?? 'stitch') !== (settings.style ?? 'stitch'))
|
|
845
965
|
setEdited(null);
|
|
846
966
|
setSettings(next);
|
|
847
967
|
setCopied(false);
|
|
@@ -856,24 +976,28 @@ export function Toolbar(props) {
|
|
|
856
976
|
const [instructions, setInstructions] = useState('');
|
|
857
977
|
const [edited, setEdited] = useState(null);
|
|
858
978
|
const captureWithInstructions = output ? { ...output.capture, ...(instructions.trim() ? { instructions: instructions.trim() } : {}) } : null;
|
|
859
|
-
// The file people copy and download:
|
|
860
|
-
const
|
|
861
|
-
const
|
|
862
|
-
const
|
|
863
|
-
const
|
|
979
|
+
// The file people copy and download: DESIGN.md for Google Stitch (default), Luci's tables, Tailwind CSS, or CSS Variables
|
|
980
|
+
const activeStyle = settings.style ?? 'stitch';
|
|
981
|
+
const isStitch = activeStyle === 'stitch';
|
|
982
|
+
const isTailwind = activeStyle === 'tailwind';
|
|
983
|
+
const isTailwindV3 = activeStyle === 'tailwind-v3';
|
|
984
|
+
const isCssVars = activeStyle === 'css-vars';
|
|
864
985
|
const isTokenExport = isTailwind || isTailwindV3 || isCssVars;
|
|
865
986
|
const isCustomExport = isStitch || isTokenExport;
|
|
866
987
|
const stitch = isStitch;
|
|
867
|
-
|
|
988
|
+
// rem on this page's root font size, not always 16px (B-27); UI defaults to Smart units (rem / % / px)
|
|
989
|
+
const effectiveUnits = settings.units ?? 'smart';
|
|
990
|
+
const pageSettings = { ...settings, units: effectiveUnits, rootFontSize: pageRootFontSize(doc) };
|
|
991
|
+
const luciMarkdown = (!isCustomExport ? edited : null) ?? (captureWithInstructions ? formatCapture(captureWithInstructions, pageSettings) : '');
|
|
868
992
|
const markdown = edited ?? (captureWithInstructions
|
|
869
993
|
? (isStitch
|
|
870
|
-
? formatStitch([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)])
|
|
994
|
+
? formatStitch([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)], { settings: pageSettings })
|
|
871
995
|
: isTailwind
|
|
872
|
-
? formatTailwind([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)])
|
|
996
|
+
? formatTailwind([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)], { settings: pageSettings })
|
|
873
997
|
: isTailwindV3
|
|
874
|
-
? formatTailwindV3([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)])
|
|
998
|
+
? formatTailwindV3([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)], { settings: pageSettings })
|
|
875
999
|
: isCssVars
|
|
876
|
-
? formatCssVariables([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)])
|
|
1000
|
+
? formatCssVariables([captureWithInstructions, ...(output?.files ?? []).map(f => f.capture)], { settings: pageSettings })
|
|
877
1001
|
: luciMarkdown)
|
|
878
1002
|
: '');
|
|
879
1003
|
const outputName = output
|
|
@@ -890,8 +1014,9 @@ export function Toolbar(props) {
|
|
|
890
1014
|
const changeInstructions = (text) => {
|
|
891
1015
|
setInstructions(text);
|
|
892
1016
|
setCopied(false);
|
|
893
|
-
// Edited text keeps the edits; only its instructions section follows the box
|
|
894
|
-
|
|
1017
|
+
// Edited text keeps the edits; only its instructions section follows the box. Edited CSS or JS
|
|
1018
|
+
// (a token export) gets no Markdown section: the note stays in Luci's file (B-29)
|
|
1019
|
+
if (edited !== null && !isTokenExport)
|
|
895
1020
|
setEdited(withInstructions(edited, text));
|
|
896
1021
|
};
|
|
897
1022
|
const copyText = async (text) => {
|
|
@@ -953,7 +1078,10 @@ export function Toolbar(props) {
|
|
|
953
1078
|
note = `The window could not be resized (${err instanceof Error ? err.message : String(err)}), so Luci read the page in a hidden frame instead.`;
|
|
954
1079
|
}
|
|
955
1080
|
responsiveRef.current = { selector: output.capture.meta.selector, data };
|
|
956
|
-
|
|
1081
|
+
if (remapped) {
|
|
1082
|
+
setRemapped(prev => prev ? { ...prev, original: withResponsive(prev.original) } : null);
|
|
1083
|
+
}
|
|
1084
|
+
show({ ok: true, output }, true);
|
|
957
1085
|
setWidthNote({ text: note ?? `${data.changes.length ? `${data.changes.length} change${data.changes.length === 1 ? '' : 's'}` : 'Nothing changes'} at ${data.widths.map(w => `${w}px`).join(', ')}: see Responsive in the file.` });
|
|
958
1086
|
}
|
|
959
1087
|
catch (err) {
|
|
@@ -968,11 +1096,12 @@ export function Toolbar(props) {
|
|
|
968
1096
|
downloadText(outputName, markdown); };
|
|
969
1097
|
// A section (v0.2): its component files follow the unit and color settings too
|
|
970
1098
|
const [viewFile, setViewFile] = useState(null);
|
|
971
|
-
const sectionFiles = (output?.files ?? []).map(f => ({ fileName: f.fileName, markdown: formatCapture(f.capture,
|
|
1099
|
+
const sectionFiles = (output?.files ?? []).map(f => ({ fileName: f.fileName, markdown: formatCapture(f.capture, pageSettings), capture: f.capture }));
|
|
972
1100
|
const downloadZip = () => {
|
|
973
1101
|
if (!output)
|
|
974
1102
|
return;
|
|
975
|
-
|
|
1103
|
+
// The .zip holds Luci's .design.md files, whatever File is set to: never CSS under a .design.md name (B-29)
|
|
1104
|
+
const bytes = zip([{ name: output.fileName, data: luciMarkdown }, ...sectionFiles.map(f => ({ name: f.fileName, data: f.markdown }))]);
|
|
976
1105
|
const url = URL.createObjectURL(new Blob([bytes], { type: 'application/zip' }));
|
|
977
1106
|
const a = doc.createElement('a');
|
|
978
1107
|
a.href = url;
|
|
@@ -991,6 +1120,14 @@ export function Toolbar(props) {
|
|
|
991
1120
|
await props.saveToProject(f.fileName, f.markdown);
|
|
992
1121
|
return sectionFiles.length ? { ...first, path: `${first.path} and ${sectionFiles.length} component file${sectionFiles.length === 1 ? '' : 's'}` } : first;
|
|
993
1122
|
};
|
|
1123
|
+
const unsaveAll = props.unsaveFromProject
|
|
1124
|
+
? async () => {
|
|
1125
|
+
await props.unsaveFromProject(output.fileName);
|
|
1126
|
+
for (const f of sectionFiles) {
|
|
1127
|
+
await props.unsaveFromProject(f.fileName).catch(() => undefined);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
: undefined;
|
|
994
1131
|
// The basket (FR18, FR19): kept by the shell's store, so it survives pages and sites
|
|
995
1132
|
const [basket, setBasket] = useState([]);
|
|
996
1133
|
const [basketExport, setBasketExport] = useState(null);
|
|
@@ -1052,13 +1189,15 @@ export function Toolbar(props) {
|
|
|
1052
1189
|
// Connected project info (v0.4.4): active project name from luci serve /health
|
|
1053
1190
|
const [activeProject, setActiveProject] = useState(null);
|
|
1054
1191
|
const [bridgePortInput, setBridgePortInput] = useState('');
|
|
1192
|
+
// Until the first answer, the card says it is checking (not "Not connected", which may be wrong)
|
|
1193
|
+
const [projectChecked, setProjectChecked] = useState(!props.projectInfo?.get);
|
|
1055
1194
|
const refreshProject = () => {
|
|
1056
1195
|
if (props.projectInfo?.get) {
|
|
1057
1196
|
props.projectInfo.get().then(info => {
|
|
1058
1197
|
setActiveProject(info);
|
|
1059
1198
|
if (info?.url)
|
|
1060
1199
|
setBridgePortInput(info.url);
|
|
1061
|
-
}).catch(() => { setActiveProject(null); });
|
|
1200
|
+
}).catch(() => { setActiveProject(null); }).finally(() => setProjectChecked(true));
|
|
1062
1201
|
}
|
|
1063
1202
|
};
|
|
1064
1203
|
useEffect(() => {
|
|
@@ -1121,18 +1260,21 @@ export function Toolbar(props) {
|
|
|
1121
1260
|
setBasketSending(false);
|
|
1122
1261
|
}
|
|
1123
1262
|
};
|
|
1263
|
+
const basketSettings = { ...settings, units: effectiveUnits, rootFontSize: pageRootFontSize(doc) };
|
|
1124
1264
|
const exported = basketExport
|
|
1125
1265
|
? (isStitch
|
|
1126
1266
|
// DESIGN.md for Stitch: the item, or the whole basket, in one file (with each item's note)
|
|
1127
|
-
? { fileName: STITCH_FILE_NAME, markdown: formatStitch((basketExport.item ? [basketExport.item] : basket).map(i => i.capture)) }
|
|
1267
|
+
? { fileName: STITCH_FILE_NAME, markdown: formatStitch((basketExport.item ? [basketExport.item] : basket).map(i => i.capture), { settings: basketSettings }) }
|
|
1128
1268
|
: isTailwind
|
|
1129
|
-
? { fileName: TAILWIND_V4_FILE_NAME, markdown: formatTailwind((basketExport.item ? [basketExport.item] : basket).map(i => i.capture)) }
|
|
1269
|
+
? { fileName: TAILWIND_V4_FILE_NAME, markdown: formatTailwind((basketExport.item ? [basketExport.item] : basket).map(i => i.capture), { settings: basketSettings }) }
|
|
1130
1270
|
: isTailwindV3
|
|
1131
|
-
? { fileName: TAILWIND_V3_FILE_NAME, markdown: formatTailwindV3((basketExport.item ? [basketExport.item] : basket).map(i => i.capture)) }
|
|
1271
|
+
? { fileName: TAILWIND_V3_FILE_NAME, markdown: formatTailwindV3((basketExport.item ? [basketExport.item] : basket).map(i => i.capture), { settings: basketSettings }) }
|
|
1132
1272
|
: isCssVars
|
|
1133
|
-
? { fileName: CSS_VARS_FILE_NAME, markdown: formatCssVariables((basketExport.item ? [basketExport.item] : basket).map(i => i.capture)) }
|
|
1134
|
-
: basketExport.item ? exportItem(basketExport.item,
|
|
1273
|
+
? { fileName: CSS_VARS_FILE_NAME, markdown: formatCssVariables((basketExport.item ? [basketExport.item] : basket).map(i => i.capture), { settings: basketSettings }) }
|
|
1274
|
+
: basketExport.item ? exportItem(basketExport.item, basketSettings) : basket.length ? exportBasket(basket, basketSettings) : null)
|
|
1135
1275
|
: null;
|
|
1276
|
+
/** What "Save to project" keeps: Luci's file, whatever File is set to; the project only takes .design.md files (B-29). */
|
|
1277
|
+
const luciExport = () => (basketExport?.item ? exportItem(basketExport.item, settings) : exportBasket(basket, settings));
|
|
1136
1278
|
const Dropper = win.EyeDropper;
|
|
1137
1279
|
const hasDropper = Boolean(Dropper);
|
|
1138
1280
|
// Pixel mode: a screenshot of the page (taken with Luci hidden), read under the pointer. Unlike the
|
|
@@ -1161,7 +1303,7 @@ export function Toolbar(props) {
|
|
|
1161
1303
|
canvas.height = img.naturalHeight;
|
|
1162
1304
|
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
1163
1305
|
ctx.drawImage(img, 0, 0);
|
|
1164
|
-
shot.current = { ctx, scale: img.naturalWidth / win.innerWidth };
|
|
1306
|
+
shot.current = { ctx, scale: img.naturalWidth / (doc.documentElement.clientWidth || win.innerWidth) };
|
|
1165
1307
|
}
|
|
1166
1308
|
finally {
|
|
1167
1309
|
if (host)
|
|
@@ -1316,7 +1458,7 @@ export function Toolbar(props) {
|
|
|
1316
1458
|
const { sRGBHex } = await new Dropper().open();
|
|
1317
1459
|
setDropperOpen(false);
|
|
1318
1460
|
setPicked(null);
|
|
1319
|
-
show(capturePixel(liveSnapshot(doc), sRGBHex,
|
|
1461
|
+
show(capturePixel(liveSnapshot(doc), sRGBHex, settingsRef.current));
|
|
1320
1462
|
}
|
|
1321
1463
|
catch {
|
|
1322
1464
|
// Esc in the eyedropper: back to picking an element
|
|
@@ -1354,6 +1496,11 @@ export function Toolbar(props) {
|
|
|
1354
1496
|
win.addEventListener('resize', onResize);
|
|
1355
1497
|
return () => win.removeEventListener('resize', onResize);
|
|
1356
1498
|
}, [Boolean(place)]);
|
|
1499
|
+
useEffect(() => {
|
|
1500
|
+
return () => {
|
|
1501
|
+
dragCleanupRef.current?.();
|
|
1502
|
+
};
|
|
1503
|
+
}, []);
|
|
1357
1504
|
const startMove = (e) => {
|
|
1358
1505
|
const bar = barRef.current, shell = shellRef.current;
|
|
1359
1506
|
if (!props.movable || e.button !== 0 || !bar || !shell)
|
|
@@ -1365,13 +1512,18 @@ export function Toolbar(props) {
|
|
|
1365
1512
|
const isBtn = Boolean(t.closest?.('.menu-btn'));
|
|
1366
1513
|
moveRef.current = { id: e.pointerId, x: e.clientX, y: e.clientY, shell: shell.getBoundingClientRect(), bar: bar.getBoundingClientRect(), moved: false, isBtn };
|
|
1367
1514
|
// Follow the pointer wherever it goes (a quick drag leaves the bar before it counts as one)
|
|
1515
|
+
const cleanup = () => {
|
|
1516
|
+
doc.removeEventListener('pointermove', doMove, true);
|
|
1517
|
+
doc.removeEventListener('pointerup', onUp, true);
|
|
1518
|
+
doc.removeEventListener('pointercancel', onUp, true);
|
|
1519
|
+
dragCleanupRef.current = null;
|
|
1520
|
+
};
|
|
1521
|
+
dragCleanupRef.current = cleanup;
|
|
1368
1522
|
const onUp = (ev) => {
|
|
1369
1523
|
endMove(ev);
|
|
1370
1524
|
if (moveRef.current)
|
|
1371
1525
|
return;
|
|
1372
|
-
|
|
1373
|
-
doc.removeEventListener('pointerup', onUp, true);
|
|
1374
|
-
doc.removeEventListener('pointercancel', onUp, true);
|
|
1526
|
+
cleanup();
|
|
1375
1527
|
};
|
|
1376
1528
|
doc.addEventListener('pointermove', doMove, true);
|
|
1377
1529
|
doc.addEventListener('pointerup', onUp, true);
|
|
@@ -1444,9 +1596,17 @@ export function Toolbar(props) {
|
|
|
1444
1596
|
const hoverElig = hovered ? eligibilityOf(hovered) : null;
|
|
1445
1597
|
const rect = hovered?.getBoundingClientRect();
|
|
1446
1598
|
const cs = hovered && tool === 'spacing' ? win.getComputedStyle(hovered) : null;
|
|
1447
|
-
|
|
1599
|
+
const isDevToolbar = Boolean(props.modes && !props.movable);
|
|
1600
|
+
const isExtensionToolbar = Boolean(props.modes && props.movable);
|
|
1601
|
+
return (_jsxs("div", { class: "luci luci-theme", "data-theme": uiPrefs.theme, "data-dock": uiPrefs.dock, children: [_jsxs("div", { class: "shell", "data-part": "shell", ref: shellRef, style: shellStyle, ...(props.movable ? { 'data-movable': '' } : {}), ...(moving ? { 'data-moving': '' } : {}), ...(place ? { 'data-h': place.h, 'data-v': place.v } : {}), children: [_jsxs("div", { class: "bar", role: "toolbar", "aria-label": isDevToolbar ? COPY.capture.devTitle : COPY.capture.title, ref: barRef, onPointerDown: startMove, onClickCapture: swallowDragClick, children: [_jsx("button", { type: "button", class: "menu-btn", "data-action": "settings", "aria-label": COPY.common.menu, "aria-pressed": settingsOpen, "aria-keyshortcuts": KEYS.menu, "data-tip": `${COPY.common.menu} ${KEYS.menu}`, onClick: toggleMenu, children: _jsx(LuciLogo, { size: 48 }) }), props.modes && _jsx(ModeSwitch, { ...props.modes }), _jsx("span", { class: "bar-sep", "aria-hidden": "true" }), TOOLS.map(t => (_jsx(Button, { iconOnly: true, size: "lg", class: "tool", icon: TOOL_ICONS[t], label: COPY.capture.tools[t], tip: t === 'component'
|
|
1602
|
+
? 'Measure styles, tokens, states and anatomy of an element'
|
|
1603
|
+
: t === 'text'
|
|
1604
|
+
? 'Read font family, size, weight and line height'
|
|
1605
|
+
: t === 'color'
|
|
1606
|
+
? 'Inspect fill colour, token and contrast — or Pixel eyedropper'
|
|
1607
|
+
: 'Measure padding, margin or drag between two elements', shortcut: KEYS[t], "data-tool": t, "aria-pressed": currentTool === t, onClick: () => pickTool(t) }))), _jsx(Button, { iconOnly: true, size: "lg", class: "tool", icon: IconPage, label: COPY.capture.tools.page, tip: "Capture text, colours, spacing, components and sections for this whole page", shortcut: KEYS.page, "data-action": "whole-page", "aria-pressed": wholePage && (pageBusy || Boolean(result)), onClick: captureWholePage }), _jsx(Button, { iconOnly: true, size: "lg", class: "tool", icon: IconCheck, label: COPY.capture.tools.check, tip: "Compare a built element against a saved .design.md file, part by part", shortcut: KEYS.check, "data-action": "check", "aria-pressed": checking, onClick: openCheck }), _jsx("span", { class: "bar-sep", "aria-hidden": "true" }), _jsxs("button", { type: "button", class: "basket-pill", "data-action": "basket", "aria-pressed": basketOpen && !settingsOpen, "aria-label": COPY.capture.basketLabel(basket.length), "aria-keyshortcuts": KEYS.basket, "data-tip": `Basket ${KEYS.basket} · Collect, compare, merge or send captures`, onClick: toggleBasket, children: [_jsx(Icon, { icon: IconBasket }), _jsx("span", { class: "basket-full", children: COPY.capture.basket(basket.length) }), _jsx("span", { class: "basket-n", children: basket.length })] }), _jsx(Button, { iconOnly: true, size: "lg", class: "tool", icon: IconClose, label: COPY.common.close, "data-action": "close", onClick: props.onClose })] }), !isExtensionToolbar && greeting && (_jsxs("div", { class: "panel greet", role: "status", "data-part": "greeting", children: [_jsx(Mascot, { pose: "hello", size: 96 }), _jsxs("div", { class: "stack", children: [_jsx("p", { class: "t-title", children: COPY.capture.greeting.title }), _jsx("p", { class: "hint", children: COPY.capture.greeting.body })] })] })), isExtensionToolbar && idle && (_jsxs("div", { class: "sub with-luci", role: "note", "data-part": "start-guide", children: [_jsx(Mascot, { pose: "frame", size: 96 }), _jsxs("div", { class: "sub-body", children: [_jsxs("p", { class: "hint", children: [_jsx("strong", { children: "Capture" }), " extracts components, typography, colours, and spacing for your coding agent. Pick a tool, then click an element."] }), _jsxs("p", { class: "keys", children: ["Switch to ", _jsx("strong", { children: "Team Feedback" }), " to click elements, leave plain notes, and share a review with your team."] })] })] })), isDevToolbar && idle && !greeting && (_jsxs("div", { class: "sub with-luci", role: "note", "data-part": "intro", children: [_jsx(Mascot, { pose: "frame", size: 96 }), _jsxs("div", { class: "sub-body", children: [_jsx("p", { class: "hint", children: COPY.devToolbar.intro.capture.body }), _jsx("p", { class: "keys", children: COPY.devToolbar.intro.capture.keys })] })] })), settingsOpen && (isDevToolbar ? (_jsx(DevSettingsPanel, { currentMode: "capture", uiPrefs: uiPrefs, onUiPrefsChange: setUiPrefs, projectInfo: props.projectInfo, store: props.store, captureSettings: settings, onCaptureSettingsChange: changeSettings, debuggerPermission: props.debuggerPermission, ...(props.onSpecSettings ? { onSpecSettings: props.onSpecSettings } : {}), ...(props.updates ? { updates: props.updates } : {}), ...(props.onHelp ? { onHelp: props.onHelp } : {}) })) : (_jsxs("div", { class: "panel", role: "dialog", "aria-label": COPY.common.menu, "data-part": "settings", children: [_jsxs("div", { class: "menu-head", children: [_jsx(Mascot, { pose: "sit", size: 96 }), _jsxs("div", { class: "brand-stack", children: [_jsxs("div", { class: "brand-title-line", children: [_jsx("span", { class: "brand-title", "data-part": "brand-title", children: isDevToolbar ? COPY.capture.devTitle : COPY.capture.title }), _jsx("span", { class: "brand-sub", "data-part": "brand-sub", children: isDevToolbar ? COPY.capture.devByline : COPY.capture.byline })] }), _jsx("p", { class: "brand-desc", children: isDevToolbar ? COPY.capture.devDescription : COPY.capture.description }), props.onHelp && _jsx("div", { class: "row", children: _jsx(Button, { variant: "secondary", icon: IconInfo, "data-action": "help", onClick: () => props.onHelp(), children: COPY.common.help }) })] }), _jsx(RepoButton, {})] }), !isDevToolbar && (_jsxs("div", { class: "invite", "data-part": "invite", children: [_jsx("p", { class: "invite-title", children: COPY.capture.invite.title }), _jsx("p", { class: "invite-body", children: COPY.capture.invite.body }), LUCI_REPO_URL
|
|
1448
1608
|
? _jsx("a", { class: "btn-link invite-action", "data-action": "take-home", href: LUCI_REPO_URL, target: "_blank", rel: "noopener noreferrer", children: COPY.capture.invite.action })
|
|
1449
|
-
: props.onHelp && _jsx(Button, { variant: "link", class: "invite-action", "data-action": "take-home", onClick: () => props.onHelp('take-luci-home'), children: COPY.capture.invite.action })] })), _jsxs("div", { class: "project-card", "data-part": "connected-project", children: [_jsxs("div", { class: "project-header", children: [_jsx("span", { class: `status-dot ${activeProject?.project ? '
|
|
1609
|
+
: props.onHelp && _jsx(Button, { variant: "link", class: "invite-action", "data-action": "take-home", onClick: () => props.onHelp('take-luci-home'), children: COPY.capture.invite.action })] })), _jsxs("div", { class: "project-card", "data-part": "connected-project", children: [_jsxs("div", { class: "project-header", children: [_jsx("span", { class: `status-dot ${!activeProject?.project ? 'offline' : (activeProject.initialized === false ? 'warning' : 'online')}`, "aria-hidden": "true" }), _jsx("div", { class: "project-info", children: !projectChecked ? (_jsx("span", { class: "project-name", "data-part": "project-checking", children: "Checking the connection\u2026" })) : activeProject?.project ? (activeProject.initialized === false ? (_jsxs(_Fragment, { children: [_jsxs("span", { class: "project-name", children: ["Connected, but this folder isn't set up for Luci. Run ", _jsx("code", { children: "luci init" }), " in your project folder."] }), _jsx("span", { class: "project-path dim", children: projectLabel(activeProject) })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { class: "project-name", children: activeProject.name ? `Connected to ${activeProject.name}` : 'Not connected to a project' }), _jsx("span", { class: "project-path dim", children: projectLabel(activeProject) })] }))) : (_jsxs(_Fragment, { children: [_jsx("span", { class: "project-name", children: "Not connected to a project" }), _jsxs("span", { class: "project-hint dim", children: ["Run ", _jsx("code", { children: "luci serve" }), " in your project terminal"] })] })) })] }), props.projectInfo?.setUrl && (_jsxs("div", { class: "project-port-row", children: [_jsx("label", { class: "dim", for: "luci-bridge-url", children: "Bridge:" }), _jsx("input", { id: "luci-bridge-url", type: "text", class: "port-input", "data-part": "port-input", value: bridgePortInput, placeholder: "http://127.0.0.1:4545", onChange: e => {
|
|
1450
1610
|
const val = e.currentTarget.value;
|
|
1451
1611
|
setBridgePortInput(val);
|
|
1452
1612
|
void props.projectInfo?.setUrl?.(val).then(refreshProject);
|
|
@@ -1456,7 +1616,7 @@ export function Toolbar(props) {
|
|
|
1456
1616
|
? (useDebugger
|
|
1457
1617
|
? 'Luci uses it during a capture for exact states and widths, then detaches it'
|
|
1458
1618
|
: 'Luci never attaches it: states come from stylesheet rules, widths from a hidden frame')
|
|
1459
|
-
: 'Chrome is not letting Luci use it: states come from stylesheet rules, widths from a hidden frame' })] })] }), _jsxs("div", { class: "project-port-row", children: [debuggerGranted && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "toggle-debugger", onClick: () => changeSettings({ ...settings, useDebugger: !useDebugger }), children: useDebugger ? "Don't use the debugger" : 'Use the debugger' })), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "debugger-help", onClick: openDebuggerHelp, children: "About the debugger" })] })] })), _jsx("hr", { class: "settings-divider" }), _jsx(AppearanceControls, { prefs: uiPrefs, onChange: setUiPrefs, movable: Boolean(props.movable || props.modes), moved: props.movable ? Boolean(place) : Boolean(props.modes && uiPrefs.devPlace) }), _jsx("hr", { class: "settings-divider" }), _jsxs("div", { class: "stack", children: [_jsx("span", { class: "field-label", children: "Default file format" }), _jsxs("div", { class: "settings-grid", children: [_jsxs("label", { class: "field-stack", children: [_jsx("span", { class: "dim", children: "Units" }), _jsxs(Select, { "data-setting": "units", value: settings.units ?? 'px', onChange: e => changeSettings({ ...settings, units: e.currentTarget.value }), children: [_jsx("option", { value: "px", children: "px" }), _jsx("option", { value: "rem", children: "rem" }), _jsx("option", { value: "both", children: "both" })] })] }), _jsxs("label", { class: "field-stack", children: [_jsx("span", { class: "dim", children: "Colours" }), _jsxs(Select, { "data-setting": "colors", value: settings.colors ?? 'hex', onChange: e => changeSettings({ ...settings, colors: e.currentTarget.value }), children: [_jsx("option", { value: "hex", children: "hex" }), _jsx("option", { value: "rgb", children: "rgb" }), _jsx("option", { value: "hsl", children: "hsl" }), _jsx("option", { value: "oklch", children: "oklch" })] })] }), _jsxs("label", { class: "field-stack", title: "The file's source line: the page address, or only the site name", children: [_jsx("span", { class: "dim", children: "Source" }), _jsxs(Select, { "data-setting": "source", value: settings.source ?? 'page', onChange: e => changeSettings({ ...settings, source: e.currentTarget.value }), children: [_jsx("option", { value: "page", children: "page address" }), _jsx("option", { value: "site", children: "site name only" })] })] }), _jsxs("label", { class: "field-stack", title: "The file you copy, download and export: Luci's tables, DESIGN.md for Google Stitch, Tailwind CSS, or CSS Variables", children: [_jsx("span", { class: "dim", children: "File" }), _jsxs(Select, { "data-setting": "style", value: settings.style ?? 'luci', onChange: e => changeSettings({ ...settings, style: e.currentTarget.value }), children: [_jsx("option", { value: "luci", children: "Luci tables" }), _jsx("option", { value: "stitch", children: "DESIGN.md (Stitch)" }), _jsx("option", { value: "tailwind", children: "Tailwind v4 (@theme)" }), _jsx("option", { value: "tailwind-v3", children: "Tailwind v3 (config.js)" }), _jsx("option", { value: "css-vars", children: "CSS Variables (tokens.css)" })] })] })] })] }), _jsx("hr", { class: "settings-divider" }), _jsxs("div", { class: "stack", children: [_jsx("span", { class: "field-label", children: "Keys" }), _jsxs("div", { class: "shortcut-list", "data-part": "keys", children: [_jsx("span", { children: TOOLS.map(t => _jsxs(_Fragment, { children: [_jsx("kbd", { class: "kbd", children: KEYS[t] }), " "] })) }), _jsx("span", { class: "dim", children: "Component, Text, Colour, Spacing" }), _jsxs("span", { children: [_jsx("kbd", { class: "kbd", children: KEYS.page }), " ", _jsx("kbd", { class: "kbd", children: KEYS.check })] }), _jsx("span", { class: "dim", children: "Whole page, Check a build" }), _jsxs("span", { children: [_jsx("kbd", { class: "kbd", children: KEYS.basket }), " ", _jsx("kbd", { class: "kbd", children: KEYS.menu })] }), _jsx("span", { class: "dim", children: "Basket, this menu" }), _jsxs("span", { children: [_jsx("kbd", { class: "kbd", children: "\u2191" }), " ", _jsx("kbd", { class: "kbd", children: "\u2193" })] }), _jsx("span", { class: "dim", children: "Wider or narrower selection" }), _jsx("span", { children: _jsx("kbd", { class: "kbd", children: "Enter" }) }), _jsx("span", { class: "dim", children: "Pick, then take This one" }), _jsx("span", { children: _jsx("kbd", { class: "kbd", children: "Esc" }) }), _jsx("span", { class: "dim", children: "Stop picking, or close the panel" })] })] })] }))), !settingsOpen && pageBusy && !basketOpen && (_jsx("div", { class: "panel", children: _jsx(Loading, { sleep: true, text: COPY.capture.readingPage, step: pageStep }) })), !settingsOpen && basketOpen && (_jsx("div", { class: "panel", role: "dialog", "aria-label": "Basket", "data-part": "basket", children: comparison ? (_jsxs(_Fragment, { children: [_jsx("h2", { children: "Compare" }), _jsxs("p", { class: "hint", "data-part": "compare-summary", children: ["A: ", comparison.result.a.name, " (", sourceLabel(comparison.items[0]), comparison.result.a.note ? `, your note: ${comparison.result.a.note}` : '', "). B: ", comparison.result.b.name, " (", sourceLabel(comparison.items[1]), comparison.result.b.note ? `, your note: ${comparison.result.b.note}` : '', "). ", comparison.result.same.length, " value", comparison.result.same.length === 1 ? ' is' : 's are', " the same; ", comparison.result.differences.length, " differ", comparison.result.differences.length === 1 ? 's' : '', "."] }), comparison.result.differences.length ? (_jsx("div", { class: "compare-scroll", children: _jsxs("table", { class: "compare", "data-part": "compare-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { class: "col-what", children: "What" }), _jsx("th", { class: "col-a", children: "A" }), _jsx("th", { class: "col-b", children: "B" })] }) }), _jsx("tbody", { children: comparison.result.differences.map(d => _jsxs("tr", { children: [_jsx("td", { class: "col-what", children: d.what }), _jsx("td", { class: "col-a", children: d.a }), _jsx("td", { class: "col-b", children: d.b })] })) })] }) })) : _jsx("p", { class: "hint", children: "No differences: every value compared is the same." }), _jsxs("div", { class: "row actions", children: [_jsx(Button, { variant: "primary", size: "md", iconOnly: true, tipAbove: true, tipAlign: "left", icon: copied ? IconSuccess : IconCopy, label: copied ? COPY.common.copied : 'Copy the comparison', "data-action": "copy-compare", onClick: () => void copyText(formatCompareReport(comparison.result, { a: comparison.items[0].name, b: comparison.items[1].name })) }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "compare-back", onClick: () => { setComparison(null); setCopied(false); }, children: "Back to the basket" })] })] })) : basketExport && exported ? (_jsxs(_Fragment, { children: [_jsx("h2", { children: basketExport.title }), _jsx("div", { class: "file", "data-part": "file-name", children: exported.fileName }), _jsx("pre", { "data-part": "preview", children: exported.markdown }), _jsxs("div", { class: "row actions", children: [_jsx(Button, { variant: "primary", size: "md", iconOnly: true, tipAbove: true, tipAlign: "left", icon: copied ? IconSuccess : IconCopy, label: copied ? COPY.common.copied : COPY.capture.actions.copy, "data-action": "copy", onClick: () => void copyText(exported.markdown) }), _jsx(Button, { variant: "secondary", size: "md", iconOnly: true, tipAbove: true, icon: IconDownload, label: COPY.capture.actions.download, "data-action": "download", onClick: () => downloadText(exported.fileName, exported.markdown) }), props.saveToProject && _jsx(SaveButton, { save: () => props.saveToProject(exported.fileName, exported.markdown), onDownload: () => downloadText(exported.fileName, exported.markdown), projectName: activeProject?.name }, exported.fileName), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "basket-back", onClick: () => { setBasketExport(null); setCopied(false); }, children: "Back to the basket" })] })] })) : (_jsxs(_Fragment, { children: [_jsx("h2", { children: "Basket" }), !basket.length ? (_jsx(EmptyState, { pose: "box", title: COPY.capture.basketEmpty.title, body: COPY.capture.basketEmpty.body, part: "basket-empty" })) : (_jsx("ul", { class: "items", children: basket.map(item => (_jsxs("li", { "data-item": item.id, children: [_jsxs("span", { class: "meta", children: [groupOf(item.capture), " \u00B7 ", sourceLabel(item)] }), basket.length > 1 && (_jsxs("label", { class: "compare-pick", title: "Pick two items to compare them", children: [_jsx("input", { type: "checkbox", "data-item-compare": true, checked: compareIds.includes(item.id), onChange: e => setCompareIds(ids => (e.currentTarget.checked ? [...ids.filter(i => i !== item.id), item.id].slice(-2) : ids.filter(i => i !== item.id))) }), "Compare"] })), _jsx("input", { type: "text", "aria-label": "Name", "data-item-name": true, value: item.name, onChange: e => saveBasket(renameInBasket(basket, item.id, e.currentTarget.value)) }), _jsxs("span", { class: "row", children: [_jsx("button", { type: "button", class: "btn-secondary", "data-item-export": true, onClick: () => setBasketExport({ title: item.name, item }), children: "Export" }), props.saveToProject && (_jsx("button", { type: "button", class: "btn-secondary", "data-item-send-project": true, title: activeProject?.name ? `Save this capture to ${activeProject.name}/.luci/design/` : "Save this capture to .luci/design/ in your project", onClick: () => void sendOneToProject(item), children: itemSent[item.id]?.error ? 'Failed' : itemSent[item.id] ? 'Saved' : 'Send to project' })), _jsx("button", { class: "btn-danger", type: "button", "data-item-remove": true, "aria-label": `Remove ${item.name}`, onClick: () => saveBasket(removeFromBasket(basket, item.id)), children: "Remove" })] }), _jsx("textarea", { "data-item-note": true, "aria-label": `Note for your agent about ${item.name}`, placeholder: "Note for your agent (optional). What to use it for, what to change.", value: item.capture.instructions ?? '', onChange: e => saveBasket(noteInBasket(basket, item.id, e.currentTarget.value)) })] }))) })), mergeable.length > 0 && (_jsxs("div", { class: "stack", "data-part": "merge", children: [_jsxs("span", { class: "dim", children: ["One site, several pages: ", mergeable.map(g => `${g.type} from ${g.pages.length} pages of ${g.site}`).join(', '), ". Merge them into one site file. Each row says which pages use it; values that differ are listed as conflicts."] }), _jsx("span", { class: "row", children: _jsxs("button", { type: "button", class: "btn-secondary", "data-action": "merge-systems", onClick: mergeSystemsNow, children: ["Merge into site system", mergeable.length === 1 ? '' : 's', " (", mergeable.length, ")"] }) })] })), mergedNote && _jsx("p", { class: "hint", "data-part": "merged", children: mergedNote }), compareItems && (_jsxs("div", { class: "row", "data-part": "compare-pick", children: [_jsxs("span", { class: "dim", children: [compareItems[0].name, " and ", compareItems[1].name] }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "compare", onClick: () => { setComparison({ items: compareItems, result: compareCaptures(compareItems[0].capture, compareItems[1].capture) }); setCopied(false); }, children: "Compare the two" })] })), _jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-primary", "data-action": "export-all", disabled: !basket.length, onClick: () => setBasketExport({ title: `All ${basket.length} items, one file` }), children: "Export all as one file" }), props.saveToProject && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "send-all-project", disabled: !basket.length || basketSending, title: activeProject?.name ? `Save each capture in the basket to ${activeProject.name}/.luci/design/` : "Save each capture in the basket to .luci/design/ in your project", onClick: () => void sendAllToProject(), children: basketSending ? _jsxs(_Fragment, { children: [_jsx(ButtonSpinner, {}), "Sending\u2026"] }) : 'Send all to project' })), basket.length > 0 && (confirmClear
|
|
1619
|
+
: 'Chrome is not letting Luci use it: states come from stylesheet rules, widths from a hidden frame' })] })] }), _jsxs("div", { class: "project-port-row", children: [debuggerGranted && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "toggle-debugger", onClick: () => changeSettings({ ...settings, useDebugger: !useDebugger }), children: useDebugger ? "Don't use the debugger" : 'Use the debugger' })), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "debugger-help", onClick: openDebuggerHelp, children: "About the debugger" })] })] })), _jsx("hr", { class: "settings-divider" }), _jsx(AppearanceControls, { prefs: uiPrefs, onChange: setUiPrefs, movable: Boolean(props.movable || props.modes), moved: props.movable ? Boolean(place) : Boolean(props.modes && uiPrefs.devPlace) }), (props.updates || props.extensionVersion) && (_jsxs(_Fragment, { children: [_jsx("hr", { class: "settings-divider" }), _jsx(UpdatesSettingsSection, { ...(props.updates ? { updates: props.updates } : {}), ...(props.extensionVersion ? { extensionVersion: props.extensionVersion } : {}) })] })), _jsx("hr", { class: "settings-divider" }), _jsxs("div", { class: "stack", children: [_jsx("span", { class: "field-label", children: "Default file format" }), _jsxs("div", { class: "settings-grid", children: [_jsxs("label", { class: "field-stack", title: "Smart uses rem for text and spacing, preserves authored %/vw/vh for layouts, and keeps borders and radii in px", children: [_jsx("span", { class: "dim", children: "Units" }), _jsxs(Select, { "data-setting": "units", value: settings.units ?? 'smart', onChange: e => changeSettings({ ...settings, units: e.currentTarget.value }), children: [_jsx("option", { value: "smart", children: "Smart (rem / % / px)" }), _jsx("option", { value: "px", children: "px" }), _jsx("option", { value: "rem", children: "rem" }), _jsx("option", { value: "both", children: "both" })] })] }), _jsxs("label", { class: "field-stack", children: [_jsx("span", { class: "dim", children: "Colours" }), _jsxs(Select, { "data-setting": "colors", value: settings.colors ?? 'hex', onChange: e => changeSettings({ ...settings, colors: e.currentTarget.value }), children: [_jsx("option", { value: "hex", children: "hex" }), _jsx("option", { value: "rgb", children: "rgb" }), _jsx("option", { value: "hsl", children: "hsl" }), _jsx("option", { value: "oklch", children: "oklch" })] })] }), _jsxs("label", { class: "field-stack", title: "The file's source line: the page address, or only the site name", children: [_jsx("span", { class: "dim", children: "Source" }), _jsxs(Select, { "data-setting": "source", value: settings.source ?? 'page', onChange: e => changeSettings({ ...settings, source: e.currentTarget.value }), children: [_jsx("option", { value: "page", children: "page address" }), _jsx("option", { value: "site", children: "site name only" })] })] }), _jsxs("label", { class: "field-stack", title: "The file you copy, download and export: DESIGN.md for Google Stitch, Luci's tables, Tailwind CSS, or CSS Variables", children: [_jsx("span", { class: "dim", children: "File" }), _jsxs(Select, { "data-setting": "style", value: settings.style ?? 'stitch', onChange: e => changeSettings({ ...settings, style: e.currentTarget.value }), children: [_jsx("option", { value: "stitch", children: "DESIGN.md (Stitch)" }), _jsx("option", { value: "luci", children: "Luci tables" }), _jsx("option", { value: "tailwind", children: "Tailwind v4 (@theme)" }), _jsx("option", { value: "tailwind-v3", children: "Tailwind v3 (config.js)" }), _jsx("option", { value: "css-vars", children: "CSS Variables (tokens.css)" })] })] })] })] }), _jsx("hr", { class: "settings-divider" }), _jsxs("div", { class: "stack", children: [_jsx("span", { class: "field-label", children: "Keys" }), _jsxs("div", { class: "shortcut-list", "data-part": "keys", children: [_jsx("span", { children: TOOLS.map(t => _jsxs(_Fragment, { children: [_jsx("kbd", { class: "kbd", children: KEYS[t] }), " "] })) }), _jsx("span", { class: "dim", children: "Component, Text, Colour, Spacing" }), _jsxs("span", { children: [_jsx("kbd", { class: "kbd", children: KEYS.page }), " ", _jsx("kbd", { class: "kbd", children: KEYS.check })] }), _jsx("span", { class: "dim", children: "Whole page, Check a build" }), _jsxs("span", { children: [_jsx("kbd", { class: "kbd", children: KEYS.basket }), " ", _jsx("kbd", { class: "kbd", children: KEYS.menu })] }), _jsx("span", { class: "dim", children: "Basket, this menu" }), _jsxs("span", { children: [_jsx("kbd", { class: "kbd", children: "\u2191" }), " ", _jsx("kbd", { class: "kbd", children: "\u2193" })] }), _jsx("span", { class: "dim", children: "Wider or narrower selection" }), _jsx("span", { children: _jsx("kbd", { class: "kbd", children: "Enter" }) }), _jsx("span", { class: "dim", children: "Pick, then take This one" }), _jsx("span", { children: _jsx("kbd", { class: "kbd", children: "Esc" }) }), _jsx("span", { class: "dim", children: "Stop picking, or close the panel" })] })] })] }))), !settingsOpen && pageBusy && !basketOpen && (_jsx("div", { class: "panel", children: _jsx(Loading, { sleep: true, text: COPY.capture.readingPage, step: pageStep }) })), !settingsOpen && basketOpen && (_jsx("div", { class: "panel", role: "dialog", "aria-label": "Basket", "data-part": "basket", children: comparison ? (_jsxs(_Fragment, { children: [_jsx("h2", { children: "Compare" }), _jsxs("p", { class: "hint", "data-part": "compare-summary", children: ["A: ", comparison.result.a.name, " (", sourceLabel(comparison.items[0]), comparison.result.a.note ? `, your note: ${comparison.result.a.note}` : '', "). B: ", comparison.result.b.name, " (", sourceLabel(comparison.items[1]), comparison.result.b.note ? `, your note: ${comparison.result.b.note}` : '', "). ", comparison.result.same.length, " value", comparison.result.same.length === 1 ? ' is' : 's are', " the same; ", comparison.result.differences.length, " differ", comparison.result.differences.length === 1 ? 's' : '', "."] }), comparison.result.differences.length ? (_jsx("div", { class: "compare-scroll", children: _jsxs("table", { class: "compare", "data-part": "compare-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { class: "col-what", children: "What" }), _jsx("th", { class: "col-a", children: "A" }), _jsx("th", { class: "col-b", children: "B" })] }) }), _jsx("tbody", { children: comparison.result.differences.map(d => _jsxs("tr", { children: [_jsx("td", { class: "col-what", children: d.what }), _jsx("td", { class: "col-a", children: d.a }), _jsx("td", { class: "col-b", children: d.b })] })) })] }) })) : _jsx("p", { class: "hint", children: "No differences: every value compared is the same." }), _jsxs("div", { class: "row actions", children: [_jsx(Button, { variant: "primary", size: "md", iconOnly: true, tipAbove: true, tipAlign: "left", icon: copied ? IconSuccess : IconCopy, label: copied ? COPY.common.copied : 'Copy the comparison', "data-action": "copy-compare", onClick: () => void copyText(formatCompareReport(comparison.result, { a: comparison.items[0].name, b: comparison.items[1].name })) }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "compare-back", onClick: () => { setComparison(null); setCopied(false); }, children: "Back to the basket" })] })] })) : basketExport && exported ? (_jsxs(_Fragment, { children: [_jsx("h2", { children: basketExport.title }), _jsx("div", { class: "file", "data-part": "file-name", children: exported.fileName }), _jsx("pre", { "data-part": "preview", children: exported.markdown }), _jsxs("div", { class: "row actions", children: [_jsx(Button, { variant: "primary", size: "md", iconOnly: true, tipAbove: true, tipAlign: "left", icon: copied ? IconSuccess : IconCopy, label: copied ? COPY.common.copied : COPY.capture.actions.copy, "data-action": "copy", onClick: () => void copyText(exported.markdown) }), _jsx(Button, { variant: "secondary", size: "md", iconOnly: true, tipAbove: true, icon: IconDownload, label: COPY.capture.actions.download, "data-action": "download", onClick: () => downloadText(exported.fileName, exported.markdown) }), props.saveToProject && _jsx(SaveButton, { save: () => { const luci = luciExport(); return props.saveToProject(luci.fileName, luci.markdown); }, onDownload: () => downloadText(exported.fileName, exported.markdown), projectName: activeProject?.name }, exported.fileName), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "basket-back", onClick: () => { setBasketExport(null); setCopied(false); }, children: "Back to the basket" })] })] })) : (_jsxs(_Fragment, { children: [_jsx("h2", { children: "Basket" }), !basket.length ? (_jsx(EmptyState, { pose: "box", title: COPY.capture.basketEmpty.title, body: COPY.capture.basketEmpty.body, part: "basket-empty" })) : (_jsx("ul", { class: "items", children: basket.map(item => (_jsxs("li", { "data-item": item.id, children: [_jsxs("span", { class: "meta", children: [groupOf(item.capture), " \u00B7 ", sourceLabel(item)] }), basket.length > 1 && (_jsxs("label", { class: "compare-pick", title: "Pick two items to compare them", children: [_jsx("input", { type: "checkbox", "data-item-compare": true, checked: compareIds.includes(item.id), onChange: e => setCompareIds(ids => (e.currentTarget.checked ? [...ids.filter(i => i !== item.id), item.id].slice(-2) : ids.filter(i => i !== item.id))) }), "Compare"] })), _jsx("input", { type: "text", "aria-label": "Name", "data-item-name": true, value: item.name, onChange: e => saveBasket(renameInBasket(basket, item.id, e.currentTarget.value)) }), _jsxs("span", { class: "row", children: [_jsx("button", { type: "button", class: "btn-secondary", "data-item-export": true, onClick: () => setBasketExport({ title: item.name, item }), children: "Export" }), props.saveToProject && (_jsx("button", { type: "button", class: "btn-secondary", "data-item-send-project": true, title: activeProject?.name ? `Save this capture to ${activeProject.name}/.luci/design/` : "Save this capture to .luci/design/ in your project", onClick: () => void sendOneToProject(item), children: itemSent[item.id]?.error ? 'Failed' : itemSent[item.id] ? 'Saved' : 'Send to project' })), _jsx("button", { class: "btn-danger", type: "button", "data-item-remove": true, "aria-label": `Remove ${item.name}`, onClick: () => saveBasket(removeFromBasket(basket, item.id)), children: "Remove" })] }), _jsx("textarea", { "data-item-note": true, "aria-label": `Note for your agent about ${item.name}`, placeholder: "Note for your agent (optional). What to use it for, what to change.", value: item.capture.instructions ?? '', onChange: e => saveBasket(noteInBasket(basket, item.id, e.currentTarget.value)) })] }))) })), mergeable.length > 0 && (_jsxs("div", { class: "stack", "data-part": "merge", children: [_jsxs("span", { class: "dim", children: ["One site, several pages: ", mergeable.map(g => `${g.type} from ${g.pages.length} pages of ${g.site}`).join(', '), ". Merge them into one site file. Each row says which pages use it; values that differ are listed as conflicts."] }), _jsx("span", { class: "row", children: _jsxs("button", { type: "button", class: "btn-secondary", "data-action": "merge-systems", onClick: mergeSystemsNow, children: ["Merge into site system", mergeable.length === 1 ? '' : 's', " (", mergeable.length, ")"] }) })] })), mergedNote && _jsx("p", { class: "hint", "data-part": "merged", children: mergedNote }), compareItems && (_jsxs("div", { class: "row", "data-part": "compare-pick", children: [_jsxs("span", { class: "dim", children: [compareItems[0].name, " and ", compareItems[1].name] }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "compare", onClick: () => { setComparison({ items: compareItems, result: compareCaptures(compareItems[0].capture, compareItems[1].capture) }); setCopied(false); }, children: "Compare the two" })] })), _jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-primary", "data-action": "export-all", disabled: !basket.length, onClick: () => setBasketExport({ title: `All ${basket.length} items, one file` }), children: "Export all as one file" }), props.saveToProject && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "send-all-project", disabled: !basket.length || basketSending, title: activeProject?.name ? `Save each capture in the basket to ${activeProject.name}/.luci/design/` : "Save each capture in the basket to .luci/design/ in your project", onClick: () => void sendAllToProject(), children: basketSending ? _jsxs(_Fragment, { children: [_jsx(ButtonSpinner, {}), "Sending\u2026"] }) : 'Send all to project' })), basket.length > 0 && (confirmClear
|
|
1460
1620
|
? _jsx("button", { type: "button", class: "btn-danger", "data-action": "clear-basket-confirm", onClick: () => { saveBasket([]); setConfirmClear(false); }, children: "Yes, empty the basket" })
|
|
1461
1621
|
: _jsx("button", { type: "button", class: "btn-danger", "data-action": "clear-basket", onClick: () => setConfirmClear(true), children: "Empty basket" }))] }), basketStatus && (_jsxs("div", { class: "row", "data-part": "basket-status", children: [_jsx("p", { class: basketStatus.error ? 'error' : 'hint', style: { margin: 0 }, children: basketStatus.text }), basketStatus.error && basketStatus.download && (_jsx("button", { type: "button", class: "btn-secondary", "data-action": "download-fallback", onClick: basketStatus.download, children: "Download file instead" }))] }))] })) })), !settingsOpen && (picking || dropperOpen || pixelMode || imageMode) && tool && (_jsxs("div", { class: `sub with-luci${imageMode ? ' image-drop' : ''}`, "data-part": "tool-hint", role: "note", ...(imageMode ? {
|
|
1462
1622
|
onDragOver: (e) => { e.preventDefault(); },
|
|
@@ -1471,10 +1631,10 @@ export function Toolbar(props) {
|
|
|
1471
1631
|
: checkDesign ? `Click the component you built. Luci checks it against ${checkDesign.label}.`
|
|
1472
1632
|
: `${TOOL_HINTS[tool]}${tool === 'color' && !canPickPixels ? ' This browser cannot pick pixels.' : ''}` }), imageMode && (_jsxs("div", { class: "row", children: [_jsx("input", { ref: imageInput, type: "file", accept: "image/*", "data-part": "image-file", hidden: true, onChange: e => { const f = e.currentTarget.files?.[0]; if (f)
|
|
1473
1633
|
void readImageFile(f, f.name); } }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "choose-image", disabled: imageBusy, onClick: () => imageInput.current?.click(), children: "Choose an image" })] })), _jsx("p", { class: "keys", children: pixelMode || imageMode ? 'Esc: back to Element' : touchScreen(win) ? 'Tap once to see an element, again to take it' : '↑ ↓ after clicking: wider or narrower · Esc: stop' })] })] })), !settingsOpen && picking && notice && (_jsx("div", { class: "panel", role: "status", children: _jsx("p", { class: "error", "data-part": "notice", children: notice }) })), !settingsOpen && checkOpen && !basketOpen && (_jsx(DesignChooser, { ...(props.designs ? { designs: props.designs } : {}), basket: basket, onChoose: chooseDesign, onCancel: endCheck })), !settingsOpen && !picking && !basketOpen && checkOutcome && checkDesign && picked && (_jsx(CheckResultPanel, { outcome: checkOutcome, watching: watchCheck, onWatch: on => { setWatchCheck(on); setAutoNote(null); if (!on)
|
|
1474
|
-
forgetWatch(); }, autoNote: autoNote, design: checkDesign, el: picked.el, selector: picked.entry.selector, ...(props.addCheckNotes ? { addNotes: props.addCheckNotes } : {}), ...(props.checkNotesWhere ? { notesWhere: props.checkNotesWhere } : {}), onCopy: copyText, onAgain: () => startPicking('component'), onChangeDesign: openCheck }, `${picked.entry.selector} ${checkDesign.file} ${checkVersion}`)), !settingsOpen && !picking && !basketOpen && picked && checkDesign && !checkOutcome && !result && (_jsx("div", { class: "panel", role: "dialog", "aria-label": "Design check", "data-part": "check-selected", children: _jsxs("div", { class: "selected-card", children: [_jsxs("div", { class: "selected-head", children: [_jsxs("h2", { children: ["Built: ", _jsx("span", { "data-part": "selected-name", children: elementName(picked.entry.tag, picked.entry.role) })] }), _jsxs("span", { class: "dim", children: [Math.round(picked.el.getBoundingClientRect().width), " \u00D7 ", Math.round(picked.el.getBoundingClientRect().height)] })] }), _jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-secondary", "data-action": "widen", disabled: !widerOf(picked.el), onClick: widen, title: "Select the element around this one (\u2191)", children: "\u2191 Wider" }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "narrow", disabled: !narrowerOf(picked.el), onClick: narrow, title: "Select the element inside this one (\u2193)", children: "\u2193 Narrower" }), _jsx("span", { class: "dim", children: "or \u2191 \u2193" })] }), picked.eligibility.status !== 'allowed' && _jsxs("p", { class: "error", "data-part": "notice", children: [picked.eligibility.reason, " Go wider or narrower."] }), busy ? _jsx(Loading, { text: busy }) : (_jsxs(_Fragment, { children: [_jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-primary", "data-action": "check-run", disabled: picked.eligibility.status !== 'allowed', onClick: () => void runCheck(), children: "Check against the design" }), _jsx("button", { type: "button", class: "btn-secondary", onClick: () => startPicking('component'), children: "Pick again" }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "check-design", onClick: openCheck, children: "Change design" })] }), _jsxs("p", { class: "tip-box", "data-part": "check-against", children: ["Design: ", checkDesign.label] })] }))] }) })), !settingsOpen && !picking && !basketOpen && picked && !checkDesign && !result && tool && (_jsx("div", { class: "panel", role: "dialog", "aria-label": "Capture", children: _jsxs("div", { class: "selected-card", children: [_jsxs("div", { class: "selected-head", children: [_jsxs("h2", { children: ["Selected \u00B7 ", _jsx("span", { "data-part": "selected-name", children: elementName(picked.entry.tag, picked.entry.role) })] }), _jsxs("span", { class: "dim", children: [Math.round(picked.el.getBoundingClientRect().width), " \u00D7 ", Math.round(picked.el.getBoundingClientRect().height)] })] }), _jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-secondary", "data-action": "widen", disabled: !widerOf(picked.el), onClick: widen, title: "Select the element around this one (\u2191)", children: "\u2191 Wider" }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "narrow", disabled: !narrowerOf(picked.el), onClick: narrow, title: "Select the element inside this one (\u2193)", children: "\u2193 Narrower" }), _jsx("span", { class: "dim", children: "or \u2191 \u2193" })] }), picked.eligibility.status === 'redirected' && _jsx("p", { class: "hint", children: picked.eligibility.reason }), picked.eligibility.status === 'blocked' && _jsxs("p", { class: "error", "data-part": "notice", children: [picked.eligibility.reason, " Go wider or narrower."] }), tool === 'spacing' && picked.eligibility.status === 'allowed' && spacingChoices(picked.entry).length > 1 && (_jsxs("div", { class: "row", children: [_jsxs("button", { type: "button", class: "btn-secondary", "aria-pressed": choice === ALL_SPACING, "data-choice": "all", onClick: () => setChoice(ALL_SPACING), children: ["All (", spacingChoices(picked.entry).length, ")"] }), spacingChoices(picked.entry).map((u, i) => (_jsxs("button", { type: "button", class: "btn-secondary", "aria-pressed": choice === i, "data-choice": u.property, onClick: () => setChoice(i), children: [u.property, " ", u.computed] })))] })), busy ? _jsx(Loading, { text: busy }) : (_jsxs(_Fragment, { children: [_jsxs("div", { class: "row", children: [picked.eligibility.status === 'allowed' && (_jsx("button", { type: "button", class: "btn-primary", "data-output": "one", onClick: () => void produce(false), children: "This one" })), picked.eligibility.status !== 'blocked' && (_jsx("button", { type: "button", class: picked.eligibility.status === 'allowed' ? 'btn-secondary' : 'btn-primary', "data-output": "system", onClick: () => void produce(true), children: "The whole system" })), tool === 'component' && picked.eligibility.status === 'allowed' && (_jsx("button", { type: "button", class: "btn-secondary", "data-output": "section", title: SECTION_HINT, onClick: () => void produce(false, true), children: "This section" })), _jsx("button", { type: "button", class: "btn-secondary", onClick: () => startPicking(tool), children: "Pick again" })] }), picked.eligibility.status !== 'blocked' && (_jsxs("p", { class: "tip-box", "data-part": "output-hints", children: [picked.eligibility.status === 'allowed' && _jsxs(_Fragment, { children: ["This one: ", OUTPUT_HINTS[tool].one, ". "] }), "The whole system: ", OUTPUT_HINTS[tool].system, ".", tool === 'component' && picked.eligibility.status === 'allowed' && _jsxs(_Fragment, { children: [" This section: ", SECTION_HINT, "."] })] }))] }))] }) })), !settingsOpen && !picking && !basketOpen && result && (_jsx("div", { class: result.ok ? 'panel result-panel' : 'panel', role: "dialog", "aria-label": "Capture file", children: result.ok ? (_jsxs(_Fragment, { children: [_jsxs("div", { class: "panel-body", children: [_jsxs("div", { class: "file-row", children: [_jsx("div", { class: "file", "data-part": "file-name", children: outputName }), _jsx("span", { class: "scope-pill badge", children: result.output.capture.meta.scope })] }), sectionFiles.length > 0 && (_jsxs("div", { class: "stack", "data-part": "section-files", children: [_jsxs("span", { class: "dim", children: ["Plus ", sectionFiles.length, " component file", sectionFiles.length === 1 ? '' : 's', ", each described once. The section file places them."] }), _jsx("ul", { class: "files", children: sectionFiles.map(f => (_jsxs("li", { "data-file": f.fileName, children: [_jsx("code", { children: f.fileName }), " ", _jsx("button", { type: "button", class: "btn-secondary", "data-file-view": true, onClick: () => setViewFile(f), children: "View" })] }))) })] })), viewFile && (_jsxs("div", { class: "stack", "data-part": "file-view-box", children: [_jsxs("span", { class: "row", children: [_jsx("code", { children: viewFile.fileName }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "file-view-close", onClick: () => setViewFile(null), children: "Back to the section file" })] }), _jsx("pre", { class: "preview", "data-part": "file-view", children: viewFile.markdown })] })), _jsxs("div", { class: "settings-grid", children: [_jsxs("label", { class: "field-stack", children: [_jsx("span", { class: "field-label", children: "Units" }), _jsxs(Select, { "data-setting": "units", value: settings.units ?? 'px', onChange: e => changeSettings({ ...settings, units: e.currentTarget.value }), children: [_jsx("option", { value: "px", children: "px" }), _jsx("option", { value: "rem", children: "rem" }), _jsx("option", { value: "both", children: "both" })] })] }), _jsxs("label", { class: "field-stack", children: [_jsx("span", { class: "field-label", children: "Colours" }), _jsxs(Select, { "data-setting": "colors", value: settings.colors ?? 'hex', onChange: e => changeSettings({ ...settings, colors: e.currentTarget.value }), children: [_jsx("option", { value: "hex", children: "hex" }), _jsx("option", { value: "rgb", children: "rgb" }), _jsx("option", { value: "hsl", children: "hsl" }), _jsx("option", { value: "oklch", children: "oklch" })] })] }), _jsxs("label", { class: "field-stack", title: "The file's source line: the page address, or only the site name", children: [_jsx("span", { class: "field-label", children: "Source" }), _jsxs(Select, { "data-setting": "source", value: settings.source ?? 'page', onChange: e => changeSettings({ ...settings, source: e.currentTarget.value }), children: [_jsx("option", { value: "page", children: "page address" }), _jsx("option", { value: "site", children: "site name only" })] })] }), _jsxs("label", { class: "field-stack", title: "The file you copy and download: Luci's tables, DESIGN.md for Google Stitch, Tailwind CSS, or CSS Variables", children: [_jsx("span", { class: "field-label", children: "File" }), _jsxs(Select, { "data-setting": "style", value: settings.style ?? 'luci', onChange: e => changeSettings({ ...settings, style: e.currentTarget.value }), children: [_jsx("option", { value: "luci", children: "Luci tables" }), _jsx("option", { value: "stitch", children: "DESIGN.md (Stitch)" }), _jsx("option", { value: "tailwind", children: "Tailwind v4 (@theme)" }), _jsx("option", { value: "tailwind-v3", children: "Tailwind v3 (config.js)" }), _jsx("option", { value: "css-vars", children: "CSS Variables (tokens.css)" })] })] })] }), isCustomExport && props.saveToProject && _jsx("p", { class: "dim", "data-part": "stitch-note", children: "Save to project keeps Luci's tables: the design check and your agent's tools read them." }), stateNote && _jsx("p", { class: "hint", "data-part": "state-note", children: stateNote }), componentCtx && result.output.capture.meta.scope === 'component' && (_jsxs("div", { class: "stack", "data-part": "manual-state", children: [_jsx("hr", { class: "settings-divider" }), _jsxs("div", { class: "stack", "data-part": "states-summary", children: [_jsx("span", { class: "field-label", children: "States in this file" }), _jsxs("div", { class: "states-list", children: [_jsx("span", { class: "state default detected", "data-state": "default", title: "Resting state", children: "Default \u2713" }), componentCtx.states.map(s => (_jsxs("span", { class: s.detected ? 'state detected' : 'state missing', "data-state": s.state, title: s.detected ? (s.trigger ? `In the file. Set by the ${s.trigger.element} around it.` : 'In the file.')
|
|
1634
|
+
forgetWatch(); }, autoNote: autoNote, design: checkDesign, el: picked.el, selector: picked.entry.selector, overlay: diffOverlay, onOverlay: setDiffOverlay, ...(props.addCheckNotes ? { addNotes: props.addCheckNotes } : {}), ...(props.checkNotesWhere ? { notesWhere: props.checkNotesWhere } : {}), onCopy: copyText, onAgain: () => startPicking('component'), onChangeDesign: openCheck }, `${picked.entry.selector} ${checkDesign.file}`)), !settingsOpen && !picking && !basketOpen && picked && checkDesign && !checkOutcome && !result && (_jsx("div", { class: "panel", role: "dialog", "aria-label": "Design check", "data-part": "check-selected", children: _jsxs("div", { class: "selected-card", children: [_jsxs("div", { class: "selected-head", children: [_jsxs("h2", { children: ["Built: ", _jsx("span", { "data-part": "selected-name", children: elementName(picked.entry.tag, picked.entry.role) })] }), _jsxs("span", { class: "dim", children: [Math.round(picked.el.getBoundingClientRect().width), " \u00D7 ", Math.round(picked.el.getBoundingClientRect().height)] })] }), _jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-secondary", "data-action": "widen", disabled: !widerOf(picked.el), onClick: widen, title: "Select the element around this one (\u2191)", children: "\u2191 Wider" }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "narrow", disabled: !narrowerOf(picked.el), onClick: narrow, title: "Select the element inside this one (\u2193)", children: "\u2193 Narrower" }), _jsx("span", { class: "dim", children: "or \u2191 \u2193" })] }), picked.eligibility.status !== 'allowed' && _jsxs("p", { class: "error", "data-part": "notice", children: [picked.eligibility.reason, " Go wider or narrower."] }), busy ? _jsx(Loading, { text: busy }) : (_jsxs(_Fragment, { children: [_jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-primary", "data-action": "check-run", disabled: picked.eligibility.status !== 'allowed', onClick: () => void runCheck(), children: "Check against the design" }), _jsx("button", { type: "button", class: "btn-secondary", onClick: () => startPicking('component'), children: "Pick again" }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "check-design", onClick: openCheck, children: "Change design" })] }), _jsxs("p", { class: "tip-box", "data-part": "check-against", children: ["Design: ", checkDesign.label] })] }))] }) })), !settingsOpen && !picking && !basketOpen && picked && !checkDesign && !result && tool && (_jsx("div", { class: "panel", role: "dialog", "aria-label": "Capture", children: _jsxs("div", { class: "selected-card", children: [_jsxs("div", { class: "selected-head", children: [_jsxs("h2", { children: ["Selected \u00B7 ", _jsx("span", { "data-part": "selected-name", children: elementName(picked.entry.tag, picked.entry.role) })] }), _jsxs("span", { class: "dim", children: [Math.round(picked.el.getBoundingClientRect().width), " \u00D7 ", Math.round(picked.el.getBoundingClientRect().height)] })] }), _jsxs("div", { class: "row", children: [_jsx("button", { type: "button", class: "btn-secondary", "data-action": "widen", disabled: !widerOf(picked.el), onClick: widen, title: "Select the element around this one (\u2191)", children: "\u2191 Wider" }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "narrow", disabled: !narrowerOf(picked.el), onClick: narrow, title: "Select the element inside this one (\u2193)", children: "\u2193 Narrower" }), _jsx("span", { class: "dim", children: "or \u2191 \u2193" })] }), picked.eligibility.status === 'redirected' && _jsx("p", { class: "hint", children: picked.eligibility.reason }), picked.eligibility.status === 'blocked' && _jsxs("p", { class: "error", "data-part": "notice", children: [picked.eligibility.reason, " Go wider or narrower."] }), tool === 'spacing' && picked.eligibility.status === 'allowed' && spacingChoices(picked.entry).length > 1 && (_jsxs("div", { class: "row", children: [_jsxs("button", { type: "button", class: "btn-secondary", "aria-pressed": choice === ALL_SPACING, "data-choice": "all", onClick: () => setChoice(ALL_SPACING), children: ["All (", spacingChoices(picked.entry).length, ")"] }), spacingChoices(picked.entry).map((u, i) => (_jsxs("button", { type: "button", class: "btn-secondary", "aria-pressed": choice === i, "data-choice": u.property, onClick: () => setChoice(i), children: [u.property, " ", u.computed] })))] })), busy ? _jsx(Loading, { text: busy }) : (_jsxs(_Fragment, { children: [_jsxs("div", { class: "row", children: [picked.eligibility.status === 'allowed' && (_jsx("button", { type: "button", class: "btn-primary", "data-output": "one", onClick: () => void produce(false), children: "This one" })), picked.eligibility.status !== 'blocked' && (_jsx("button", { type: "button", class: picked.eligibility.status === 'allowed' ? 'btn-secondary' : 'btn-primary', "data-output": "system", onClick: () => void produce(true), children: "The whole system" })), tool === 'component' && picked.eligibility.status === 'allowed' && (_jsx("button", { type: "button", class: "btn-secondary", "data-output": "section", title: SECTION_HINT, onClick: () => void produce(false, true), children: "This section" })), _jsx("button", { type: "button", class: "btn-secondary", onClick: () => startPicking(tool), children: "Pick again" })] }), picked.eligibility.status !== 'blocked' && (_jsxs("p", { class: "tip-box", "data-part": "output-hints", children: [picked.eligibility.status === 'allowed' && _jsxs(_Fragment, { children: ["This one: ", OUTPUT_HINTS[tool].one, ". "] }), "The whole system: ", OUTPUT_HINTS[tool].system, ".", tool === 'component' && picked.eligibility.status === 'allowed' && _jsxs(_Fragment, { children: [" This section: ", SECTION_HINT, "."] })] }))] }))] }) })), !settingsOpen && !picking && !basketOpen && result && (_jsx("div", { class: result.ok ? 'panel result-panel' : 'panel', role: "dialog", "aria-label": "Capture file", children: result.ok ? (_jsxs(_Fragment, { children: [_jsxs("div", { class: "panel-body", children: [_jsxs("div", { class: "file-row", children: [_jsx("div", { class: "file", "data-part": "file-name", children: outputName }), _jsx("span", { class: "scope-pill badge", children: result.output.capture.meta.scope })] }), sectionFiles.length > 0 && (_jsxs("div", { class: "stack", "data-part": "section-files", children: [_jsxs("span", { class: "dim", children: ["Plus ", sectionFiles.length, " component file", sectionFiles.length === 1 ? '' : 's', ", each described once. The section file places them."] }), _jsx("ul", { class: "files", children: sectionFiles.map(f => (_jsxs("li", { "data-file": f.fileName, children: [_jsx("code", { children: f.fileName }), " ", _jsx("button", { type: "button", class: "btn-secondary", "data-file-view": true, onClick: () => setViewFile(f), children: "View" })] }))) })] })), viewFile && (_jsxs("div", { class: "stack", "data-part": "file-view-box", children: [_jsxs("span", { class: "row", children: [_jsx("code", { children: viewFile.fileName }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "file-view-close", onClick: () => setViewFile(null), children: "Back to the section file" })] }), _jsx("pre", { class: "preview", "data-part": "file-view", children: viewFile.markdown })] })), _jsxs("div", { class: "settings-grid", children: [_jsxs("label", { class: "field-stack", title: "Smart uses rem for text and spacing, preserves authored %/vw/vh for layouts, and keeps borders and radii in px", children: [_jsx("span", { class: "field-label", children: "Units" }), _jsxs(Select, { "data-setting": "units", value: settings.units ?? 'smart', onChange: e => changeSettings({ ...settings, units: e.currentTarget.value }), children: [_jsx("option", { value: "smart", children: "Smart (rem / % / px)" }), _jsx("option", { value: "px", children: "px" }), _jsx("option", { value: "rem", children: "rem" }), _jsx("option", { value: "both", children: "both" })] })] }), _jsxs("label", { class: "field-stack", children: [_jsx("span", { class: "field-label", children: "Colours" }), _jsxs(Select, { "data-setting": "colors", value: settings.colors ?? 'hex', onChange: e => changeSettings({ ...settings, colors: e.currentTarget.value }), children: [_jsx("option", { value: "hex", children: "hex" }), _jsx("option", { value: "rgb", children: "rgb" }), _jsx("option", { value: "hsl", children: "hsl" }), _jsx("option", { value: "oklch", children: "oklch" })] })] }), _jsxs("label", { class: "field-stack", title: "The file's source line: the page address, or only the site name", children: [_jsx("span", { class: "field-label", children: "Source" }), _jsxs(Select, { "data-setting": "source", value: settings.source ?? 'page', onChange: e => changeSettings({ ...settings, source: e.currentTarget.value }), children: [_jsx("option", { value: "page", children: "page address" }), _jsx("option", { value: "site", children: "site name only" })] })] }), _jsxs("label", { class: "field-stack", title: "The file you copy and download: DESIGN.md for Google Stitch, Luci's tables, Tailwind CSS, or CSS Variables", children: [_jsx("span", { class: "field-label", children: "File" }), _jsxs(Select, { "data-setting": "style", value: settings.style ?? 'stitch', onChange: e => changeSettings({ ...settings, style: e.currentTarget.value }), children: [_jsx("option", { value: "stitch", children: "DESIGN.md (Stitch)" }), _jsx("option", { value: "luci", children: "Luci tables" }), _jsx("option", { value: "tailwind", children: "Tailwind v4 (@theme)" }), _jsx("option", { value: "tailwind-v3", children: "Tailwind v3 (config.js)" }), _jsx("option", { value: "css-vars", children: "CSS Variables (tokens.css)" })] })] })] }), isCustomExport && props.saveToProject && _jsx("p", { class: "dim", "data-part": "stitch-note", children: "Save to project keeps Luci's tables: the design check and your agent's tools read them." }), stateNote && _jsx("p", { class: "hint", "data-part": "state-note", children: stateNote }), componentCtx && result.output.capture.meta.scope === 'component' && (_jsxs("div", { class: "stack", "data-part": "manual-state", children: [_jsx("hr", { class: "settings-divider" }), _jsxs("div", { class: "stack", "data-part": "states-summary", children: [_jsx("span", { class: "field-label", children: "States in this file" }), _jsxs("div", { class: "states-list", children: [_jsx("span", { class: "state default detected", "data-state": "default", title: "Resting state", children: "Default \u2713" }), componentCtx.states.map(s => (_jsxs("span", { class: s.detected ? 'state detected' : 'state missing', "data-state": s.state, title: s.detected ? (s.trigger ? `In the file. Set by the ${s.trigger.element} around it.` : 'In the file.')
|
|
1475
1635
|
: checked(s) ? 'Checked in the browser. Nothing changes.'
|
|
1476
1636
|
: 'Not detected. It may change through JavaScript. Capture it by hand below.', children: [s.state, " ", s.detected ? `✓${s.trigger ? ` (via ${s.trigger.element.split(' ')[0]})` : ''}` : checked(s) ? '– no change' : '– not detected'] })))] })] }), _jsx("hr", { class: "settings-divider" }), countdown !== null && capturing ? (_jsxs("div", { class: "row", children: [_jsxs("p", { class: "hint", "data-part": "countdown", children: [capturing.total > 1 ? `${capturing.index} of ${capturing.total}: ` : '', "Put it in its ", _jsx("strong", { children: capturing.state }), " state now (", STATE_HOW[capturing.state], "). Capturing in ", countdown, "\u2026"] }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "cancel-capture", onClick: cancelCapture, children: "Stop" })] })) : (_jsxs("div", { class: "manual-row", children: [_jsxs("div", { class: "section-copy", children: [_jsx("label", { class: "field-label", for: "luci-manual-state", children: "Capture by hand" }), _jsx("span", { class: "dim", children: "Set hover, focus or active yourself. 3 second countdown." })] }), _jsxs("div", { class: "manual-actions", children: [_jsxs(Select, { id: "luci-manual-state", "data-setting": "manual-state", value: manualTarget, onChange: e => setManualTarget(e.currentTarget.value), children: [missingStates(componentCtx.states).length > 0 && _jsxs("option", { value: ALL_MISSING, children: ["All missing states (", missingStates(componentCtx.states).length, ")"] }), STATE_ORDER.filter(s => s !== 'disabled').map(s => _jsx("option", { value: s, children: s }))] }), _jsx("button", { type: "button", class: "btn-secondary", "data-action": "capture-state", onClick: captureCurrentState, children: manualTarget === ALL_MISSING ? 'Capture' : 'Capture state' })] })] }))] })), picked && (result.output.capture.meta.scope === 'component' || result.output.capture.meta.scope === 'section') && result.output.capture.meta.selector === picked.entry.selector && (_jsxs("div", { class: "stack", "data-part": "responsive", children: [_jsx("hr", { class: "settings-divider" }), widthBusy ? _jsx(Loading, { text: widthBusy }) : (_jsxs("div", { class: "manual-row", children: [_jsxs("div", { class: "section-copy", children: [_jsx("span", { class: "field-label", children: "Breakpoints" }), !widthNote && _jsx("span", { class: "dim", children: responsiveRef.current ? 'In the file, under Responsive.' : 'The site\'s own breakpoints. 2 or 3 widths.' })] }), _jsx("div", { class: "manual-actions", children: _jsx("button", { type: "button", class: "btn-secondary", "data-action": "responsive", title: "Read it at the widths where the site's media queries change it, and add the changes to the file", onClick: () => void addResponsive(), children: responsiveRef.current ? 'Read the widths again' : 'How it changes by width' }) })] })), widthNote && _jsx("p", { class: widthNote.error ? 'error' : 'hint', "data-part": "responsive-note", children: widthNote.text })] })), _jsx("hr", { class: "settings-divider" }), _jsx(RemapSection, { source: myTokens, edited: edited !== null, applied: remapped && remapped.fileName === result.output.fileName ? remapped.summary : null, onApply: tokens => {
|
|
1477
|
-
const next = remapOutput(result.output, tokens,
|
|
1637
|
+
const next = remapOutput(result.output, tokens, pageSettings.rootFontSize);
|
|
1478
1638
|
setRemapped({ fileName: result.output.fileName, original: result.output, summary: next.summary });
|
|
1479
1639
|
setResult({ ok: true, output: next.output });
|
|
1480
1640
|
setCopied(false);
|
|
@@ -1488,13 +1648,22 @@ export function Toolbar(props) {
|
|
|
1488
1648
|
: _jsx(Button, { variant: "secondary", size: "md", iconOnly: true, tipAbove: true, icon: IconDownload, "data-action": "download", onClick: download, label: COPY.capture.actions.download }), _jsx(Button, { variant: "secondary", size: "md", iconOnly: true, tipAbove: true, icon: added ? IconSuccess : IconBasket, "data-action": "add-to-basket", label: added ? COPY.capture.actions.inBasket : COPY.capture.actions.addToBasket, onClick: () => { if (added)
|
|
1489
1649
|
openBasket();
|
|
1490
1650
|
else
|
|
1491
|
-
void addCurrent(); } }), tool && _jsx(Button, { variant: "secondary", size: "md", iconOnly: true, tipAbove: true, icon: TOOL_ICONS[tool], "data-action": "pick-again", label: COPY.capture.actions.pickAgain, onClick: () => startPicking(tool) }),
|
|
1651
|
+
void addCurrent(); } }), tool && _jsx(Button, { variant: "secondary", size: "md", iconOnly: true, tipAbove: true, icon: TOOL_ICONS[tool], "data-action": "pick-again", label: COPY.capture.actions.pickAgain, onClick: () => startPicking(tool) })] }), output && (props.saveToProject || (props.makeRule && output.capture.meta.scope === 'component')) && (_createElement(ProjectActions, { ...(props.saveToProject ? { save: saveAll } : {}), ...(unsaveAll ? { unsave: unsaveAll } : {}), ...(props.makeRule && output.capture.meta.scope === 'component'
|
|
1652
|
+
? { makeRule: () => props.makeRule(output.fileName, luciMarkdown) }
|
|
1653
|
+
: {}), ...(props.onViewOnSpec && output.capture.meta.scope === 'component'
|
|
1654
|
+
? { onViewOnSpec: () => props.onViewOnSpec(output.capture.meta.selector) }
|
|
1655
|
+
: {}), currentSnapshot: luciMarkdown, onDownload: sectionFiles.length ? downloadZip : download, projectName: activeProject?.name, key: output.fileName }))] })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { class: "greet", children: [_jsx(Mascot, { pose: "annoyed", size: 96 }), _jsx("p", { class: "error", "data-part": "error", children: result.message })] }), tool && _jsx("div", { class: "row", children: _jsx(Button, { variant: "secondary", icon: TOOL_ICONS[tool], "data-action": "pick-again", onClick: () => startPicking(tool), children: COPY.capture.actions.pickAgain }) })] })) }))] }), picking && tool && (_jsx("div", { class: "pick-layer", "data-part": "pick-layer", onPointerMove: e => { if (e.pointerType !== 'touch')
|
|
1492
1656
|
pickMove(e.clientX, e.clientY); }, onPointerDown: e => { e.preventDefault(); e.currentTarget.setPointerCapture?.(e.pointerId); pickDown(e.clientX, e.clientY); }, onPointerUp: e => { e.preventDefault(); pickUp(e.clientX, e.clientY, e.pointerType === 'touch'); }, onPointerCancel: () => { drag.current = null; }, onWheel: e => pickWheel(e), onContextMenu: e => e.preventDefault() })), pixelMode && (_jsxs(_Fragment, { children: [_jsx("div", { class: "pixel-layer", "data-part": "pixel-layer", onPointerMove: e => setPixelHover(samplePixel(e.clientX, e.clientY)), onPointerLeave: () => setPixelHover(null), onClick: e => pickPixelAt(e.clientX, e.clientY) }), pixelHover && shot.current && (() => {
|
|
1493
1657
|
// The loupe and the hex sit below and right of the pointer, or flip to stay in the window
|
|
1494
1658
|
const left = pixelHover.x + 20 + LOUPE_PX > win.innerWidth ? pixelHover.x - 20 - LOUPE_PX : pixelHover.x + 20;
|
|
1495
1659
|
const top = pixelHover.y + 20 + LOUPE_PX + 36 > win.innerHeight ? pixelHover.y - 20 - LOUPE_PX - 36 : pixelHover.y + 20;
|
|
1496
1660
|
return (_jsxs(_Fragment, { children: [_jsx(Loupe, { shot: shot.current, x: pixelHover.x, y: pixelHover.y, hex: pixelHover.hex, left: left, top: top }), _jsxs("div", { class: "swatch", "data-part": "pixel-swatch", style: { top: `${top + LOUPE_PX + 8}px`, left: `${left + LOUPE_PX / 2 - 52}px` }, children: [_jsx("span", { class: "chip", style: { background: pixelHover.hex } }), pixelHover.hex] })] }));
|
|
1497
|
-
})()] })),
|
|
1661
|
+
})()] })), checkOutcome && picked && _jsx(DiffOverlay, { overlay: diffOverlay, el: picked.el }), checkBlink && checkBlink.el.isConnected && (() => {
|
|
1662
|
+
const r = checkBlink.el.getBoundingClientRect();
|
|
1663
|
+
if (!r.width && !r.height)
|
|
1664
|
+
return null;
|
|
1665
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { class: "blink-ring", "data-part": "blink-ring", style: { left: `${r.left - 3}px`, top: `${r.top - 3}px`, width: `${r.width + 6}px`, height: `${r.height + 6}px` } }, `check-blink-${checkBlink.key}`), _jsxs("div", { class: "blink-pill", role: "status", "data-part": "blink-pill", style: { left: `${Math.max(8, Math.min(r.left, win.innerWidth - 220))}px`, top: `${Math.max(8, r.top - 28)}px` }, children: [_jsx("span", { class: "blink-pill-dot", "aria-hidden": "true" }), checkBlink.label] })] }));
|
|
1666
|
+
})(), choosing && picked && !pixelMode && (() => {
|
|
1498
1667
|
const r = picked.el.getBoundingClientRect();
|
|
1499
1668
|
return (_jsxs(_Fragment, { children: [_jsx("div", { class: `highlight locked${picked.eligibility.status === 'blocked' ? ' blocked' : ''}`, "data-part": "selection", style: { top: `${r.top}px`, left: `${r.left}px`, width: `${r.width}px`, height: `${r.height}px` } }), _jsx("div", { class: "label", style: { top: `${Math.max(4, r.top - 28)}px`, left: `${Math.max(4, r.left)}px` }, children: hoverLabel(picked.el) })] }));
|
|
1500
1669
|
})(), hovered && rect && (_jsxs(_Fragment, { children: [_jsx("div", { class: `highlight${hoverElig?.status === 'blocked' ? ' blocked' : ''}`, style: { top: `${rect.top}px`, left: `${rect.left}px`, width: `${rect.width}px`, height: `${rect.height}px` } }), cs && (_jsxs(_Fragment, { children: [_jsx("div", { class: "pad", style: { top: `${rect.top + px(cs.borderTopWidth)}px`, left: `${rect.left + px(cs.borderLeftWidth)}px`, width: `${rect.width - px(cs.borderLeftWidth) - px(cs.borderRightWidth)}px`, height: `${rect.height - px(cs.borderTopWidth) - px(cs.borderBottomWidth)}px`, borderWidth: `${cs.paddingTop} ${cs.paddingRight} ${cs.paddingBottom} ${cs.paddingLeft}` } }), _jsx("div", { class: "margin", style: { top: `${rect.top - px(cs.marginTop)}px`, left: `${rect.left - px(cs.marginLeft)}px`, width: `${rect.width + px(cs.marginLeft) + px(cs.marginRight)}px`, height: `${rect.height + px(cs.marginTop) + px(cs.marginBottom)}px`, borderWidth: `${cs.marginTop} ${cs.marginRight} ${cs.marginBottom} ${cs.marginLeft}` } })] })), _jsxs("div", { class: "label", "data-part": "hover-label", style: { top: `${Math.max(4, rect.top - 28)}px`, left: `${Math.max(4, rect.left)}px` }, children: [hoverLabel(hovered), cs && `\npadding ${cs.padding} margin ${cs.margin}${/flex|grid/.test(cs.display) ? ` gap ${cs.rowGap} ${cs.columnGap}` : ''}`, hoverElig && hoverElig.status !== 'allowed' && _jsx("span", { class: "reason", children: hoverElig.reason })] })] }))] }));
|