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

Add Optional Coordinate Labels to the Grid #71

Merged
merged 2 commits into from
Mar 21, 2023

Conversation

coreyja
Copy link
Sponsor Member

@coreyja coreyja commented Mar 19, 2023

This PR implements the feature that was discussed in this Feedback item: https://github.com/orgs/BattlesnakeOfficial/discussions/231

Now there is a settings toggle that enabled this rows and columns to have a numerical label, to ease finding the correct coordinate, and debugging!

If we have the showCoordinateLabels option enabled, make the Grid inside
smaller, so that we have room for the labels.

The labels are rendered inside Grid but OUTSIDE it's SVGs bounding box.
We allow the SVG to overflow so that the labels are visible, when the option
is set.
This allowed us to use -1 for the row/col where the labels went and means
we didn't need to modify the rest of the grid generation for this PR.

To get the text centered nicely in the cell, we use a foreignObject
and HTML + CSS. SVGs don't seem to support text styling as well as HTML,
and foreignObject seems supported in all non-IE browsers

Screenshot:
image

We have a checkbox on the settings page that can round trip through
Local Storage nicely

Also touched up the README a bit, since I missed the part about the port
at first so moved added it to the sentence I was reading
First we adjust the size of the `Grid` we are going to render within `Board`

If we have the `showCoordinateLabels` option enabled, make the `Grid` inside
smaller, so that we have room for the labels.

The labels are rendered inside `Grid` but OUTSIDE it's SVGs bounding box.
We allow the SVG to overflow so that the labels are visible, when the option
is set.
This allowed us to use `-1` for the row/col where the labels went and means
we didn't need to modify the rest of the grid generation for this PR.

To get the text centered nicely in the cell, we use a `foreignObject`
and HTML + CSS. SVGs don't seem to support text styling as well as HTML,
and foreignObject seems supported in all non-IE browsers
@bvanvugt
Copy link
Sponsor Member

Very slick!

@alexandramartinez
Copy link

omg you're the best! <3

@bvanvugt bvanvugt merged commit cecb3f6 into BattlesnakeOfficial:main Mar 21, 2023
@coreyja coreyja deleted the ca/main/coordinate-labels branch March 21, 2023 14:35
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

Successfully merging this pull request may close these issues.

None yet

3 participants