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

grid: don't overwrite nested graph label positions #1345

Merged

Conversation

gavin-ts
Copy link
Contributor

@gavin-ts gavin-ts commented May 26, 2023

Summary

Fixes grid layout "initializing" label and icon positions even if a nestedGraph layout already positioned them.

Details

  • if a grid cell contains a nested graph, layout will run and position the cells label and/or icon, so we shouldn't overwrite that
  • adds grid_icons test
  • In the test below, the container label positions were incorrectly being overwritten
  • This also adds spacing for these labels when it would conflict with the grid's label
  • Icons are now also considered for this spacing
  • factors out some d2graph methods into d2graph/layout.go

before/after

_Users_gavinnishizawa_github_repos_d2_e2etests_out_e2e_report html (3)

grid_icons before/after

Screen Shot 2023-05-30 at 1 32 51 PM

@gavin-ts gavin-ts force-pushed the grid-only-place-label-if-unplaced branch from fc7dc8a to 5165a39 Compare May 27, 2023 00:56
@gavin-ts gavin-ts requested a review from alixander May 27, 2023 01:02
@gavin-ts gavin-ts marked this pull request as ready for review May 27, 2023 01:02
@gavin-ts gavin-ts enabled auto-merge May 27, 2023 01:02
Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a grid cell contains a nested graph, layout will run and position the cells label and/or icon,

can the test include an icon example?

d2graph/d2graph.go Outdated Show resolved Hide resolved
d2graph/d2graph.go Outdated Show resolved Hide resolved
d2layouts/d2grid/layout.go Outdated Show resolved Hide resolved
d2layouts/d2grid/layout.go Outdated Show resolved Hide resolved
d2layouts/d2grid/layout.go Outdated Show resolved Hide resolved
@gavin-ts gavin-ts force-pushed the grid-only-place-label-if-unplaced branch from 5165a39 to ad44eff Compare May 30, 2023 18:28
@gavin-ts
Copy link
Contributor Author

can the test include an icon example?

added a test for icons and fixed the layouts to account for icons

Screen Shot 2023-05-30 at 1 32 51 PM

@gavin-ts gavin-ts requested a review from alixander May 30, 2023 20:38
@gavin-ts gavin-ts merged commit ba3e43a into terrastruct:master May 31, 2023
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.

2 participants