cm-chessboard 8.1.2 → 8.1.4

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.
@@ -14,17 +14,30 @@
14
14
  <pre>
15
15
  new Chessboard(document.getElementById("board"), {
16
16
  position: FEN.start,
17
- style: {aspectRatio: 0.9}
17
+ assetsUrl: "../assets/",
18
+ style: {
19
+ aspectRatio: 0.9,
20
+ pieces: {file: "pieces/staunty.svg"},
21
+ borderType: BORDER_TYPE.frame
22
+ },
23
+ extensions: [{class: AutoBorderNone}]
18
24
  })
19
25
  </pre>
26
+ <p>Also uses the "AutoBorderNone" extension to switch off the frame border below 560px width.</p>
20
27
  <script type="module">
21
- import {Chessboard} from "../src/Chessboard.js"
28
+ import {BORDER_TYPE, Chessboard} from "../src/Chessboard.js"
22
29
  import {FEN} from "../src/model/Position.js"
30
+ import {AutoBorderNone} from "../src/extensions/auto-border-none/AutoBorderNone.js"
23
31
 
24
32
  new Chessboard(document.getElementById("board"), {
25
33
  position: FEN.start,
26
34
  assetsUrl: "../assets/",
27
- style: {aspectRatio: 0.9, pieces: {file: "pieces/staunty.svg"}}
35
+ style: {
36
+ aspectRatio: 0.9,
37
+ pieces: {file: "pieces/staunty.svg"},
38
+ borderType: BORDER_TYPE.frame
39
+ },
40
+ extensions: [{class: AutoBorderNone}]
28
41
  })
29
42
  </script>
30
43
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cm-chessboard",
3
- "version": "8.1.2",
3
+ "version": "8.1.4",
4
4
  "description": "A JavaScript chessboard which is lightweight, ES6 module based, responsive, SVG rendered and without dependencies.",
5
5
  "keywords": [
6
6
  "chess",
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Author and copyright: Stefan Haack (https://shaack.com)
3
+ * Repository: https://github.com/shaack/cm-chessboard
4
+ * License: MIT, see file 'LICENSE'
5
+ */
6
+ import {Extension, EXTENSION_POINT} from "../../model/Extension.js"
7
+
8
+ export class AutoBorderNone extends Extension {
9
+ constructor(chessboard, props = {}) {
10
+ super(chessboard)
11
+ this.props = {
12
+ chessboardBorderType: chessboard.props.style.borderType,
13
+ borderNoneBelow: 550 // pixels width of the board, where the border is set to none
14
+ }
15
+ Object.assign(this.props, props)
16
+ this.registerExtensionPoint(EXTENSION_POINT.beforeRedrawBoard, this.extensionPointBeforeRedrawBoard.bind(this))
17
+ }
18
+ extensionPointBeforeRedrawBoard() {
19
+ if(this.chessboard.view.width < this.props.borderNoneBelow){
20
+ this.chessboard.props.style.borderType = "none"
21
+ } else {
22
+ this.chessboard.props.style.borderType = this.props.chessboardBorderType
23
+ }
24
+ }
25
+ }
@@ -1,9 +1,8 @@
1
1
  /**
2
- * Authors and copyright: Laura Campo Alberca (@lauracampoalberca) and Stefan Haack (@shaack)
2
+ * Author and copyright: Stefan Haack (https://shaack.com)
3
3
  * Repository: https://github.com/shaack/cm-chessboard
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
-
7
6
  import {Extension} from "../../model/Extension.js"
8
7
 
9
8
  export class HtmlLayer extends Extension {
@@ -1,9 +1,8 @@
1
1
  /**
2
- * Authors and copyright: Laura Campo Alberca (@lauracampoalberca) and Stefan Haack (@shaack)
2
+ * Author and copyright: Stefan Haack (https://shaack.com)
3
3
  * Repository: https://github.com/shaack/cm-chessboard
4
4
  * License: MIT, see file 'LICENSE'
5
5
  */
6
-
7
6
  import {Extension, EXTENSION_POINT} from "../../model/Extension.js"
8
7
  import {Svg} from "../../lib/Svg.js"
9
8
  import {INPUT_EVENT_TYPE} from "../../Chessboard.js"