@decidables/prospectable-elements 0.5.2 → 0.6.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": "@decidables/prospectable-elements",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "prospectable-elements: Web Components for visualizing Cumulative Prospect Theory",
5
5
  "keywords": [
6
6
  "web component",
@@ -49,6 +49,7 @@
49
49
  "lib"
50
50
  ],
51
51
  "scripts": {
52
+ "clean": "gulp clean",
52
53
  "lint": "gulp lint",
53
54
  "test": "gulp test -X \"$@\"",
54
55
  "build": "gulp build"
@@ -57,8 +58,8 @@
57
58
  "gulp": "^5.0.1"
58
59
  },
59
60
  "dependencies": {
60
- "@decidables/decidables-elements": "^0.5.7",
61
- "@decidables/prospectable-math": "^0.3.5",
61
+ "@decidables/decidables-elements": "^0.6.0",
62
+ "@decidables/prospectable-math": "^0.3.6",
62
63
  "@lit-labs/motion": "^1.1.0",
63
64
  "@observablehq/plot": "^0.6.17",
64
65
  "bayes.js": "https://github.com/akrawitz/bayes.js.git#commit=c7b091b75f85a86b6a3965a983b31e23d9ef456f",
@@ -67,5 +68,5 @@
67
68
  "d3-3d": "^2.0.0",
68
69
  "lit": "^3.3.2"
69
70
  },
70
- "gitHead": "6fcd31a19c082ec41bde7d351bcb52161c5b654b"
71
+ "gitHead": "72981c711111354170ece1e403d497073da7be96"
71
72
  }
