Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need a property to provide custom styles on specific board squares. #26

Closed
csharptest opened this issue Jul 17, 2018 · 4 comments
Closed

Comments

@csharptest
Copy link

Use case:
In order to display possible valid/legal moves, moves resulting in threats, best moves, and other analytical display, I'd like to be able to use a prop to customize specific board squares. Thus the following would render the g5 square as solid red:

      <Chessboard
        id="board"
        position={this.state.fen}
        width={320}
        squareStyles={{
          g5: { backgroundColor: "red" }
        }}
        ... />

This could, in time, deprecate the use of selectedSquareStyle and selectedSquares since it would allow customization of board display in a number of ways. I would recommend retooling these two properties to simply overwrite (or merge) the value of squareStyles for each entry in selectedSquares with the value of selectedSquareStyle. This should reduce the maintenance of the two similar features.

@willb335
Copy link
Owner

Thanks for putting all of this out at once. It would be nice to get all these features out in one release.

This is very straightforward; I prefer this approach over selectedSquares. It seems squareStyles as you have it is flexible and easy to implement

@willb335
Copy link
Owner

Take a look at Square.js in the following commit. It was an easy change that allowed me to delete selectedSquareStyle and squareStyles. It's a much clearer way to style squares.

Thanks for the recommendation!

42c1ddf

@willb335
Copy link
Owner

@willb335
Copy link
Owner

In release 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants