Skip to content

fix: expose anchor size CSS variables - #336

Draft
draedful wants to merge 1 commit into
mainfrom
codex/fix-329-anchor-css-variables
Draft

fix: expose anchor size CSS variables#336
draedful wants to merge 1 commit into
mainfrom
codex/fix-329-anchor-css-variables

Conversation

@draedful

@draedful draedful commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • provide default --graph-block-anchor-width and --graph-block-anchor-height values on the graph wrapper
  • consume the size variables without fallback declarations while preserving CSS overrides
  • document anchor sizing and add browser regression coverage for defaults and overrides

Root cause

Anchor coordinates were exposed as concrete CSS custom-property values, while width and height existed only as fallbacks inside var(...). As a result, consumers could not read default values from the custom properties and CSS processing could emit duplicate width and height declarations.

Impact

The rendered anchor size remains 16px × 16px by default. Consumers can continue overriding either dimension through the CSS cascade; no inline values are introduced.

Validation

  • CI=1 npx playwright test e2e/tests/anchor/anchor-css-variables.spec.ts
  • npm run typecheck
  • npm run lint
  • npm test -- --runInBand
  • git diff --check

Fixes #329

Summary by Sourcery

Expose and default anchor size CSS variables while documenting and testing their usage.

Bug Fixes:

  • Ensure anchor width and height CSS variables are properly exposed with default values on the graph wrapper to avoid duplicate declarations and allow consumers to read them.

Enhancements:

  • Simplify anchor sizing CSS by relying directly on the exposed custom properties for width and height.

Documentation:

  • Document how to configure anchor size via CSS variables in the React usage guide.

Tests:

  • Add Playwright end-to-end tests to verify default anchor size variables and consumer overrides for width and height.

@sourcery-ai

sourcery-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR centralizes default anchor sizing on the graph wrapper via CSS variables, updates the anchor styles to always consume those variables directly (no fallbacks), documents how to size anchors, and adds Playwright coverage to verify default and overridden anchor dimensions via CSS custom properties.

File-Level Changes

Change Details Files
Anchor component now relies solely on CSS custom properties for width/height instead of embedding fallback values.
  • Replaced var(...) usages for internal --width/--height with references to --graph-block-anchor-width and --graph-block-anchor-height without fallbacks.
  • Updated width and height declarations on the anchor element to use --graph-block-anchor-width and --graph-block-anchor-height directly, removing inline fallback sizes.
src/react-components/Anchor.css
Graph wrapper now exposes default anchor size via CSS variables.
  • Defined --graph-block-anchor-width and --graph-block-anchor-height defaults (16px) on the .graph-wrapper container.
  • Ensured layout-related styles on .graph-wrapper remain unchanged.
src/react-components/graph-canvas.css
Anchor sizing via CSS variables is documented and covered by e2e tests.
  • Extended usage docs to show overriding --graph-block-anchor-width and --graph-block-anchor-height in consumer CSS.
  • Added Playwright tests to assert default anchor width/height custom property values and corresponding computed sizes.
  • Added Playwright tests to assert that consumer overrides of anchor width/height via CSS custom properties propagate to computed styles.
docs/react/usage.md
e2e/tests/anchor/anchor-css-variables.spec.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#329 Expose CSS custom properties --graph-block-anchor-width and --graph-block-anchor-height with default values for anchor size so consumers can read and override them.
#329 Use the anchor size CSS variables consistently in the anchor styles without redundant hardcoded width/height declarations.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gravity-ui-bot

Copy link
Copy Markdown
Contributor

Preview is ready.

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.

Missing css-variables of graph-block-anchor for width and height

2 participants