Have a look at https://chessboardjs.com/ to have an idea of this component.
Yet far to be complete, I built an Anvil’s custom component that should be a wrapper over Chessboard.js properties, methods and events explained in their Examples page.
The exercise was not easy at all .
Here’s my CopyApp link for the component’s demo:
I think this is a pretty cool component to share, maybe someone can build something interesting on it.
Notes for myself on things still to complete, to clarify, to improve or to understand better:
- Put in MIT License’s preservation of copyright and license notices
- Complete with all the properties, methods, events and error handling listed in their Docs page
- question on Anvil Custom Component’s event names: all events in Anvil are named like “x-eventname” but when you name a custom event in a custom component you cannot use the “-”: it gets converted to “_”. So my events are all named like “x_onchange”. Not a big problem, I am just curious to know why.
- question on Anvil Custom Component’s properties declaration: I declared a “config” property on the custom component’s config form (CCCF), but in the code I defined also a “position” property. Form1 (the caller of the custom component) has no trouble at all at setting and reading “position” property too, despite it’s not defined. So I wonder what’s the CCCF useful for.
- flip doesn’t work
position property setter calls a JS function that can have 1 or 2 parameters. I wanted (but wasn’t able) to translate this into property setting (so I had to create
set_position_instantlymethod to accomodate the 2 parameters version). Is there a more elegant way to do that?
config management: I decided to expose an object in the
configproperty to mimic chessboardjs. Maybe I should expose the single properties.
- find a PGN Management and chess game management component to integrate, like the chess.js library.