@stefan.inc/feedback-engine 1.0.2 → 1.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stefan.inc/feedback-engine",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
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",
@@ -0,0 +1,3 @@
1
+ /** ProcrastiMate's app icon without its tile, 66 pixels square for 22 CSS pixels. Rendered by `scripts/procrastimate-icon.ts` from ProcrastiMate's `app-icon.svg`. */
2
+ export const procrastimateIcon =
3
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAMAAADUivDaAAABiVBMVEVHcEwUPIM3if03ifs1hf81jf83if03ifw4if83ifw3ifwUNHQ3if03ifw3ifw3if03ifw3if03ifw4ifw2if83ifw3ifw3ifwOLGo3ifs3ifw3ifo3iPoZRpMVPIQcTJkyfOn99uU3ifwEFUc4ifwbcPT99uYEFUZCTW/08eYKG0wmYsBLlPq/vr2Oo8Nob4caK1dTapXw7uQQI1YkW7QlYLvM2ONudYpno/cqbM83R2shMlsqOWK5z+vW3+j69ORNV3VhaoEmd/Ti5ucXQIqxyqTn4tc0QWVZY3wPJ1/c4+eAlLaru9KnxO1cnPaZvu9NjvEtdNt6gJIdSpcxfOjo6uc0g/QnZcSfss91iKqPk5+UpsPE0+WDiJh8r/SQuvJheqaBmsFtoe+pqrCho6t5kIZJXIXFxMKFnI3a189Yc6KEr+4mU6CJm7l3pu/W0824xNQyfu5wi7VLYG27ydqPqdDOzMePp5JvhYA9UX4weOJtfZ+ptaljeHpyo+6vxeFwqPVtmdhzouPaTv+UAAAAIXRSTlMAwGqzCRDWkiL1zv5yW8XwfumtTBeLo8D+P9w0MIK+bMWpbfIMAAAFGUlEQVRYw+1XaVfiSBR1REQERF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sCE/L6RojxEGJRwsOrr91Xkoqw9C+uto7A+hCvxMEq+DAJwD9XyqRYz5K+guJiURhUT68gCgfAh/XVNVDdC+A4fCMHAp/EmKKHMH8OBb4Fc8GlQvUEjeE0v5Zz+lqel89AGMWqJzTeG/wJ3WRPLFUhEiKqhPd5/7eje5HTo4qIEoLKAs7O2nWZqjvQl5HfrxNiz+fz7YHNXAkF+W6hu7ZeaGKIDEDV4U+M4LvC4yE0WGVhPI90vVUQ6ThQBN9bPBoSB/luxaaDaDVjwWyKIrzJ9hEWMZ5FW+1paGCRmaI9BkOg4RlAg5wWQqsOotvIog/MYMcMGBllCFSXAb0WL0waA43FAC42xHWUIYwqBWhAr0W7vtnVs8AQAZ9mo3GsA7kMLFoa6oaEslBkpFRUZata1K4D93punkW+Gkyfb4TtDyMLe00D2sGzoBDgL4owU42vTgtXvVaLsRhnLtNkSyk6kCuPghqLdrM+x1nNEQUi+8a3l+WzVQyqe8JV50PMo2ZqTssPTQfyzKFlxqH51SMd+AKKFs3avqIkLhAOnsbHP0UKKFlUcpW7TktigWTGo182LU5L9289SPIbLSmJDovX9dRPtKbXv/xUY69//fHd/j/Yf9pylQ+uqoR2AAAAAElFTkSuQmCC';
@@ -23,6 +23,7 @@
23
23
  type ExportFormat,
24
24
  } from '../dom/share.ts';
25
25
  import type { Webhook } from '../dom/webhook.ts';
26
+ import { destinations, shortcutCount, type Destination } from './destinations.ts';
26
27
  import type { Engine } from './engine.ts';
27
28
  import ItemsSheet from './ItemsSheet.svelte';
28
29
  import ProcrastimateSheet from './ProcrastimateSheet.svelte';
@@ -91,6 +92,8 @@
91
92
  let showsShare = $state(false);
92
93
  let showsProcrastimate = $state(false);
93
94
  let posting = $state<Webhook>();
95
+ // svelte-ignore state_referenced_locally
96
+ const targets = destinations(engine.options);
94
97
  let confirmsClose = $state(false);
95
98
  let pending = $state<{ format: ExportFormat; ready: Export }>();
96
99
  let busy = $state(false);
@@ -209,6 +212,12 @@
209
212
  }
210
213
  }
211
214
 
215
+ function send(destination: Destination) {
216
+ showsShare = false;
217
+ if (destination.kind === 'procrastimate') showsProcrastimate = true;
218
+ else posting = destination.webhook;
219
+ }
220
+
212
221
  async function choose(format: ExportFormat) {
213
222
  showsShare = false;
214
223
  busy = true;
@@ -271,6 +280,22 @@
271
280
  <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6h11M9 12h11M9 18h11M4 6h.01M4 12h.01M4 18h.01" /></svg>
272
281
  {#if view.items.length}<span class="count" aria-hidden="true">{view.items.length}</span>{/if}
273
282
  </button>
283
+ {#each targets.slice(0, shortcutCount) as destination, index (index)}
284
+ <button
285
+ type="button"
286
+ class="round"
287
+ aria-label={destination.name}
288
+ title={destination.name}
289
+ disabled={!view.items.length || busy}
290
+ onclick={() => send(destination)}
291
+ >
292
+ {#if destination.image}
293
+ <img src={destination.image} alt="" />
294
+ {:else}
295
+ <svg viewBox="0 0 24 24" aria-hidden="true"><path d="M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" /></svg>
296
+ {/if}
297
+ </button>
298
+ {/each}
274
299
  <div class="menu">
275
300
  <button
276
301
  type="button"
@@ -288,28 +313,10 @@
288
313
  {#each Object.entries(exportTitles) as [format, name] (format)}
289
314
  <button type="button" role="menuitem" onclick={() => void choose(format as ExportFormat)}>{name}</button>
290
315
  {/each}
291
- {#if engine.options.procrastimate}
292
- <button
293
- type="button"
294
- role="menuitem"
295
- onclick={() => {
296
- showsShare = false;
297
- showsProcrastimate = true;
298
- }}>ProcrastiMate</button
299
- >
300
- {/if}
301
- {#each engine.options.webhooks ?? [] as webhook, index (index)}
302
- <button
303
- type="button"
304
- role="menuitem"
305
- class="webhook"
306
- onclick={() => {
307
- showsShare = false;
308
- posting = webhook;
309
- }}
310
- >
311
- {#if webhook.image}<img src={webhook.image} alt="" />{/if}
312
- {webhook.name}
316
+ {#each targets as destination, index (index)}
317
+ <button type="button" role="menuitem" class="destination" onclick={() => send(destination)}>
318
+ {#if destination.image}<img src={destination.image} alt="" />{/if}
319
+ {destination.name}
313
320
  </button>
314
321
  {/each}
315
322
  </div>
@@ -624,7 +631,11 @@
624
631
 
625
632
  h1 {
626
633
  flex: 1;
634
+ min-width: 0;
627
635
  margin: 0;
636
+ overflow: hidden;
637
+ text-overflow: ellipsis;
638
+ white-space: nowrap;
628
639
  font-size: 17px;
629
640
  font-weight: 600;
630
641
  text-align: center;
@@ -641,6 +652,12 @@
641
652
  background: #2c2c2e;
642
653
  }
643
654
 
655
+ .round img {
656
+ width: 22px;
657
+ height: 22px;
658
+ object-fit: contain;
659
+ }
660
+
644
661
  .round.small {
645
662
  width: 30px;
646
663
  height: 30px;
@@ -698,7 +715,7 @@
698
715
  background: rgb(255 255 255 / 0.08);
699
716
  }
700
717
 
701
- .popup .webhook {
718
+ .popup .destination {
702
719
  display: flex;
703
720
  align-items: center;
704
721
  gap: 10px;
@@ -0,0 +1,25 @@
1
+ import type { ProcrastimateConfig } from '../dom/procrastimate.ts';
2
+ import { procrastimateIcon } from '../dom/procrastimate-icon.ts';
3
+ import { githubIcon, type Webhook } from '../dom/webhook.ts';
4
+
5
+ /** A server the feedback can be posted to, as the Share menu lists it after the exports. */
6
+ export type Destination = { name: string; image?: string } & (
7
+ | { kind: 'procrastimate' }
8
+ | { kind: 'webhook'; webhook: Webhook }
9
+ );
10
+
11
+ /** How many destinations also get a button beside Share. */
12
+ export const shortcutCount = 2;
13
+
14
+ /** ProcrastiMate first, then the webhooks with GitHub's icon, then the other webhooks in the app's order. */
15
+ export function destinations(options: { procrastimate?: ProcrastimateConfig; webhooks?: Webhook[] }): Destination[] {
16
+ const webhooks = [...(options.webhooks ?? [])].sort(
17
+ (a, b) => Number(b.image === githubIcon) - Number(a.image === githubIcon),
18
+ );
19
+ return [
20
+ ...(options.procrastimate
21
+ ? [{ kind: 'procrastimate' as const, name: 'ProcrastiMate', image: procrastimateIcon }]
22
+ : []),
23
+ ...webhooks.map(webhook => ({ kind: 'webhook' as const, name: webhook.name, image: webhook.image, webhook })),
24
+ ];
25
+ }
@@ -27,7 +27,8 @@ export type FeedbackOptions = {
27
27
  procrastimate?: ProcrastimateConfig;
28
28
  /**
29
29
  * Adds one entry to the Share menu per webhook. Choosing it posts the image export and the JSON export to the
30
- * webhook's `url`, with nothing more to fill in.
30
+ * webhook's `url`, with nothing more to fill in. The menu lists ProcrastiMate, then the webhooks with `githubIcon`,
31
+ * then the others, and the first two of them also get a button beside Share.
31
32
  */
32
33
  webhooks?: Webhook[];
33
34
  };
@@ -32,7 +32,8 @@ export type FeedbackOptions = {
32
32
  };
33
33
  /**
34
34
  * Adds one entry to the Share menu per webhook. Choosing it posts the image export and the JSON export to the
35
- * webhook's `url`, with nothing more to fill in.
35
+ * webhook's `url`, with nothing more to fill in. The menu lists ProcrastiMate, then the webhooks with `githubIcon`,
36
+ * then the others, and the first two of them also get a button beside Share.
36
37
  */
37
38
  webhooks?: Webhook[];
38
39
  };