shaack / cm-chessboard

A JavaScript chessboard without dependencies. Rendered in SVG, coded in ES6. Views FEN, handles move input, animated, responsive, expandable
MIT License
216 stars 68 forks source link

Allow no border #31

Closed LandonSchropp closed 3 years ago

LandonSchropp commented 3 years ago

I'm trying to disable the border, but the style.showBorder setting doesn't seem to work. For example, here's what I get with my current config:

{
  "responsive": true,
  "moveInputMode": 1,
  "sprite": {
    "url": "/static/chessboard-sprite-7ae4df542523aef7007536d2a99557d0.svg"
  },
  "style": {
    "showCoordinates": false,
    "showBorder": false
  },
  "position": "8/8/8/8/8/8/8/8 w KQkq - 0 1"
}
Screen Shot 2021-03-15 at 6 37 01 PM

I would just hide the border with CSS, but the squares are still offset from 0,0, so my board would't align to other elements in my UI.

LandonSchropp commented 3 years ago

Shouldn't borderSize on this line be set to 0?

shaack commented 3 years ago

There's something to that. With "border", however, the wide margin is meant, in which the coordinates are then also, as on the page: https://shaack.com/projekte/cm-chessboard/examples/styles.html

So there should be three types of border: none, a thin one and the wide one. I would say the property "showBorder" should be renamed to "border" and then "none", "thin", "wide" as parameters or something like that.

LandonSchropp commented 3 years ago

That makes sense. Or, as an alternative, you could make the border size configurable with parameters like 5px or 10% as well.

shaack commented 3 years ago

With 3.7.0 (https://github.com/shaack/cm-chessboard/commit/ddf5db7c190668afa6bea5530f6db2331283ca9b) you can now set the props.style.borderType to BORDER_TYPE.none or just "none". (showBorder is now deprecated, it was illogical) Example: https://shaack.com/projekte/cm-chessboard/examples/styles.html (boards 4 & 5) The width of the border should be configureable via css, I think. Thanks for your suggestion! I think it's better now.

LandonSchropp commented 3 years ago

Awesome! Thank you!