cm-chessboard 8.7.11 → 8.9.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.
@@ -1,49 +1,47 @@
1
- .cm-chessboard .arrow-default .arrow-head {
2
- fill: blue;
1
+ .cm-chessboard .arrow-warning .arrow-head {
2
+ fill: orange;
3
3
  fill-rule: nonzero;
4
- fill-opacity: 1; }
5
-
6
- .cm-chessboard .arrow-default .arrow-line {
7
- stroke: blue;
4
+ }
5
+ .cm-chessboard .arrow-warning .arrow-line {
6
+ stroke: orange;
8
7
  stroke-linecap: round;
9
- opacity: 0.5; }
10
-
8
+ opacity: 0.6;
9
+ }
11
10
  .cm-chessboard .arrow-danger .arrow-head {
12
11
  fill: red;
13
12
  fill-rule: nonzero;
14
- fill-opacity: 1; }
15
-
13
+ }
16
14
  .cm-chessboard .arrow-danger .arrow-line {
17
15
  stroke: red;
18
16
  stroke-linecap: round;
19
- opacity: 0.5; }
20
-
21
- .cm-chessboard .arrow-pointy .arrow-head {
22
- fill: black;
17
+ opacity: 0.5;
18
+ }
19
+ .cm-chessboard .arrow-success .arrow-head {
20
+ fill: green;
23
21
  fill-rule: nonzero;
24
- fill-opacity: 1; }
25
-
26
- .cm-chessboard .arrow-pointy .arrow-line {
27
- stroke: black;
22
+ }
23
+ .cm-chessboard .arrow-success .arrow-line {
24
+ stroke: green;
28
25
  stroke-linecap: round;
29
- opacity: 0.5; }
30
-
31
- /* custom colors for RightClickAnnotator */
32
- .cm-chessboard .arrow-green .arrow-head {
33
- fill: #2e7d32; /* green */
26
+ opacity: 0.5;
27
+ }
28
+ .cm-chessboard .arrow-info .arrow-head {
29
+ fill: blue;
34
30
  fill-rule: nonzero;
35
- fill-opacity: 1; }
36
- .cm-chessboard .arrow-green .arrow-line {
37
- stroke: #2e7d32;
38
- stroke-linecap: round;
39
- opacity: 0.5; }
40
- .cm-chessboard .arrow-orange .arrow-head {
41
- fill: #ff9800; /* orange */
31
+ }
32
+ .cm-chessboard .arrow-info .arrow-line {
33
+ stroke: blue;
34
+ stroke-linecap: butt;
35
+ opacity: 0.4;
36
+ }
37
+ .cm-chessboard .arrow-neutral .arrow-head {
38
+ fill: black;
42
39
  fill-rule: nonzero;
43
- fill-opacity: 1; }
44
- .cm-chessboard .arrow-orange .arrow-line {
45
- stroke: #ff9800;
40
+ }
41
+ .cm-chessboard .arrow-neutral .arrow-line {
42
+ stroke: black;
46
43
  stroke-linecap: round;
47
- opacity: 0.5; }
44
+ opacity: 0.5;
45
+ }
48
46
 
