Repository navigation
Extracted Graph.js SVG setup into typed GraphCanvas component - #1823
Merged
Merged
Conversation
Moves the root <svg> element, viewBox calculation, and shared filter/marker definitions out of Graph.js into GraphCanvas.tsx, with the graph contents passed in as children. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 41320918833Coverage increased (+0.05%) to 60.654%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed Changes
Graph.jsis still a large class component. This pulls the root<svg>setup out into its own typed functional component, as a step towards breaking it up and converting it to TypeScript.Added
js/components/graph/GraphCanvas.tsx, which owns:<svg id="main-graph">element and its attributes<defs>block with the shared node drop-shadow filter,#arrowHeadmarker and#blur-filter(previously split across two<defs>plus a loose<filter>)childrenExported
NODE_DROPSHADOW_FILTER_IDfromGraphCanvas.tsx, replacingthis.nodeDropshadowFilterinGraph.jsRemoved
renderArrowHead,renderEllipseBlurFilterand the inline viewBox math fromGraph.js.Graphstill chooses whether to pass the draw or the pan mouse handlers.Kept the
xmlns:*andversionattributes, with a comment explaining that they only matter if the SVG markup is serialized (e.g. for export)Added
js/components/graph/__tests__/GraphCanvas.test.js, which checks the exact viewBox in three cases:#generateRoot(Generate page)#react-graphcontainerIt also checks that children render inside the
<svg>.The rendered SVG is unchanged apart from where the filters and marker sit inside
<defs>.Screenshots of your changes (if applicable)
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
GraphCanvas.test.jsgivesGraphCanvas.tsx100% line and branch coverage, including the Generate-page lines Coveralls flagged on the first push.GraphCanvasstill reads the container size withdocument.getElementById("react-graph")while rendering, as the old code did. A resize-observer hook would be cleaner, but it would change when the viewBox updates, so I left it out of this PR.🤖 Generated with Claude Code