@stefan.inc/feedback-engine 1.2.2 → 1.2.4
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/package.json +1 -1
- package/src/core/cardLayout.ts +12 -18
- package/src/dom/image.ts +14 -6
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Alt+Meta+click anything in the browser, click any component on the frozen screen
|
|
|
8
8
|
|
|
9
9
|
| The editor in the browser | The `feedback.png` it exports |
|
|
10
10
|
| :---: | :---: |
|
|
11
|
-
| <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-editor.png" alt="The Feedback editor in Google Chrome over the React example: the page's screenshot on the left with four notes numbered 1 to 4 and an @5 tag on the New List button, and the panel on the right with the Groceries row, a ListRow, selected and its note, Show a progress bar here." width="320"> | <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-export.png" alt="The feedback.png exported from the browser: the page with four numbered boxes and the New List button tagged @5. One column on the left holds the app's details as Name: value lines, a References line naming @5 with its file:line, and a card per note, each joined to its box by a curve that crosses no other box. Each card has its note, the component or element, and its file:line. The note on Settings reads Move this next to @5_Button. A faint GitHub mark and the repository's URL sit
|
|
11
|
+
| <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-editor.png" alt="The Feedback editor in Google Chrome over the React example: the page's screenshot on the left with four notes numbered 1 to 4 and an @5 tag on the New List button, and the panel on the right with the Groceries row, a ListRow, selected and its note, Show a progress bar here." width="320"> | <img src="https://raw.githubusercontent.com/smirea/feedback-engine/master/docs/web-export.png" alt="The feedback.png exported from the browser: the page with four numbered boxes and the New List button tagged @5. One column on the left holds the app's details as Name: value lines, a References line naming @5 with its file:line, and a card per note, each joined to its box by a curve with a dot at each end that crosses no other box. Each card has its note, the component or element, and its file:line. The note on Settings reads Move this next to @5_Button. A faint GitHub mark and the repository's URL sit in the top left corner, above the details." width="520"> |
|
|
12
12
|
|
|
13
13
|
Four notes on the React example in Google Chrome. The last one points at a second element. Type `@`, click the element, and the note reads `Move this next to @5_Button`. The export draws that element's box and highlights the token in the same color, so an agent knows which button you meant. Each card names its component or element and the `file:line` it comes from, such as `src/components/ListRow.tsx:4`.
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stefan.inc/feedback-engine",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "In-app feedback for Svelte and React: point at a component, write what should change, and export its name, file:line, and data for an agent.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
package/src/core/cardLayout.ts
CHANGED
|
@@ -9,7 +9,7 @@ export const cards = {
|
|
|
9
9
|
padding: 10,
|
|
10
10
|
rightColumnPenalty: 80,
|
|
11
11
|
crossingPenalty: 500,
|
|
12
|
-
watermark:
|
|
12
|
+
watermark: 13,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export type Card = { isLeft: boolean; origin: Point };
|
|
@@ -94,8 +94,7 @@ function crossings(path: Point[], target: Frame, boxes: Frame[], earlier: Point[
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
type Columns = 'both' | 'left' | 'right';
|
|
97
|
-
|
|
98
|
-
type Arrangement = Layout & { cost: number; crossings: number; fit: number };
|
|
97
|
+
type Arrangement = Layout & { cost: number; crossings: number };
|
|
99
98
|
|
|
100
99
|
function arrange(
|
|
101
100
|
columns: Columns,
|
|
@@ -120,6 +119,7 @@ function arrange(
|
|
|
120
119
|
const midY = (index: number) => moved[index]!.y + moved[index]!.height / 2;
|
|
121
120
|
const placed: Card[] = moved.map(() => ({ isLeft: true, origin: { x: 0, y: 0 } }));
|
|
122
121
|
const paths: Point[][] = [];
|
|
122
|
+
const environment = { x: columns === 'left' ? margin : rightX, y: margin };
|
|
123
123
|
const underEnvironment = margin + environmentHeight + spacing * 2;
|
|
124
124
|
let nextLeft = columns === 'left' ? underEnvironment : margin;
|
|
125
125
|
let nextRight = underEnvironment;
|
|
@@ -155,32 +155,26 @@ function arrange(
|
|
|
155
155
|
...placed.map((card, index) => card.origin.y + heights[index]! - shot.y),
|
|
156
156
|
);
|
|
157
157
|
shot.height = Math.min(screen.height, Math.max(viewport, lowest + viewport / 2));
|
|
158
|
-
const
|
|
159
|
-
const fit = Math.max(shot.y + shot.height, nextLeft - spacing, nextRight - spacing) + margin;
|
|
160
|
-
const height = Math.max(fit, last + watermark + margin);
|
|
158
|
+
const height = Math.max(shot.y + shot.height, nextLeft - spacing, nextRight - spacing) + margin;
|
|
161
159
|
return {
|
|
162
160
|
shot,
|
|
163
161
|
cards: placed,
|
|
164
|
-
environment
|
|
165
|
-
watermark: {
|
|
166
|
-
isLeft: columns !== 'right',
|
|
167
|
-
origin: { x: columns === 'right' ? rightX : margin, y: height - margin - watermark },
|
|
168
|
-
},
|
|
162
|
+
environment,
|
|
163
|
+
watermark: { isLeft: columns === 'left', origin: { x: environment.x, y: (margin - watermark) / 2 } },
|
|
169
164
|
size: { width: columns === 'left' ? shot.x + shot.width + margin : rightX + column + margin, height },
|
|
170
165
|
cost,
|
|
171
166
|
crossings: crossed,
|
|
172
|
-
fit,
|
|
173
167
|
};
|
|
174
168
|
}
|
|
175
169
|
|
|
176
170
|
/**
|
|
177
171
|
* Where the image export puts each item's card. Cards go in the column whose path to the target costs least: its
|
|
178
172
|
* length, `rightColumnPenalty` points for the right column, and `crossingPenalty` for each other box or earlier path
|
|
179
|
-
* it crosses, as level with the target as the cards above allow. The
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
173
|
+
* it crosses, as level with the target as the cards above allow. The watermark sits in the top margin, centered in it,
|
|
174
|
+
* in the outer corner of the environment's column. The environment sits at the top of the right column, and
|
|
175
|
+
* right-column cards start below it. When one column holds the
|
|
176
|
+
* environment and every card with no crossing and no taller image, the image drops the other column and keeps only a
|
|
177
|
+
* margin on that side, and of the two sides it takes the one whose paths are shorter in total. A tall capture is cut half the
|
|
184
178
|
* height that was on screen below the lowest box or card, and never shorter than that height, and `shot` is the part
|
|
185
179
|
* that is drawn. `targets` and `references` are frames in the capture. The layout's frames are in the image.
|
|
186
180
|
*/
|
|
@@ -196,7 +190,7 @@ export function place(
|
|
|
196
190
|
arrange(columns, targets, heights, screen, environmentHeight, viewport, references);
|
|
197
191
|
const both = build('both');
|
|
198
192
|
const single = [build('left'), build('right')]
|
|
199
|
-
.filter(option => option.crossings === 0 && option.
|
|
193
|
+
.filter(option => option.crossings === 0 && option.size.height <= both.size.height)
|
|
200
194
|
.reduce<Arrangement | undefined>(
|
|
201
195
|
(chosen, option) => (chosen && chosen.cost <= option.cost ? chosen : option),
|
|
202
196
|
undefined,
|
package/src/dom/image.ts
CHANGED
|
@@ -128,9 +128,18 @@ const footerPadding = 6;
|
|
|
128
128
|
|
|
129
129
|
const clamp = (value: number, low: number, high: number) => Math.min(Math.max(value, low), high);
|
|
130
130
|
|
|
131
|
+
const stroke = 1.5;
|
|
132
|
+
|
|
133
|
+
function dot(context: CanvasRenderingContext2D, center: Point, color: string) {
|
|
134
|
+
context.beginPath();
|
|
135
|
+
context.arc(center.x, center.y, 2.5, 0, Math.PI * 2);
|
|
136
|
+
context.fillStyle = color;
|
|
137
|
+
context.fill();
|
|
138
|
+
}
|
|
139
|
+
|
|
131
140
|
function dashedBox(context: CanvasRenderingContext2D, target: Frame, color: string) {
|
|
132
141
|
roundedRect(context, { x: target.x - 1, y: target.y - 1, width: target.width + 2, height: target.height + 2 }, 4);
|
|
133
|
-
context.lineWidth =
|
|
142
|
+
context.lineWidth = stroke;
|
|
134
143
|
context.setLineDash([6, 4]);
|
|
135
144
|
context.strokeStyle = withAlpha(color, 0.9);
|
|
136
145
|
context.stroke();
|
|
@@ -183,6 +192,7 @@ function watermark(context: CanvasRenderingContext2D, { isLeft, origin }: Card)
|
|
|
183
192
|
context.fillStyle = withAlpha(secondary, 0.5);
|
|
184
193
|
context.save();
|
|
185
194
|
context.translate(x, origin.y);
|
|
195
|
+
context.scale(side / 16, side / 16);
|
|
186
196
|
const mark = new Path2D(githubPath);
|
|
187
197
|
context.fill(mark);
|
|
188
198
|
context.restore();
|
|
@@ -322,13 +332,10 @@ export function annotatedImage({ capture, image, scale }: Screen, annotations: A
|
|
|
322
332
|
context.beginPath();
|
|
323
333
|
context.moveTo(start.x, start.y);
|
|
324
334
|
context.bezierCurveTo(control1.x, control1.y, control2.x, control2.y, end.x, end.y);
|
|
325
|
-
context.lineWidth =
|
|
335
|
+
context.lineWidth = stroke;
|
|
326
336
|
context.strokeStyle = withAlpha(item.color, 0.6);
|
|
327
337
|
context.stroke();
|
|
328
|
-
context.
|
|
329
|
-
context.arc(end.x, end.y, 2.5, 0, Math.PI * 2);
|
|
330
|
-
context.fillStyle = item.color;
|
|
331
|
-
context.fill();
|
|
338
|
+
dot(context, end, item.color);
|
|
332
339
|
badge(context, item.number, item.color, {
|
|
333
340
|
x: clamp(target.x, shot.x + badgeSize / 2 + 2, shot.x + shot.width - badgeSize / 2 - 2),
|
|
334
341
|
y: clamp(target.y, shot.y + badgeSize / 2 + 2, shot.y + shot.height - badgeSize / 2 - 2),
|
|
@@ -363,6 +370,7 @@ export function annotatedImage({ capture, image, scale }: Screen, annotations: A
|
|
|
363
370
|
});
|
|
364
371
|
drawText(context, item.text, { x: origin.x + padding * 2 + badgeSize, y: origin.y + padding });
|
|
365
372
|
drawText(context, item.footer, { x: origin.x + padding, y: origin.y + item.body + footerPadding });
|
|
373
|
+
dot(context, connector(placed.cards[index]!, inShot(item.frame)).start, item.color);
|
|
366
374
|
}
|
|
367
375
|
|
|
368
376
|
drawText(context, environment, placed.environment);
|