mliebelt / pgn-viewer

Simple PGN viewer with the necessary features to display chess games
GNU General Public License v3.0
161 stars 44 forks source link

Fix board CSS class manipulation #504

Closed joanlopez closed 7 months ago

joanlopez commented 7 months ago

Similar to https://github.com/mliebelt/pgn-viewer/pull/476, but more generically, it fixes the board CSS class manipulation for the following (on top of piece style):

If I'm not wrong, all of them are now using divBoard.classList.add, which makes it end up in a situation where more than one exclusive value is present (more details in the aforementioned pull request), breaking the application.

You'll see I did the trick with a some TypeScript generics, in order to re-use code, but I'd be happy to simplify if by copy-pasting one function for each type. Similar for the enums, and for the heuristics. I'll be happy to apply any code suggestion you have that achieves the same behavior, but that's the best I could do so far.

I hope it helps! At least, it would really unblock the use I'm planning to for this amazing library! 💟

Thanks!

mliebelt commented 7 months ago

Thank you for fixing that, it will go into the next minor version then. Don't know when that will be done ...