liteagents 2.6.1 → 2.8.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/CHANGELOG.md +46 -0
- package/README.md +4 -2
- package/installer/cli.js +4 -1
- package/package.json +1 -1
- package/packages/ampcode/commands/live-canvas/README.md +38 -47
- package/packages/{claude/skills/live-canvas/templates/demo → ampcode/commands/live-canvas/dev}/post-variants.html +8 -3
- package/packages/ampcode/commands/live-canvas/templates/lab-banner.html +6 -0
- package/packages/ampcode/commands/live-canvas/templates/overlay-vanilla.js +64 -6
- package/packages/ampcode/commands/live-canvas.md +140 -161
- package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/.claude-plugin/plugin.json +1 -1
- package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/README.md +2 -2
- package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/package.json +1 -1
- package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/schema.json +1 -1
- package/packages/claude/plugins/live-canvas-marketplace/plugins/live-canvas-channel/server.js +320 -27
- package/packages/claude/plugins/live-canvas-marketplace/setup.sh +83 -24
- package/packages/claude/skills/live-canvas/README.md +53 -57
- package/packages/claude/skills/live-canvas/SKILL.md +122 -158
- package/packages/{ampcode/commands/live-canvas/templates/demo → claude/skills/live-canvas/dev}/post-variants.html +8 -3
- package/packages/claude/skills/live-canvas/templates/lab-banner.html +6 -0
- package/packages/claude/skills/live-canvas/templates/overlay-vanilla.js +64 -6
- package/packages/droid/commands/live-canvas/README.md +38 -47
- package/packages/droid/commands/live-canvas/{templates/demo → dev}/post-variants.html +8 -3
- package/packages/droid/commands/live-canvas/templates/lab-banner.html +6 -0
- package/packages/droid/commands/live-canvas/templates/overlay-vanilla.js +64 -6
- package/packages/droid/commands/live-canvas.md +140 -161
- package/packages/opencode/command/live-canvas/README.md +38 -47
- package/packages/opencode/command/live-canvas/{templates/demo → dev}/post-variants.html +8 -3
- package/packages/opencode/command/live-canvas/templates/lab-banner.html +6 -0
- package/packages/opencode/command/live-canvas/templates/overlay-vanilla.js +64 -6
- package/packages/opencode/command/live-canvas.md +140 -161
- package/packages/ampcode/commands/live-canvas/templates/.claude/settings.local.json +0 -8
- package/packages/ampcode/commands/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
- package/packages/ampcode/commands/live-canvas/templates/feedback-react/format-utils.ts +0 -283
- package/packages/ampcode/commands/live-canvas/templates/feedback-react/index.ts +0 -62
- package/packages/ampcode/commands/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
- package/packages/ampcode/commands/live-canvas/templates/feedback-react/types.ts +0 -118
- package/packages/claude/skills/live-canvas/INTEGRATION_NOTES.md +0 -210
- package/packages/claude/skills/live-canvas/templates/.claude/settings.local.json +0 -8
- package/packages/claude/skills/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
- package/packages/claude/skills/live-canvas/templates/feedback-react/format-utils.ts +0 -283
- package/packages/claude/skills/live-canvas/templates/feedback-react/index.ts +0 -62
- package/packages/claude/skills/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
- package/packages/claude/skills/live-canvas/templates/feedback-react/types.ts +0 -118
- package/packages/droid/commands/live-canvas/templates/.claude/settings.local.json +0 -8
- package/packages/droid/commands/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
- package/packages/droid/commands/live-canvas/templates/feedback-react/format-utils.ts +0 -283
- package/packages/droid/commands/live-canvas/templates/feedback-react/index.ts +0 -62
- package/packages/droid/commands/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
- package/packages/droid/commands/live-canvas/templates/feedback-react/types.ts +0 -118
- package/packages/opencode/command/live-canvas/templates/.claude/settings.local.json +0 -8
- package/packages/opencode/command/live-canvas/templates/feedback-react/FeedbackOverlay.tsx +0 -1299
- package/packages/opencode/command/live-canvas/templates/feedback-react/format-utils.ts +0 -283
- package/packages/opencode/command/live-canvas/templates/feedback-react/index.ts +0 -62
- package/packages/opencode/command/live-canvas/templates/feedback-react/selector-utils.ts +0 -423
- package/packages/opencode/command/live-canvas/templates/feedback-react/types.ts +0 -118
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Click-to-annotate UI design tool for Claude Code. Renders N variants of a component or page in your browser, you click an element and type what to change, and Claude edits the variant file while you watch in the browser. No window switching, no pasted JSON.
|
|
4
4
|
|
|
5
|
-
Ships as a Claude Code skill plus an MCP channel plugin. Works in every tool liteagents supports (Claude, Droid, Amp, Opencode), but **Live mode only works in Claude Code** — other tools run in
|
|
5
|
+
Ships as a Claude Code skill plus an MCP channel plugin. Works in every tool liteagents supports (Claude, Droid, Amp, Opencode), but **Live mode only works in Claude Code** — other tools run in JSON mode only (see modes below).
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Ships as a Claude Code skill plus an MCP channel plugin. Works in every tool lit
|
|
|
11
11
|
```
|
|
12
12
|
┌──────────────────────┐ POST /feedback ┌─────────────────────┐
|
|
13
13
|
│ Overlay in browser │ ─────────────────────────► │ live-canvas-channel │
|
|
14
|
-
│ (vanilla JS
|
|
14
|
+
│ (vanilla JS, ~500 lines)│ │ (Node MCP server) │
|
|
15
15
|
└──────────────────────┘ └──────────┬──────────┘
|
|
16
16
|
▲ │
|
|
17
17
|
│ dev server hot-reloads the page │ notifications/
|
|
@@ -31,28 +31,31 @@ Each Save in the overlay streams into the Claude session as a `<channel>` tag wi
|
|
|
31
31
|
|
|
32
32
|
## Modes
|
|
33
33
|
|
|
34
|
-
The
|
|
34
|
+
The skill asks you which mode you want every time `/live-canvas` runs.
|
|
35
35
|
|
|
36
|
-
| Mode |
|
|
36
|
+
| Mode | Use when | What happens per Save |
|
|
37
37
|
|---|---|---|
|
|
38
|
-
| **Live** |
|
|
39
|
-
| **
|
|
38
|
+
| **Live** | You launched the session with `live-claude` and the channel is up | Comment streams into Claude's context; Claude edits the file; dev server hot-reloads. Toast: "Pushed to Claude ✨". |
|
|
39
|
+
| **JSON** | Any session, any tool (Claude, Droid, Amp, Opencode) | Comment stays local. On Finish/Submit it writes JSONL (or downloads the file if no endpoint). User pastes or says "check" in the CLI to have the assistant act on the whole batch. |
|
|
40
40
|
|
|
41
|
-
Live
|
|
41
|
+
If you pick Live but the channel doesn't answer, the skill stops and tells you to relaunch with `live-claude` (or fall back to JSON). It doesn't silently downgrade — the user always gets to choose.
|
|
42
42
|
|
|
43
43
|
---
|
|
44
44
|
|
|
45
45
|
## One-time setup (Live mode, Claude Code only)
|
|
46
46
|
|
|
47
|
-
Run this once per machine. Without it, the skill still works in
|
|
47
|
+
Run this once per machine. Without it, the skill still works in JSON mode.
|
|
48
48
|
|
|
49
|
-
### 1.
|
|
49
|
+
### 1. Run the installer
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
|
-
bash
|
|
52
|
+
bash packages/claude/plugins/live-canvas-marketplace/setup.sh
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
The installer:
|
|
56
|
+
- copies the marketplace into `~/.claude/plugins/live-canvas-marketplace/` (overwrites any prior install)
|
|
57
|
+
- runs `npm install` inside the channel plugin
|
|
58
|
+
- adds a `live-claude` shell function to `~/.zshrc` and `~/.bashrc` (idempotent — re-runs replace in place)
|
|
56
59
|
|
|
57
60
|
### 2. Register the marketplace in Claude Code
|
|
58
61
|
|
|
@@ -66,21 +69,9 @@ Checks Node >= 18, runs `npm install` inside the plugin dir. Idempotent.
|
|
|
66
69
|
/plugin install live-canvas-channel@live-canvas-marketplace
|
|
67
70
|
```
|
|
68
71
|
|
|
69
|
-
### 4.
|
|
72
|
+
### 4. Open a fresh shell
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
claude --dangerously-load-development-channels plugin:live-canvas-channel@live-canvas-marketplace
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Accept the safety prompt (custom channels are in research preview and not on the default allowlist).
|
|
76
|
-
|
|
77
|
-
**Save yourself typing** — add to `~/.bashrc` or `~/.zshrc`:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
alias claude-live='claude --dangerously-load-development-channels plugin:live-canvas-channel@live-canvas-marketplace'
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
From now on, `claude-live` to enable Live mode, plain `claude` for everything else.
|
|
74
|
+
`live-claude` is now available. Use plain `claude` for everything else; use `live-claude` when you want Live mode for this skill.
|
|
84
75
|
|
|
85
76
|
---
|
|
86
77
|
|
|
@@ -88,7 +79,7 @@ From now on, `claude-live` to enable Live mode, plain `claude` for everything el
|
|
|
88
79
|
|
|
89
80
|
### Start a session
|
|
90
81
|
|
|
91
|
-
Either `claude` (
|
|
82
|
+
Either `claude` (JSON only) or `live-claude` (Live available).
|
|
92
83
|
|
|
93
84
|
### Invoke the skill in a project
|
|
94
85
|
|
|
@@ -96,13 +87,13 @@ Either `claude` (Batch only) or `claude-live` (Live available).
|
|
|
96
87
|
/live-canvas
|
|
97
88
|
```
|
|
98
89
|
|
|
99
|
-
Phase 0 probes the channel
|
|
90
|
+
Phase 0 always asks which mode you want — Live channel or JSON file — then probes the channel if you picked Live:
|
|
100
91
|
|
|
101
|
-
|
|
|
102
|
-
|
|
103
|
-
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
92
|
+
| Choice | Channel up? | Skill behavior |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| Live | yes | Announces Live mode, starts the interview |
|
|
95
|
+
| Live | no | Tells you to relaunch with `live-claude` (or fall back to JSON) |
|
|
96
|
+
| JSON | n/a | Announces JSON mode, starts the interview |
|
|
106
97
|
|
|
107
98
|
### Interview & generation
|
|
108
99
|
|
|
@@ -113,13 +104,15 @@ Skill asks 5 short questions (scope, pain points, inspiration, persona, constrai
|
|
|
113
104
|
Open `http://localhost:<dev-port>/__live_canvas`. Click **Add Feedback** (bottom right), click any element in any variant, type a one-liner, Save.
|
|
114
105
|
|
|
115
106
|
- Live mode: toast says "Pushed to Claude ✨", Claude acknowledges and edits the file, dev server hot-reloads.
|
|
116
|
-
-
|
|
107
|
+
- JSON mode: toast says "Saved — submit when ready", pin stays on the element, counter in the Submit button ticks up.
|
|
108
|
+
|
|
109
|
+
Need the page back? The overlay has a "−" button next to **Add Feedback** that collapses everything to a small circle in the corner — tap to expand again. Useful on mobile where the bar can cover what's underneath.
|
|
117
110
|
|
|
118
111
|
Keep clicking until a winner emerges.
|
|
119
112
|
|
|
120
113
|
### Finish
|
|
121
114
|
|
|
122
|
-
Click the pink **Finish** (Live) or **Submit** (
|
|
115
|
+
Click the pink **Finish** (Live) or **Submit** (JSON) button:
|
|
123
116
|
|
|
124
117
|
1. Type the overall direction: e.g. *"Go with B's layout, A's button styling"*
|
|
125
118
|
2. Click Finish
|
|
@@ -142,12 +135,11 @@ packages/claude/
|
|
|
142
135
|
├── skills/live-canvas/
|
|
143
136
|
│ ├── SKILL.md # Skill instructions (phases, flow)
|
|
144
137
|
│ ├── DESIGN_PRINCIPLES.md # UX/a11y/motion reference
|
|
145
|
-
│ ├── INTEGRATION_NOTES.md # Design-time notes (channel paths explored)
|
|
146
138
|
│ ├── README.md # This file
|
|
139
|
+
│ ├── dev/post-variants.html # Standalone demo for local QA of the overlay
|
|
147
140
|
│ └── templates/
|
|
148
|
-
│ ├── overlay-vanilla.js # Framework-agnostic overlay (~
|
|
149
|
-
│
|
|
150
|
-
│ └── demo/post-variants.html # Standalone demo for testing the overlay
|
|
141
|
+
│ ├── overlay-vanilla.js # Framework-agnostic overlay (~500 lines)
|
|
142
|
+
│ └── lab-banner.html # "This is a temp lab" notice snippet
|
|
151
143
|
└── plugins/
|
|
152
144
|
└── live-canvas-marketplace/
|
|
153
145
|
├── .claude-plugin/marketplace.json
|
|
@@ -188,9 +180,9 @@ The skill checks the cache dir to tell first-time vs returning users apart.
|
|
|
188
180
|
<project-root>/
|
|
189
181
|
└── .claude-design/
|
|
190
182
|
├── lab/variants/VariantA.tsx … VariantE.tsx
|
|
191
|
-
├──
|
|
183
|
+
├── overlay-vanilla.js (copied into the project's public/static dir)
|
|
192
184
|
├── design-brief.json # Structured output from the interview
|
|
193
|
-
└── feedback.jsonl #
|
|
185
|
+
└── feedback.jsonl # JSON mode only; deleted on Finish
|
|
194
186
|
```
|
|
195
187
|
|
|
196
188
|
Plus a temporary route (e.g. `app/__live_canvas/page.tsx` for Next.js App Router). Everything under `.claude-design/` and the temporary route is deleted on Finish or Abort.
|
|
@@ -207,12 +199,11 @@ Plus a temporary route (e.g. `app/__live_canvas/page.tsx` for Next.js App Router
|
|
|
207
199
|
|
|
208
200
|
## The install pipeline, end to end
|
|
209
201
|
|
|
210
|
-
1. **Liteagents installer** copies
|
|
202
|
+
1. **Liteagents installer** copies the skill:
|
|
211
203
|
- `packages/claude/skills/live-canvas/` → `~/.claude/skills/live-canvas/`
|
|
212
|
-
|
|
213
|
-
2. **User, once:** runs `bash ~/.claude/plugins/live-canvas-marketplace/setup.sh` → installs the plugin's npm deps
|
|
204
|
+
2. **User, once:** runs `bash packages/claude/plugins/live-canvas-marketplace/setup.sh` → copies marketplace to `~/.claude/plugins/`, runs `npm install`, adds `live-claude` function to `~/.zshrc` and `~/.bashrc`
|
|
214
205
|
3. **User, once:** in a Claude session, runs `/plugin marketplace add ~/.claude/plugins/live-canvas-marketplace` + `/plugin install live-canvas-channel@live-canvas-marketplace`
|
|
215
|
-
4. **User, every session that wants Live mode:**
|
|
206
|
+
4. **User, every session that wants Live mode:** runs `live-claude` (function installed by step 2)
|
|
216
207
|
5. **User, whenever:** `/live-canvas` in any project
|
|
217
208
|
|
|
218
209
|
Steps 1, 2, 3 are truly one-time. Step 4 is per-session. Step 5 is per-project-use.
|
|
@@ -221,7 +212,7 @@ Steps 1, 2, 3 are truly one-time. Step 4 is per-session. Step 5 is per-project-u
|
|
|
221
212
|
|
|
222
213
|
## Troubleshooting
|
|
223
214
|
|
|
224
|
-
###
|
|
215
|
+
### Channel server starts but skill still routes to JSON
|
|
225
216
|
|
|
226
217
|
Port 8788 is stuck from an earlier session's server process. Kill it:
|
|
227
218
|
|
|
@@ -236,13 +227,13 @@ Then `/reload-plugins` in the new session.
|
|
|
236
227
|
|
|
237
228
|
Three common causes, in order of likelihood:
|
|
238
229
|
|
|
239
|
-
1. You didn't start this session with the dev flag. Close it, reopen with `claude
|
|
230
|
+
1. You didn't start this session with the dev flag. Close it, reopen with `live-claude`.
|
|
240
231
|
2. The plugin subprocess died on startup. In the session, run `/mcp` — look for `live-canvas` with its status. "Failed to connect" means a node/dep error: check `~/.claude/debug/<session-id>.txt` for the stderr.
|
|
241
232
|
3. You never ran step 2 of setup. Re-run `bash ~/.claude/plugins/live-canvas-marketplace/setup.sh`.
|
|
242
233
|
|
|
243
234
|
### Overlay loads in the browser but no pills appear
|
|
244
235
|
|
|
245
|
-
The overlay script didn't load. Most common cause: you started the Python server inside the wrong directory so the relative `../overlay-vanilla.js` path couldn't resolve. Start the server one level up and navigate with the `/
|
|
236
|
+
The overlay script didn't load. Most common cause: you started the Python server inside the wrong directory so the relative `../templates/overlay-vanilla.js` path couldn't resolve. Start the server one level up and navigate with the `/dev/` prefix.
|
|
246
237
|
|
|
247
238
|
### "Pushed to Claude ✨" toast appears but nothing happens in the terminal
|
|
248
239
|
|
|
@@ -79,6 +79,9 @@
|
|
|
79
79
|
<header>
|
|
80
80
|
<h1>Live Canvas — Post card demo</h1>
|
|
81
81
|
<p>5 variations of a social post (likes, retweets, comments). Click <b>Add Feedback</b> bottom-right → click any element → leave a comment. Right-click the pill to submit.</p>
|
|
82
|
+
<div style="background:#fef3c7;border:1px solid #fbbf24;border-radius:8px;padding:10px 14px;margin-top:12px;font-size:13px;color:#78350f;">
|
|
83
|
+
<b>This is an overlay-only demo.</b> Feedback events transit through the Live channel (or JSON file, with <code>?json=1</code>) so you can verify the UI works — but there are no <code>.claude-design/lab/variants/</code> files behind these cards, so the Claude session receiving events <em>cannot</em> edit anything. For the full lifecycle, run <code>/live-canvas</code> in a real project.
|
|
84
|
+
</div>
|
|
82
85
|
</header>
|
|
83
86
|
|
|
84
87
|
<main>
|
|
@@ -193,12 +196,14 @@
|
|
|
193
196
|
|
|
194
197
|
</main>
|
|
195
198
|
|
|
196
|
-
<!-- Overlay (
|
|
197
|
-
<script src="../overlay-vanilla.js"></script>
|
|
199
|
+
<!-- Overlay (served from sibling templates/ dir; works under any static server rooted at the skill dir) -->
|
|
200
|
+
<script src="../templates/overlay-vanilla.js"></script>
|
|
198
201
|
<script>
|
|
202
|
+
// ?json=1 forces JSON mode (skip channel probe); default tries Live first.
|
|
203
|
+
const forceJson = new URLSearchParams(location.search).has('json');
|
|
199
204
|
LiveCanvas.init({
|
|
200
205
|
target: 'PostCard',
|
|
201
|
-
channelUrl: 'http://localhost:8788',
|
|
206
|
+
...(forceJson ? {} : { channelUrl: 'http://localhost:8788' }),
|
|
202
207
|
});
|
|
203
208
|
</script>
|
|
204
209
|
</body>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<div role="note" style="background:#fefce8;border:1px solid #facc15;border-radius:8px;padding:10px 14px;margin:12px 0;font-size:13px;line-height:1.5;color:#854d0e;">
|
|
2
|
+
<b>This is a temporary design lab.</b> Click any element → leave a comment → Save.
|
|
3
|
+
Your feedback goes to Claude; the lab is deleted on Finish. The overlay
|
|
4
|
+
badge (bottom-right) tells you whether feedback is streaming live or being
|
|
5
|
+
collected as JSON.
|
|
6
|
+
</div>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* Batch — saves accumulate locally; Submit All POSTs JSONL to batchEndpoint
|
|
24
24
|
* (or downloads the file if no endpoint configured)
|
|
25
25
|
*
|
|
26
|
-
* Payload schema: v1.0
|
|
26
|
+
* Payload schema: v1.0 (see live-canvas-channel/schema.json).
|
|
27
27
|
*/
|
|
28
28
|
(function () {
|
|
29
29
|
'use strict';
|
|
@@ -38,11 +38,16 @@
|
|
|
38
38
|
batchEndpoint: null,
|
|
39
39
|
active: false,
|
|
40
40
|
picking: false,
|
|
41
|
+
minimized: false, // collapsed to a single bubble?
|
|
41
42
|
comments: [], // Comment[] — only items pending batch submit
|
|
42
43
|
overall: '',
|
|
43
44
|
pinCounts: Object.create(null), // `${variant}|${selector}` → placed-pin count
|
|
44
45
|
};
|
|
45
46
|
|
|
47
|
+
// Persist collapse state across hot reloads / variant switches.
|
|
48
|
+
const MIN_KEY = 'lc-minimized';
|
|
49
|
+
try { state.minimized = sessionStorage.getItem(MIN_KEY) === '1'; } catch (_) {}
|
|
50
|
+
|
|
46
51
|
// ---------- utilities ----------
|
|
47
52
|
|
|
48
53
|
const uid = () => `c-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
@@ -134,7 +139,8 @@
|
|
|
134
139
|
const css = `
|
|
135
140
|
[${DATA_OVERLAY}] { font-family: system-ui, sans-serif; box-sizing: border-box; }
|
|
136
141
|
.${PFX}-bar { position: fixed; right: 16px; bottom: 16px; z-index: 2147483646;
|
|
137
|
-
display: flex; gap: 8px; }
|
|
142
|
+
display: flex; gap: 8px; align-items: center; }
|
|
143
|
+
.${PFX}-bar[data-hidden='1'] { display: none; }
|
|
138
144
|
.${PFX}-btn { border: 0; border-radius: 999px; padding: 10px 16px;
|
|
139
145
|
font-weight: 600; font-size: 13px; cursor: pointer;
|
|
140
146
|
box-shadow: 0 4px 12px rgba(0,0,0,.25); font-family: inherit; }
|
|
@@ -146,9 +152,22 @@
|
|
|
146
152
|
.${PFX}-submit .${PFX}-count { display: inline-block; background: #d946ef; color: #fff;
|
|
147
153
|
border-radius: 999px; min-width: 18px; padding: 0 6px; margin-left: 6px;
|
|
148
154
|
font-size: 11px; line-height: 18px; text-align: center; }
|
|
155
|
+
.${PFX}-min { width: 32px; height: 32px; padding: 0; border-radius: 50%;
|
|
156
|
+
background: #fff; color: #111; border: 1px solid #e4e4e7; font-size: 16px;
|
|
157
|
+
line-height: 1; display: flex; align-items: center; justify-content: center; }
|
|
158
|
+
.${PFX}-bubble { position: fixed; right: 16px; bottom: 16px; z-index: 2147483646;
|
|
159
|
+
width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
|
|
160
|
+
background: #111; color: #fff; font-size: 14px; font-weight: 700;
|
|
161
|
+
box-shadow: 0 4px 12px rgba(0,0,0,.25); display: none; }
|
|
162
|
+
.${PFX}-bubble[data-show='1'] { display: flex; align-items: center; justify-content: center; }
|
|
149
163
|
.${PFX}-mode { position: fixed; right: 16px; bottom: 60px; z-index: 2147483646;
|
|
150
164
|
background: rgba(0,0,0,.75); color: #fff; font-size: 11px;
|
|
151
165
|
padding: 4px 8px; border-radius: 4px; pointer-events: none; }
|
|
166
|
+
.${PFX}-mode[data-hidden='1'] { display: none; }
|
|
167
|
+
@media (max-width: 640px) {
|
|
168
|
+
.${PFX}-popup { left: 8px !important; right: 8px; width: auto !important; max-width: none; }
|
|
169
|
+
.${PFX}-submit-card { width: 100% !important; max-width: calc(100vw - 24px); }
|
|
170
|
+
}
|
|
152
171
|
.${PFX}-picking { cursor: crosshair !important; }
|
|
153
172
|
.${PFX}-hover-outline { outline: 2px solid #d946ef !important; outline-offset: 2px; }
|
|
154
173
|
.${PFX}-pin { position: absolute; z-index: 2147483645; width: 24px; height: 24px;
|
|
@@ -235,9 +254,33 @@
|
|
|
235
254
|
|
|
236
255
|
// ---------- UI ----------
|
|
237
256
|
|
|
238
|
-
let toggleBtn, submitBtn, modeBadge, toast, popupNode;
|
|
257
|
+
let toggleBtn, submitBtn, minBtn, bubbleBtn, barNode, modeBadge, toast, popupNode;
|
|
239
258
|
let hoverEl = null;
|
|
240
259
|
|
|
260
|
+
const applyMinimized = () => {
|
|
261
|
+
if (!barNode) return;
|
|
262
|
+
barNode.setAttribute('data-hidden', state.minimized ? '1' : '0');
|
|
263
|
+
modeBadge.setAttribute('data-hidden', state.minimized ? '1' : '0');
|
|
264
|
+
bubbleBtn.setAttribute('data-show', state.minimized ? '1' : '0');
|
|
265
|
+
// state.mode can flip live → batch mid-session if a push fails; refresh
|
|
266
|
+
// the badge each time we re-show it so it doesn't lie.
|
|
267
|
+
if (!state.minimized) {
|
|
268
|
+
modeBadge.textContent = `${state.mode === 'live' ? 'LIVE' : 'JSON'} mode`;
|
|
269
|
+
}
|
|
270
|
+
// Cancel an active pick when collapsing — otherwise clicks land on the page.
|
|
271
|
+
if (state.minimized && state.picking) {
|
|
272
|
+
state.picking = false;
|
|
273
|
+
setPickingCursor(false);
|
|
274
|
+
clearHover();
|
|
275
|
+
toggleBtn.setAttribute('data-active', '0');
|
|
276
|
+
toggleBtn.textContent = 'Add Feedback';
|
|
277
|
+
}
|
|
278
|
+
closePopup();
|
|
279
|
+
try { sessionStorage.setItem(MIN_KEY, state.minimized ? '1' : '0'); } catch (_) {}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const setMinimized = (v) => { state.minimized = !!v; applyMinimized(); };
|
|
283
|
+
|
|
241
284
|
const pendingCount = () => state.comments.filter(c => !c.delivered).length;
|
|
242
285
|
|
|
243
286
|
const refreshSubmitBtn = () => {
|
|
@@ -442,14 +485,29 @@
|
|
|
442
485
|
submitBtn = el('button', { class: `${PFX}-btn ${PFX}-submit`, on: {
|
|
443
486
|
click: openSubmitModal,
|
|
444
487
|
}});
|
|
488
|
+
minBtn = el('button', {
|
|
489
|
+
class: `${PFX}-btn ${PFX}-min`,
|
|
490
|
+
title: 'Hide overlay',
|
|
491
|
+
'aria-label': 'Hide overlay',
|
|
492
|
+
on: { click: () => setMinimized(true) },
|
|
493
|
+
}, '−');
|
|
445
494
|
refreshSubmitBtn();
|
|
446
|
-
|
|
447
|
-
|
|
495
|
+
barNode = el('div', { class: `${PFX}-bar` }, [minBtn, submitBtn, toggleBtn]);
|
|
496
|
+
bubbleBtn = el('button', {
|
|
497
|
+
class: `${PFX}-bubble`,
|
|
498
|
+
title: 'Show feedback overlay',
|
|
499
|
+
'aria-label': 'Show feedback overlay',
|
|
500
|
+
on: { click: () => setMinimized(false) },
|
|
501
|
+
}, '◐');
|
|
502
|
+
modeBadge = el('div', { class: `${PFX}-mode` }, `${state.mode === 'live' ? 'LIVE' : 'JSON'} mode`);
|
|
448
503
|
toast = el('div', { class: `${PFX}-toast` });
|
|
449
|
-
document.body.appendChild(
|
|
504
|
+
document.body.appendChild(barNode);
|
|
505
|
+
document.body.appendChild(bubbleBtn);
|
|
450
506
|
document.body.appendChild(modeBadge);
|
|
451
507
|
document.body.appendChild(toast);
|
|
452
508
|
|
|
509
|
+
applyMinimized();
|
|
510
|
+
|
|
453
511
|
document.addEventListener('mousemove', onMouseMove, true);
|
|
454
512
|
document.addEventListener('click', onClick, true);
|
|
455
513
|
};
|