@decidables/accumulable-elements 0.3.6 → 0.3.7

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.
@@ -4742,54 +4742,12 @@
4742
4742
  const ambientS = rotate ? `${-ambientM.y}px ${ambientM.y / 2}px ${ambientM.b}px ${ambientM.s}px` : `${ambientM.y / 2}px ${ambientM.y}px ${ambientM.b}px ${ambientM.s}px`;
4743
4743
  return `${umbraS} ${umbraC}, ${penumbraS} ${penumbraC}, ${ambientS} ${ambientC}`;
4744
4744
  }
4745
- static get svgDefs() {
4746
- const shadows = DecidablesElement.shadows; /* eslint-disable-line prefer-destructuring */
4747
-
4748
- const filters = shadows.elevations.map(z => {
4749
- return `
4750
- <filter id=${`shadow-${z}`} filterUnits="userSpaceOnUse" x="-100%" y="-100%" width="200%" height="200%">
4751
- <feComponentTransfer in="SourceAlpha" result="solid">
4752
- <feFuncA type="table" tableValues="0 1 1"/>
4753
- </feComponentTransfer>
4754
- <feOffset in="solid" result="offU" dx=${shadows.mapUmbra[z].y / 2} dy=${shadows.mapUmbra[z].y} />
4755
- <feOffset in="solid" result="offP" dx=${shadows.mapPenumbra[z].y / 2} dy=${shadows.mapPenumbra[z].y} />
4756
- <feOffset in="solid" result="offA" dx=${shadows.mapAmbient[z].y / 2} dy=${shadows.mapAmbient[z].y} />
4757
- ${shadows.mapUmbra[z].s === 0 ? '' : `<feMorphology in="offU" result="spreadU" operator=${shadows.mapUmbra[z].s > 0 ? 'dilate' : 'erode'} radius=${Math.abs(shadows.mapUmbra[z].s)} />`}
4758
- ${shadows.mapPenumbra[z].s === 0 ? '' : `<feMorphology in="offP" result="spreadP" operator=${shadows.mapPenumbra[z].s > 0 ? 'dilate' : 'erode'} radius=${Math.abs(shadows.mapPenumbra[z].s)} />`}
4759
- ${shadows.mapAmbient[z].s === 0 ? '' : `<feMorphology in="offA" result="spreadA" operator=${shadows.mapAmbient[z].s > 0 ? 'dilate' : 'erode'} radius=${Math.abs(shadows.mapAmbient[z].s)} />`}
4760
- <feGaussianBlur in=${shadows.mapUmbra[z].s === 0 ? 'offU' : 'spreadU'} result="blurU" stdDeviation=${shadows.mapUmbra[z].b / 2} />
4761
- <feGaussianBlur in=${shadows.mapPenumbra[z].s === 0 ? 'offP' : 'spreadP'} result="blurP" stdDeviation=${shadows.mapPenumbra[z].b / 2} />
4762
- <feGaussianBlur in=${shadows.mapAmbient[z].s === 0 ? 'offA' : 'spreadA'} result="blurA" stdDeviation=${shadows.mapAmbient[z].b / 2} />
4763
- <feFlood in="SourceGraphic" result="opU" flood-color=${shadows.baselineColor} flood-opacity=${shadows.opacityUmbra + shadows.opacityBoost} />
4764
- <feFlood in="SourceGraphic" result="opP" flood-color=${shadows.baselineColor} flood-opacity=${shadows.opacityPenumbra + shadows.opacityBoost} />
4765
- <feFlood in="SourceGraphic" result="opA" flood-color=${shadows.baselineColor} flood-opacity=${shadows.opacityAmbient + shadows.opacityBoost} />
4766
- <feComposite in="opU" in2="blurU" result="shU" operator="in" />
4767
- <feComposite in="opP" in2="blurP" result="shP" operator="in" />
4768
- <feComposite in="opA" in2="blurA" result="shA" operator="in" />
4769
- <feMorphology in="solid" result="smaller" operator="erode" radius="1" />
4770
- <feComposite in="shU" in2="smaller" result="finalU" operator="out" />
4771
- <feComposite in="shP" in2="smaller" result="finalP" operator="out" />
4772
- <feComposite in="shA" in2="smaller" result="finalA" operator="out" />
4773
- <feMerge>
4774
- <feMergeNode in="finalU" />
4775
- <feMergeNode in="finalP" />
4776
- <feMergeNode in="finalA" />
4777
- <feMergeNode in="SourceGraphic" />
4778
- </feMerge>
4779
- </filter>`;
4780
- });
4781
- return `
4782
- <defs>
4783
- ${filters}
4784
- </defs>
4785
- `;
4786
- }
4787
4745
  static get svgFilters() {
4788
4746
  const shadows = DecidablesElement.shadows; /* eslint-disable-line prefer-destructuring */
4789
4747
 
4790
4748
  const filters = shadows.elevations.map(z => {
4791
4749
  return b`
4792
- <filter id=${`shadow-${z}`} x="-250%" y="-250%" width="600%" height="600%">
4750
+ <filter id=${`shadow-${z}`} filterUnits="userSpaceOnUse" x="-100%" y="-100%" width="200%" height="200%">
4793
4751
  <feComponentTransfer in="SourceAlpha" result="solid">
4794
4752
  <feFuncA type="table" tableValues="0 1 1"/>
4795
4753
  </feComponentTransfer>
@@ -4821,11 +4779,9 @@
4821
4779
  </filter>`;
4822
4780
  });
4823
4781
  return b`
4824
- <svg class="defs">
4825
- <defs>
4826
- ${filters}
4827
- </defs>
4828
- </svg>
4782
+ <defs class="filtersUser">
4783
+ ${filters}
4784
+ </defs>
4829
4785
  `;
4830
4786
  }
