cm-chessboard 8.7.5 → 8.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "8.7.5",
3
+ "version": "8.7.7",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -6,16 +6,9 @@
6
6
 
7
7
  Adds a marker on a square.
8
8
 
9
- Default types are: `MARKER_TYPE.frame`, `MARKER_TYPE.square`, `MARKER_TYPE.dot`, `MARKER_TYPE.circle` exportet
9
+ Default types are: `MARKER_TYPE.frame`, `MARKER_TYPE.square`, `MARKER_TYPE.dot`, `MARKER_TYPE.circle` exported
10
10
  by `Chessboard.js`.
11
11
 
12
- #### You can create your own marker types:
13
-
14
- Just create an object like `const myMarker = {class: "markerCssClass", slice: "markerSliceId"}`, where `class` is the
15
- css class of the marker for styling
16
- and `slice` is the `id` in `sprite.svg`. See also [Create your own custom markers](#create-your-own-custom-markers)
17
- below.
18
-
19
12
  [Example for **addMarker**, **getMarkers** and
20
13
  **removeMarkers**](https://shaack.com/projekte/cm-chessboard/examples/extensions/markers-extension.html)
21
14
 
@@ -25,7 +18,8 @@ Returns the board's markers as an array.
25
18
 
26
19
  Only set type, to get all markers of a type on the board. Set type to `undefined`, to get markers of all types on a
27
20
  square.
28
- Set `both` to `undefined` to get all markers on the board.
21
+
22
+ Set both to `undefined` (or don't set them at all) to get all markers on the board.
29
23
 
30
24
  ### removeMarkers(type = undefined, square = undefined)
31
25
 
@@ -36,11 +30,12 @@ of markers from a square. Call without parameters to remove all markers from the
36
30
 
37
31
  ## Create your own custom markers
38
32
 
39
- The ability to add custom markers is build in. You can use the existing
40
- marker shapes in the SVG sprite and create your own markers with just css or create
41
- your own custom SVG shapes. With a program like InkScape or Sketch this should be relatively easy.
33
+ Just create an object like `const myMarker = {class: "markerCssClass", slice: "markerSliceId"}`, where `class` is the
34
+ css class of the marker for styling and `slice` is the `id` in `sprite.svg`.
35
+
36
+ ### Example
42
37
 
43
- Example: The markerCircle is defined in the SVG like this.
38
+ The markerCircle is defined in the SVG as a circle with a radius of 18:
44
39
 
45
40
  ```svg
46
41
 
@@ -49,27 +44,9 @@ Example: The markerCircle is defined in the SVG like this.
49
44
  </g>
50
45
  ```
51
46
 
52
- It's a circle with the radius 18 and its center at 20/20.
53
-
54
- Important is the id "markerCircle". You can set the marker
55
- with `board.addMarker({class: "markerSquare", slice: "markerSquare"}, "e4")`
56
- "emphasize" is the css class, which defines the color and opacity of the marker. "slice" is the id of the marker in the
57
- SVG. This is
58
- also demonstrated in
59
- the [mark squares example](https://shaack.com/projekte/cm-chessboard/examples/extensions/markers-extension.html)
60
- .
61
-
62
- The color and stroke-width of the marker is defined in the css (or scss). You could also define your marker completely
63
- in the sprite, but then that is not so flexible.
64
-
65
- These are the css styles of the markers "markerSquare" and "markerCircleRed".
47
+ Has this CSS, where stroke color, width and opacity are defined:
66
48
 
67
49
  ```css
68
- marker.marker-square {
69
- fill: black;
70
- opacity: 0.11;
71
- }
72
-
73
50
  marker.marker-circle-red {
74
51
  stroke: #aa0000;
75
52
  stroke-width: 3px;
@@ -77,15 +54,10 @@ marker.marker-circle-red {
77
54
  }
78
55
  ```
79
56
 
80
- So you can simply add a marker with the id `myMarkerIdInSvg` to the SVG, and add the class `myMarkerCssClass` to the
81
- css. Then you can show it on the field "e4" with
82
-
83
- `addMarker({class: "myMarkerCssClass", slice: "myMarkerIdInSvg"}, "e4")`
84
-
85
- To allow easy removing of the marker, you have to define the marker type in your code.
57
+ And is used like this in your JavaScript:
86
58
 
87
59
  ```js
88
- const myMarkerType = {class: "myMarkerCssClass", slice: "myMarkerIdInSvg"}
60
+ const myMarkerType = {class: "marker-circle-red", slice: "markerCircle"}
89
61
  // add
90
62
  chessboard.addMarker(myMarkerType, "e4")
91
63
  // remove a specific marker