@luci-dev/capture 0.5.5 → 0.5.6
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 +13 -0
- package/dist/luci-capture.js +90 -20
- package/dist/ui/picker.d.ts +5 -0
- package/dist/ui/picker.d.ts.map +1 -1
- package/dist/ui/picker.js +12 -0
- package/dist/ui/picker.js.map +1 -1
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/dist/ui/styles.js +50 -12
- package/dist/ui/styles.js.map +1 -1
- package/dist/ui/toolbar.d.ts.map +1 -1
- package/dist/ui/toolbar.js +12 -5
- package/dist/ui/toolbar.js.map +1 -1
- package/package.json +3 -3
- package/dist/ui/screenshot.d.ts +0 -39
- package/dist/ui/screenshot.d.ts.map +0 -1
- package/dist/ui/screenshot.js +0 -59
- package/dist/ui/screenshot.js.map +0 -1
package/dist/ui/toolbar.js
CHANGED
|
@@ -11,7 +11,7 @@ import { addToBasket, exportBasket, exportItem, mergeInBasket, noteInBasket, rem
|
|
|
11
11
|
import { manualState } from '../states.js';
|
|
12
12
|
import { elementName } from '../naming.js';
|
|
13
13
|
import { LUCI_UI_ATTRIBUTE } from '../dom.js';
|
|
14
|
-
import { elementAt, eligibilityOf, eventTarget, firstChildOf, hoverLabel, parentOf, scrollableAncestor } from './picker.js';
|
|
14
|
+
import { elementAt, eligibilityOf, eventTarget, firstChildOf, hoverLabel, parentOf, scrollableAncestor, touchScreen } from './picker.js';
|
|
15
15
|
import { ButtonSpinner, Loading, nextPaint } from './loading.js';
|
|
16
16
|
import { ModeSwitch } from './modeSwitch.js';
|
|
17
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';
|
|
@@ -729,7 +729,7 @@ export function Toolbar(props) {
|
|
|
729
729
|
area.scrollBy(e.deltaX, e.deltaY);
|
|
730
730
|
}
|
|
731
731
|
};
|
|
732
|
-
const pickUp = (x, y) => {
|
|
732
|
+
const pickUp = (x, y, touch = false) => {
|
|
733
733
|
{
|
|
734
734
|
const target = elementAt(doc, x, y);
|
|
735
735
|
const start = drag.current;
|
|
@@ -737,6 +737,12 @@ export function Toolbar(props) {
|
|
|
737
737
|
if (!target || !start || !tool)
|
|
738
738
|
return;
|
|
739
739
|
const moved = Math.hypot(x - start.x, y - start.y) > DRAG_PX;
|
|
740
|
+
// By touch (no hover), a first tap shows what would be taken; a second tap on it takes it
|
|
741
|
+
if (touch && !moved && target !== candidateRef.current) {
|
|
742
|
+
trail.current = [];
|
|
743
|
+
aim(target);
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
740
746
|
if (tool === 'spacing' && moved && target !== start.el) {
|
|
741
747
|
// A drag between two elements measures the distance between them (FR15)
|
|
742
748
|
const blocked = [start.el, target].map(eligibilityOf).find(x => x.status !== 'allowed');
|
|
@@ -1430,7 +1436,7 @@ export function Toolbar(props) {
|
|
|
1430
1436
|
const hoverElig = hovered ? eligibilityOf(hovered) : null;
|
|
1431
1437
|
const rect = hovered?.getBoundingClientRect();
|
|
1432
1438
|
const cs = hovered && tool === 'spacing' ? win.getComputedStyle(hovered) : null;
|
|
1433
|
-
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": props.modes ? 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], 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, 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, 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}`, onClick: toggleBasket, children: [_jsx(Icon, { icon: IconBasket }), COPY.capture.basket(basket.length)] }), _jsx(Button, { iconOnly: true, size: "lg", class: "tool", icon: IconClose, label: COPY.common.close, "data-action": "close", onClick: props.onClose })] }), 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 })] })] })), props.modes && idle && !greeting && (_jsxs("div", { class: "sub with-luci", role: "note", "data-part": "intro", children: [_jsx(Mascot, { pose: "peek", 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 && (props.modes ? (_jsx(DevSettingsPanel, { currentMode: "capture", uiPrefs: uiPrefs, onUiPrefsChange: setUiPrefs, projectInfo: props.projectInfo, store: props.store, captureSettings: settings, onCaptureSettingsChange: changeSettings, debuggerPermission: props.debuggerPermission })) : (_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: props.modes ? COPY.capture.devTitle : COPY.capture.title }), _jsx("span", { class: "brand-sub", "data-part": "brand-sub", children: props.modes ? COPY.capture.devByline : COPY.capture.byline })] }), _jsx("p", { class: "brand-desc", children: props.modes ? 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, {})] }), !props.modes && (_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
|
|
1439
|
+
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": props.modes ? 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], 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, 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, 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}`, 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 })] }), 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 })] })] })), props.modes && idle && !greeting && (_jsxs("div", { class: "sub with-luci", role: "note", "data-part": "intro", children: [_jsx(Mascot, { pose: "peek", 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 && (props.modes ? (_jsx(DevSettingsPanel, { currentMode: "capture", uiPrefs: uiPrefs, onUiPrefsChange: setUiPrefs, projectInfo: props.projectInfo, store: props.store, captureSettings: settings, onCaptureSettingsChange: changeSettings, debuggerPermission: props.debuggerPermission })) : (_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: props.modes ? COPY.capture.devTitle : COPY.capture.title }), _jsx("span", { class: "brand-sub", "data-part": "brand-sub", children: props.modes ? COPY.capture.devByline : COPY.capture.byline })] }), _jsx("p", { class: "brand-desc", children: props.modes ? 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, {})] }), !props.modes && (_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
|
|
1434
1440
|
? _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 })
|
|
1435
1441
|
: 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 ? 'online' : 'offline'}`, "aria-hidden": "true" }), _jsxs("div", { class: "project-info", children: [_jsx("span", { class: "project-name", children: activeProject?.name ? `Connected to ${activeProject.name}` : 'Not connected to a project' }), activeProject?.project && _jsx("span", { class: "project-path dim", title: activeProject.project, children: activeProject.project }), !activeProject?.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 => {
|
|
1436
1442
|
const val = e.currentTarget.value;
|
|
@@ -1463,7 +1469,7 @@ export function Toolbar(props) {
|
|
|
1463
1469
|
: pixelMode ? 'Point at any spot. Click to take its colour.'
|
|
1464
1470
|
: checkDesign ? `Click the component you built. Luci checks it against ${checkDesign.label}.`
|
|
1465
1471
|
: `${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)
|
|
1466
|
-
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' : '↑ ↓ 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)
|
|
1472
|
+
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)
|
|
1467
1473
|
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.')
|
|
1468
1474
|
: checked(s) ? 'Checked in the browser. Nothing changes.'
|
|
1469
1475
|
: '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 => {
|
|
@@ -1481,7 +1487,8 @@ export function Toolbar(props) {
|
|
|
1481
1487
|
: _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)
|
|
1482
1488
|
openBasket();
|
|
1483
1489
|
else
|
|
1484
|
-
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) }), props.saveToProject && output && _jsx(SaveButton, { save: saveAll, projectName: activeProject?.name }, output.fileName), props.makeRule && output && output.capture.meta.scope === 'component' && (_jsx(RuleButton, { make: () => props.makeRule(output.fileName, markdown) }, `rule ${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 =>
|
|
1490
|
+
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) }), props.saveToProject && output && _jsx(SaveButton, { save: saveAll, projectName: activeProject?.name }, output.fileName), props.makeRule && output && output.capture.meta.scope === 'component' && (_jsx(RuleButton, { make: () => props.makeRule(output.fileName, markdown) }, `rule ${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')
|
|
1491
|
+
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 && (() => {
|
|
1485
1492
|
// The loupe and the hex sit below and right of the pointer, or flip to stay in the window
|
|
1486
1493
|
const left = pixelHover.x + 20 + LOUPE_PX > win.innerWidth ? pixelHover.x - 20 - LOUPE_PX : pixelHover.x + 20;
|
|
1487
1494
|
const top = pixelHover.y + 20 + LOUPE_PX + 36 > win.innerHeight ? pixelHover.y - 20 - LOUPE_PX - 36 : pixelHover.y + 20;
|