4831
4787
  static get styles() {
@@ -8042,31 +7998,50 @@
8042
7998
  /*
8043
7999
  OVERLAYER
8044
8000
  */
8045
- .interactive {
8001
+ .boundary.interactive {
8002
+ cursor: ns-resize;
8003
+ }
8004
+
8005
+ .t0z.interactive {
8006
+ cursor: move;
8007
+ }
8008
+
8009
+ .boundary.interactive,
8010
+ .t0z.interactive {
8046
8011
  filter: url("#shadow-2");
8047
8012
  outline: none;
8048
8013
  }
8049
8014
 
8050
- .interactive:hover {
8015
+ .boundary.interactive:hover,
8016
+ .t0z.interactive:hover {
8051
8017
  filter: url("#shadow-4");
8018
+
8019
+ /* HACK: This gets Safari to correctly apply the filter! */
8020
+ /* https://github.com/emilbjorklund/svg-weirdness/issues/27 */
8021
+ transform: translateX(0);
8052
8022
  }
8053
8023
 
8054
- .interactive:active {
8024
+ .boundary.interactive:active,
8025
+ .t0z.interactive:active {
8055
8026
  filter: url("#shadow-8");
8027
+
8028
+ /* HACK: This gets Safari to correctly apply the filter! */
8029
+ transform: translateY(0);
8056
8030
  }
8057
8031
 
8058
- :host(.keyboard) .interactive:focus {
8032
+ :host(.keyboard) .boundary.interactive:focus,
8033
+ :host(.keyboard) .t0z.interactive:focus {
8059
8034
  filter: url("#shadow-8");
8060
- }
8061
8035
 
8062
- .boundary {
8063
- fill: none;
8064
- stroke: var(---color-element-emphasis);
8065
- stroke-width: 2;
8036
+ /* HACK: This gets Safari to correctly apply the filter! */
8037
+ transform: translateZ(0);
8066
8038
  }
8067
8039
 
8068
- .boundary.interactive {
8069
- cursor: ns-resize;
8040
+ .t0z .point {
8041
+ fill: var(---color-element-emphasis);
8042
+ stroke-width: 0;
8043
+
8044
+ r: 6px;
8070
8045
  }
8071
8046
 
8072
8047
  .drift {
@@ -8080,21 +8055,38 @@
8080
8055
 
8081
8056
  .drift.interactive {
8082
8057
  cursor: ns-resize;
8058
+
8059
+ filter: url("#shadow-2");
8060
+ outline: none;
8061
+
8062
+ /* HACK: This gets Safari to correctly apply the filter! */
8063
+ fill: #000000;
8064
+ fill-opacity: 0;
8083
8065
  }
8084
8066
 
8085
- .drift .arrow {
8086
- stroke-dasharray: none;
8067
+ .drift.interactive:hover {
8068
+ filter: url("#shadow-4");
8069
+
8070
+ /* HACK: This gets Safari to correctly apply the filter! */
8071
+ fill: #ff0000;
8087
8072
  }
8088
8073
 
8089
- .t0z.interactive {
8090
- cursor: move;
8074
+ .drift.interactive:active {
8075
+ filter: url("#shadow-8");
8076
+
8077
+ /* HACK: This gets Safari to correctly apply the filter! */
8078
+ fill: #00ff00;
8091
8079
  }
8092
8080
 
8093
- .t0z .point {
8094
- fill: var(---color-element-emphasis);
8095
- stroke-width: 0;
8081
+ :host(.keyboard) .drift.interactive:focus {
8082
+ filter: url("#shadow-8");
8096
8083
 
8097
- r: 6px;
8084
+ /* HACK: This gets Safari to correctly apply the filter! */
8085
+ fill: #0000ff;
8086
+ }
8087
+
8088
+ .drift .arrow {
8089
+ stroke-dasharray: none;
8098
8090
  }
8099
8091
 
8100
8092
  /* Make larger targets for touch users */
@@ -8456,16 +8448,19 @@
8456
8448
  rem: this.rem
8457
8449
  }]);
8458
8450
  // ENTER
8459
- const svgEnter = svgUpdate.enter().append('svg').classed('main', true).html(AccumulableElement.svgDefs);
8460
- const svgDefs = svgEnter.append('defs');
8451
+ const svgEnter = svgUpdate.enter().append('svg').classed('main', true).each((datum, index, nodes) => {
8452
+ // Filters for shadows
8453
+ B(AccumulableElement.svgFilters, nodes[index]);
8454
+ });
8455
+ const svgMarkers = svgEnter.append('defs').classed('markers', true);
8461
8456
  // Arrowhead marker for measures
8462
8457
  const measureArrow = parameter => {
8463
8458
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
8464
- svgDefs.append('marker').attr('id', `measure-arrow-${parameter}`).attr('class', `measure-arrow ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-10 -6 12 12').attr('refX', '0').attr('refY', '0').attr('markerWidth', '12').attr('markerHeight', '12').append('path').attr('class', 'arrow').attr('d', 'M -7 -3 l 6 3 l -6 3 z');
8459
+ svgMarkers.append('marker').attr('id', `measure-arrow-${parameter}`).attr('class', `measure-arrow ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-10 -6 12 12').attr('refX', '0').attr('refY', '0').attr('markerWidth', '12').attr('markerHeight', '12').append('path').attr('class', 'arrow').attr('d', 'M -7 -3 l 6 3 l -6 3 z');
8465
8460
  };
8466
8461
  const measureCappedArrow = parameter => {
8467
8462
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
8468
- const marker = svgDefs.append('marker').attr('id', `measure-capped-arrow-${parameter}`).attr('class', `measure-arrow capped ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-10 -6 12 12').attr('refX', '0').attr('refY', '0').attr('markerWidth', '12').attr('markerHeight', '12');
8463
+ const marker = svgMarkers.append('marker').attr('id', `measure-capped-arrow-${parameter}`).attr('class', `measure-arrow capped ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-10 -6 12 12').attr('refX', '0').attr('refY', '0').attr('markerWidth', '12').attr('markerHeight', '12');
8469
8464
  marker.append('path').attr('class', 'arrow').attr('d', 'M -7 -3 l 6 3 l -6 3 z');
8470
8465
  marker.append('path').attr('class', 'cap').attr('d', 'M 0 -4 l 0 8');
8471
8466
  };
@@ -8477,12 +8472,12 @@
8477
8472
  // Flat markers for SDs
8478
8473
  const sdCap = outcome => {
8479
8474
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
8480
- svgDefs.append('marker').attr('id', `model-sd-cap-${outcome}`).attr('class', `model-sd cap ${outcome}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-5 -5 10 10').attr('refX', '0').attr('refY', '0').attr('markerWidth', '10').attr('markerHeight', '10').append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('stroke-width', '2').attr('d', 'M 0 -4 l 0 8');
8481
- svgDefs.append('marker').attr('id', `data-sd-cap-${outcome}`).attr('class', `data-sd cap ${outcome}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-5 -5 10 10').attr('refX', '0').attr('refY', '0').attr('markerWidth', '10').attr('markerHeight', '10').append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('stroke-width', '2').attr('d', 'M 0 -3 l 0 6');
8475
+ svgMarkers.append('marker').attr('id', `model-sd-cap-${outcome}`).attr('class', `model-sd cap ${outcome}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-5 -5 10 10').attr('refX', '0').attr('refY', '0').attr('markerWidth', '10').attr('markerHeight', '10').append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('stroke-width', '2').attr('d', 'M 0 -4 l 0 8');
8476
+ svgMarkers.append('marker').attr('id', `data-sd-cap-${outcome}`).attr('class', `data-sd cap ${outcome}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-5 -5 10 10').attr('refX', '0').attr('refY', '0').attr('markerWidth', '10').attr('markerHeight', '10').append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('stroke-width', '2').attr('d', 'M 0 -3 l 0 6');
8482
8477
  };
8483
8478
  sdCap('error');
8484
8479
  sdCap('correct');
8485
- const gradient = svgDefs.append('linearGradient').attr('id', 'path-animate').attr('gradientUnits', 'userSpaceOnUse').attr('color-interpolation', 'linearRGB').attr('x1', '0').attr('x2', '0').attr('y1', evidenceScale(this.bounds.upper)).attr('y2', evidenceScale(this.bounds.lower));
8480
+ const gradient = svgMarkers.append('linearGradient').attr('id', 'path-animate').attr('gradientUnits', 'userSpaceOnUse').attr('color-interpolation', 'linearRGB').attr('x1', '0').attr('x2', '0').attr('y1', evidenceScale(this.bounds.upper)).attr('y2', evidenceScale(this.bounds.lower));
8486
8481
  gradient.append('stop').classed('stop-0', true).attr('offset', '0%');
8487
8482
  gradient.append('stop').classed('stop-100', true).attr('offset', '100%');
8488
8483
  // MERGE