Don't hardcode size and layout of board component #244
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to make the component more flexible and easier to integrate into any website layout.
Currently, the size and layout of the board component are hardcoded and can only be changed by overriding the component's CSS.
What is currently hardcoded in the component:
.cg-wrap { width: 700px; height: 700px; }
width: 90vh;
margin-inline: auto;
Since the size of the
cg-container
is enforced by the chess-ground library to be a multiple of 8, it is possible that the wrapper divcg-wrap
is bigger by at most 7px in both dimensions. This gap used to be only on the left and bottom but in my opinion, it looks better when it is evenly distributed on all 4 sides. That's why I changed thecg-wrap
's display toflex
and centred its contents. Let me know if you think this can lead to some issues.The suggested changes require the user to provide reasonable definitions for the size of the component (there is no default size).
If no user-supplied CSS is provided, it tries to take up as much of the width as possible, while potentially cutting off parts of the bottom half of the board if the page is in landscape mode. See:
This is probably a breaking change, in the sense that, updating might change the looks of the website.
Let me know what you think! I'm sure we can work out a solution.