49
- /*# sourceMappingURL=arrows.css.map */
47
+ /*# sourceMappingURL=arrows.css.map */
@@ -1,9 +1 @@
1
- {
2
- "version": 3,
3
- "file": "arrows.css",
4
- "sources": [
5
- "arrows.scss"
6
- ],
7
- "names": [],
8
- "mappings": "AAAA,AAEI,cAFU,CACZ,cAAc,CACZ,WAAW,CAAC;EACV,IAAI,EAAE,IAAI;EACV,SAAS,EAAE,OAAO;EAClB,YAAY,EAAE,CAAC,GAChB;;AANL,AAOI,cAPU,CACZ,cAAc,CAMZ,WAAW,CAAC;EACV,MAAM,EAAE,IAAI;EACZ,cAAc,EAAE,KAAK;EACrB,OAAO,EAAE,GAAG,GACb;;AAXL,AAcI,cAdU,CAaZ,aAAa,CACX,WAAW,CAAC;EACV,IAAI,EAAE,GAAG;EACT,SAAS,EAAE,OAAO;EAClB,YAAY,EAAE,CAAC,GAChB;;AAlBL,AAmBI,cAnBU,CAaZ,aAAa,CAMX,WAAW,CAAC;EACV,MAAM,EAAE,GAAG;EACX,cAAc,EAAE,KAAK;EACrB,OAAO,EAAE,GAAG,GACb;;AAvBL,AA0BI,cA1BU,CAyBZ,aAAa,CACX,WAAW,CAAC;EACV,IAAI,EAAE,KAAK;EACX,SAAS,EAAE,OAAO;EAClB,YAAY,EAAE,CAAC,GAChB;;AA9BL,AA+BI,cA/BU,CAyBZ,aAAa,CAMX,WAAW,CAAC;EACV,MAAM,EAAE,KAAK;EACb,cAAc,EAAE,KAAK;EACrB,OAAO,EAAE,GAAG,GACb"
9
- }
1
+ {"version":3,"sourceRoot":"","sources":["arrows.scss"],"names":[],"mappings":"AAEI;EACE;EACA;;AAEF;EACE;EACA;EACA;;AAIF;EACE;EACA;;AAEF;EACE;EACA;EACA;;AAIF;EACE;EACA;;AAEF;EACE;EACA;EACA;;AAIF;EACE;EACA;;AAEF;EACE;EACA;EACA;;AAIF;EACE;EACA;;AAEF;EACE;EACA;EACA","file":"arrows.css"}
@@ -1,21 +1,19 @@
1
1
  .cm-chessboard {
2
- .arrow-default {
2
+ .arrow-warning {
3
3
  .arrow-head {
4
- fill: blue;
4
+ fill: orange;
5
5
  fill-rule: nonzero;
6
- fill-opacity: 1;
7
6
  }
8
7
  .arrow-line {
9
- stroke: blue;
8
+ stroke: orange;
10
9
  stroke-linecap: round;
11
- opacity: 0.5;
10
+ opacity: 0.6;
12
11
  }
13
12
  }
14
13
  .arrow-danger {
15
14
  .arrow-head {
16
15
  fill: red;
17
16
  fill-rule: nonzero;
18
- fill-opacity: 1;
19
17
  }
20
18
  .arrow-line {
21
19
  stroke: red;
@@ -23,11 +21,32 @@
23
21
  opacity: 0.5;
24
22
  }
25
23
  }
26
- .arrow-pointy {
24
+ .arrow-success {
25
+ .arrow-head {
26
+ fill: green;
27
+ fill-rule: nonzero;
28
+ }
29
+ .arrow-line {
30
+ stroke: green;
31
+ stroke-linecap: round;
32
+ opacity: 0.5;
33
+ }
34
+ }
35
+ .arrow-info {
36
+ .arrow-head {
37
+ fill: blue;
38
+ fill-rule: nonzero;
39
+ }
40
+ .arrow-line {
41
+ stroke: blue;
42
+ stroke-linecap: butt;
43
+ opacity: 0.4;
44
+ }
45
+ }
46
+ .arrow-neutral {
27
47
  .arrow-head {
28
48
  fill: black;
29
49
  fill-rule: nonzero;
30
- fill-opacity: 1;
31
50
  }
32
51
  .arrow-line {
33
52
  stroke: black;
@@ -51,10 +51,10 @@ console.log(chessboard.getArrows())
51
51
  assetsUrl: "../../assets/",
52
52
  extensions: [{class: Arrows}]
53
53
  })
54
- chessboard.addArrow(ARROW_TYPE.default, "f3", "d5")
55
- chessboard.addArrow(ARROW_TYPE.default, "b8", "c6")
56
- chessboard.addArrow(ARROW_TYPE.pointy, "d2", "d3")
57
- chessboard.addArrow(ARROW_TYPE.danger, "g5", "e6")
54
+ chessboard.addArrow(ARROW_TYPE.danger, "f3", "d5")
55
+ chessboard.addArrow(ARROW_TYPE.info, "b8", "c6")
56
+ chessboard.addArrow(ARROW_TYPE.success, "d2", "d3")
57
+ chessboard.addArrow(ARROW_TYPE.warning, "g5", "e6")
58
58
  console.log(chessboard.getArrows())
59
59
 
60
60
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "8.7.11",
3
+ "version": "8.9.0",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -5,13 +5,14 @@
5
5
  */
6
6
 
7
7
  import {Extension, EXTENSION_POINT} from "../../model/Extension.js"
8
- import {Svg} from "../../lib/Svg.js"
9
8
  import {Utils} from "../../lib/Utils.js"
10
9
 
11
10
  export const ARROW_TYPE = {
12
- default: {class: "arrow-default", slice: "arrowDefault", headSize: 7},
13
- danger: {class: "arrow-danger", slice: "arrowDefault", headSize: 7},
14
- pointy: {class: "arrow-pointy", slice: "arrowPointy", headSize: 7},
11
+ default: {class: "arrow-success"},
12
+ success: {class: "arrow-success"},
13
+ warning: {class: "arrow-warning"},
14
+ info: {class: "arrow-info"},
15
+ danger: {class: "arrow-danger"}
15
16
  }
16
17
 
17
18
  export class Arrows extends Extension {
@@ -24,10 +25,8 @@ export class Arrows extends Extension {
24
25
  })
25
26
  this.props = {
26
27
  sprite: "extensions/arrows/arrows.svg",
27
- // offset factors relative to half the square size (0.0 .. 1.0)
28
- // 0.0 = start/end in the center; 1.0 = at the outer edge of the inscribed circle (half the square)
29
- // default chosen to preserve previous appearance where radius = 0.36 * min(squareWidth, squareHeight)
30
- // which corresponds to 0.72 of half the square size (0.36 / 0.5 = 0.72)
28
+ slice: "arrowDefault",
29
+ headSize: 7,
31
30
  offsetFrom: 0,
32
31
  offsetTo: 0.55
33
32
  }
@@ -63,8 +62,8 @@ export class Arrows extends Extension {
63
62
  const id = "arrow-" + arrow.from + arrow.to
64
63
  const marker = Svg.addElement(defs, "marker", {
65
64
  id: id,
66
- markerWidth: arrow.type.headSize,
67
- markerHeight: arrow.type.headSize,
65
+ markerWidth: this.props.headSize,
66
+ markerHeight: this.props.headSize,
68
67
  refX: 20,
69
68
  refY: 20,
70
69
  viewBox: "0 0 40 40",
@@ -73,7 +72,7 @@ export class Arrows extends Extension {
73
72
  })
74
73
 
75
74
  Svg.addElement(marker, "use", {
76
- href: `${spriteUrl}#${arrow.type.slice}`,
75
+ href: `${spriteUrl}#${this.props.slice}`,
77
76
  })
78
77
 
79
78
  // Compute centers of start and end squares
@@ -14,16 +14,11 @@ import {Markers, MARKER_TYPE} from "../markers/Markers.js"
14
14
  import {Svg} from "../../lib/Svg.js"
15
15
 
16
16
  export const ARROW_TYPE = {
17
- default: {class: "arrow-default", slice: "arrowDefault", headSize: 7},
18
- danger: {class: "arrow-danger", slice: "arrowDefault", headSize: 7}
17
+ warning: { class: "arrow-warning", slice: "arrowDefault", headSize: 7}
19
18
  }
19
+ export const MARKER_TYPE = {
20
20
 
21
- // Define persistent type objects for matching (strict equality used in core extensions)
22
- const ARROW_GREEN = {class: "arrow-green", slice: "arrowDefault", headSize: 7}
23
- const ARROW_ORANGE = {class: "arrow-orange", slice: "arrowDefault", headSize: 7}
24
-
25
- const CIRCLE_GREEN = {class: "marker-circle-green", slice: "markerCircle"}
26
- const CIRCLE_ORANGE = {class: "marker-circle-orange", slice: "markerCircle"}
21
+ }
27
22
 
28
23
  export class RightClickAnnotator extends Extension {
29
24
  constructor(chessboard, props = {}) {
@@ -237,7 +232,7 @@ export class RightClickAnnotator extends Extension {
237
232
  if (modifiers.shift && modifiers.alt) return "orange"
238
233
  if (modifiers.shift) return "red"
239
234
  if (modifiers.alt) return "blue"
240
- return "green"
235
+ return "orange"
241
236
  }
242
237
 
243
238
  typesForColorKey(colorKey) {