@@ -92,6 +92,7 @@ export default class CPTParameters extends ProspectableElement {
92
92
 
93
93
  decidables-slider {
94
94
  line-height: 1;
95
+
95
96
  text-align: center;
96
97
  }
97
98
 
@@ -275,9 +275,9 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
275
275
 
276
276
  .curve.interactive {
277
277
  cursor: nwse-resize;
278
+ outline: none;
278
279
 
279
280
  filter: url("#shadow-2");
280
- outline: none;
281
281
  }
282
282
 
283
283
  .curve.interactive:hover {
@@ -295,7 +295,7 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
295
295
  transform: translateY(0);
296
296
  }
297
297
 
298
- :host(.keyboard) .curve.interactive:focus {
298
+ .curve.interactive:focus-visible {
299
299
  filter: url("#shadow-8");
300
300
 
301
301
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -304,9 +304,9 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
304
304
 
305
305
  .point.interactive {
306
306
  cursor: nesw-resize;
307
+ outline: none;
307
308
 
308
309
  filter: url("#shadow-2");
309
- outline: none;
310
310
 
311
311
  /* HACK: This gets Safari to correctly apply the filter! */
312
312
  stroke: #000000;
@@ -328,7 +328,7 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
328
328
  stroke: #00ff00;
329
329
  }
330
330
 
331
- :host(.keyboard) .point.interactive:focus {
331
+ .point.interactive:focus-visible {
332
332
  filter: url("#shadow-8");
333
333
 
334
334
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -362,8 +362,8 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
362
362
 
363
363
  .diagonal {
364
364
  stroke: var(---color-element-border);
365
- stroke-dasharray: 4;
366
365
  stroke-width: 1;
366
+ stroke-dasharray: 4;
367
367
  }
368
368
 
369
369
  .curve {
@@ -396,8 +396,8 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
396
396
  font-size: 0.75rem;
397
397
 
398
398
  dominant-baseline: middle;
399
- text-anchor: middle;
400
399
 
400
+ text-anchor: middle;
401
401
  fill: var(---color-text-inverse);
402
402
  }
403
403
 
@@ -409,8 +409,8 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
409
409
 
410
410
  @media (pointer: coarse) {
411
411
  .interactive .touch {
412
- stroke-linecap: round;
413
412
  stroke-width: 12;
413
+ stroke-linecap: round;
414
414
  }
415
415
  }
416
416
  `,
@@ -327,6 +327,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
327
327
  font-weight: 600;
328
328
 
329
329
  alignment-baseline: middle;
330
+
330
331
  text-anchor: middle;
331
332
  }
332
333
 
@@ -350,6 +351,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
350
351
  font-size: 0.75rem;
351
352
 
352
353
  alignment-baseline: middle;
354
+
353
355
  text-anchor: end;
354
356
  }
355
357
 
@@ -390,6 +392,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
390
392
  font-weight: 600;
391
393
 
392
394
  alignment-baseline: middle;
395
+
393
396
  text-anchor: middle;
394
397
  }
395
398
 
@@ -289,9 +289,9 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
289
289
  .curve-p.interactive,
290
290
  .curve-n.interactive {
291
291
  cursor: nwse-resize;
292
+ outline: none;
292
293
 
293
294
  filter: url("#shadow-2");
294
- outline: none;
295
295
  }
296
296
 
297
297
  .curve-p.interactive:hover,
@@ -311,8 +311,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
311
311
  transform: translateY(0);
312
312
  }
313
313
 
314
- :host(.keyboard) .curve-p.interactive:focus,
315
- :host(.keyboard) .curve-n.interactive:focus {
314
+ .curve-p.interactive:focus-visible,
315
+ .curve-n.interactive:focus-visible {
316
316
  filter: url("#shadow-8");
317
317
 
318
318
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -321,9 +321,9 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
321
321
 
322
322
  .point.interactive {
323
323
  cursor: nesw-resize;
324
+ outline: none;
324
325
 
325
326
  filter: url("#shadow-2");
326
- outline: none;
327
327
 
328
328
  /* HACK: This gets Safari to correctly apply the filter! */
329
329
  stroke: #000000;
@@ -345,7 +345,7 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
345
345
  stroke: #00ff00;
346
346
  }
347
347
 
348
- :host(.keyboard) .point.interactive:focus {
348
+ .point.interactive:focus-visible {
349
349
  filter: url("#shadow-8");
350
350
 
351
351
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -385,8 +385,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
385
385
 
386
386
  .diagonal {
387
387
  stroke: var(---color-element-border);
388
- stroke-dasharray: 4;
389
388
  stroke-width: 1;
389
+ stroke-dasharray: 4;
390
390
  }
391
391
 
392
392
  .curve-p,
@@ -420,8 +420,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
420
420
  font-size: 0.75rem;
421
421
 
422
422
  dominant-baseline: middle;
423
- text-anchor: middle;
424
423
 
424
+ text-anchor: middle;
425
425
  fill: var(---color-text-inverse);
426
426
  }
427
427
 
@@ -433,8 +433,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
433
433
 
434
434
  @media (pointer: coarse) {
435
435
  .interactive .touch {
436
- stroke-linecap: round;
437
436
  stroke-width: 12;
437
+ stroke-linecap: round;
438
438
  }
439
439
  }
440
440
  `,
@@ -397,6 +397,7 @@ export default class DecisionSpace extends DecidablesMixinResizeable(Prospectabl
397
397
  font-weight: 600;
398
398
 
399
399
  alignment-baseline: middle;
400
+
400
401
  text-anchor: middle;
401
402
  }
402
403
 
@@ -420,6 +421,7 @@ export default class DecisionSpace extends DecidablesMixinResizeable(Prospectabl
420
421
  font-size: 0.75rem;
421
422
 
422
423
  alignment-baseline: middle;
424
+
423
425
  text-anchor: end;
424
426
  }
425
427
 
@@ -460,6 +462,7 @@ export default class DecisionSpace extends DecidablesMixinResizeable(Prospectabl
460
462
  font-weight: 600;
461
463
 
462
464
  alignment-baseline: middle;
465
+
463
466
  text-anchor: middle;
464
467
  }
465
468
 
@@ -265,6 +265,7 @@ export default class ProspectableResponse extends ProspectableElement {
265
265
 
266
266
  width: 5.25rem;
267
267
  height: 3.5rem;
268
+
268
269
  padding: 0.375rem 0.75rem;
269
270
  margin: 0.25rem;
270
271
 
@@ -292,6 +293,7 @@ export default class ProspectableResponse extends ProspectableElement {
292
293
 
293
294
  .feedback .outcome {
294
295
  font-weight: 600;
296
+
295
297
  line-height: 1.15;
296
298
  }
297
299
 
@@ -23,6 +23,8 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
23
23
  --decidables-spinner-input-width: 4rem;
24
24
  --decidables-spinner-prefix: "$";
25
25
 
26
+ position: relative;
27
+
26
28
  display: inline-block;
27
29
 
28
30
  width: 10rem;
@@ -32,6 +34,7 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
32
34
  .main {
33
35
  width: 100%;
34
36
  height: 100%;
37
+
35
38
  overflow: visible;
36
39
  }
37
40
 
@@ -48,9 +51,9 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
48
51
 
49
52
  .arc.interactive {
50
53
  cursor: ns-resize;
54
+ outline: none;
51
55
 
52
56
  filter: url("#shadow-2");
53
- outline: none;
54
57
  }
55
58
 
56
59
  .arc.interactive:hover {
@@ -61,7 +64,7 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
61
64
  filter: url("#shadow-8");
62
65
  }
63
66
 
64
- :host(.keyboard) .arc.interactive:focus {
67
+ .arc.interactive:focus-visible {
65
68
  filter: url("#shadow-8");
66
69
  }
67
70
 
@@ -80,23 +83,20 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
80
83
  .label.static {
81
84
  font-size: 1.75rem;
82
85
 
86
+ dominant-baseline: middle;
87
+
83
88
  user-select: none;
84
89
 
85
- dominant-baseline: middle;
86
90
  text-anchor: middle;
87
91
  }
88
92
 
89
93
  .label.interactive {
94
+ position: absolute;
95
+
90
96
  width: var(--decidables-spinner-input-width);
91
97
  height: calc(var(--decidables-spinner-font-size) * 1.5);
92
- overflow: visible;
93
- }
94
98
 
95
- /* HACK: Get Safari to work with SVG foreignObject */
96
- /* https://stackoverflow.com/questions/51313873/svg-foreignobject-not-working-properly-on-safari */
97
- /* https://bugs.webkit.org/show_bug.cgi?id=23113 */
98
- .label.interactive decidables-spinner {
99
- position: fixed;
99
+ overflow: visible;
100
100
  }
101
101
 
102
102
  .label.interactive.win decidables-spinner {
@@ -332,12 +332,12 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
332
332
  // DATA-JOIN
333
333
  const labelStaticUpdate = pieMerge.selectAll('.label.static')
334
334
  .data(arcsStatic);
335
- const labelInteractiveUpdate = pieMerge.selectAll('.label.interactive')
335
+ const labelInteractiveUpdate = d3.select(this.renderRoot).selectAll('.label.interactive')
336
336
  .data(arcsInteractive);
337
337
  // ENTER
338
338
  const labelStaticEnter = labelStaticUpdate.enter().append('text');
339
- const labelInteractiveEnter = labelInteractiveUpdate.enter().append('foreignObject');
340
- labelInteractiveEnter.append('xhtml:decidables-spinner')
339
+ const labelInteractiveEnter = labelInteractiveUpdate.enter().append('xhtml:div');
340
+ labelInteractiveEnter.append('decidables-spinner')
341
341
  .on('input', (event, datum) => {
342
342
  datum.data.x = parseFloat(event.target.value);
343
343
 
@@ -364,22 +364,19 @@ export default class RiskyOption extends DecidablesMixinResizeable(ProspectableE
364
364
  .text((datum) => { return `$${datum.data.x.toFixed(0)}`; });
365
365
  const labelInteractiveMerge = labelInteractiveEnter.merge(labelInteractiveUpdate)
366
366
  .attr('class', (datum) => { return `label interactive ${datum.data.name}`; })
367
- .attr('transform', (datum) => {
368
- // HACK: Center spinner here instead of CSS for Safari SVG foreignObject
369
- // x: calc(var(--decidables-spinner-input-width) / -2);
370
- // y: calc(var(--decidables-spinner-font-size) * 1.5 / -2);
367
+ .attr('style', (datum) => {
371
368
  const inputWidth = parseFloat(this.getComputedStyleValue('--decidables-spinner-input-width'));
372
369
  const fontSize = parseFloat(this.getComputedStyleValue('--decidables-spinner-font-size'));
373
370
  const rem = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('font-size'), 10);
374
- const x = (inputWidth * rem) / -2;
375
- const y = (fontSize * rem * 1.5) / -2;
371
+ const x = (width / 2) + (inputWidth * rem) / -2;
372
+ const y = (height / 2) + (fontSize * rem * 1.5) / -2;
376
373
 
377
374
  if (arcs.length === 1) {
378
- return `translate(${x}, ${y})`;
375
+ return `left: ${x}px; top: ${y}px;`;
379
376
  }
380
377
  const radius = (Math.min(width, height) / 2) * 0.6;
381
378
  const arcLabel = d3.arc().innerRadius(radius).outerRadius(radius);
382
- return `translate(${arcLabel.centroid(datum)[0] + x}, ${arcLabel.centroid(datum)[1] + y})`;
379
+ return `left: ${arcLabel.centroid(datum)[0] + x}px; top: ${arcLabel.centroid(datum)[1] + y}px;`;
383
380
  });
384
381
  labelInteractiveMerge.select('decidables-spinner')
385
382
  .attr('value', (datum) => { return `${datum.data.x.toFixed(0)}`; });
@@ -87,11 +87,13 @@ export default class CPTEquation extends ProspectableElement {
87
87
 
88
88
  .addend {
89
89
  position: relative;
90
+
90
91
  display: inline-block;
91
92
  }
92
93
 
93
94
  .comparison {
94
95
  position: relative;
96
+
95
97
  display: inline-block;
96
98
 
97
99
  font-size: 125%;