-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
SVG element selection refactoring #4609
Conversation
42d582b
to
ff9f1c5
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #4609 +/- ##
===========================================
- Coverage 76.99% 76.97% -0.02%
===========================================
Files 143 144 +1
Lines 14455 14465 +10
Branches 516 515 -1
===========================================
+ Hits 11130 11135 +5
- Misses 3220 3227 +7
+ Partials 105 103 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
I'd really like to see them refactored, but if you were planning to refactor them all in one PR, it would be hard to review. I was planning to do the same thing in #4486 (originally it was standardizing all diagrams), but @sidharthv96 suggested splitting it into separate PRs. So I'd suggest the same thing, refactor the Please see #4514, it would help you know to the structure we following with the issue we are facing with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file name is kinda long, the folder containing this is already rendering-util
, so ForRendering
part is kinda clear. The selectElements
part is kinda referring to it could select and return multiple elements, whereas it it's only one.
Not sure what to suggest :).
For lines at the end of file, see #4514 to update because it's currently incorrect.
Sorry I could refer to specific lines in review but github in phone isn't as PC, I don't know how to review here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know that you had similar PR and ideas about that. This is simply a draft. There is a complete mess inside draw functions so I put it aside for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh, I didn't thought of creating a file for selecting, although we should since it's a common lines in all diagram :), so thanks for that!
I'll be working in convert it files and delete some of the randomness there, but I don't have time rn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate file is not an ultimate dream.
Too many side effects inside draw function is happening
draw
takes svg element
To my mind draw function of each particular graph must accept the target element, may be along with parent element, document etc. They don have to call this "getElements" function directly, base class or interface must provide it to them.
render
function with parameters
Even better would be a render function that:
- Takes parsed graph definition
- Takes options (dimensions and whatever is needed for the graph), extracted from element beforehand
- Returns some data, including string with svg content, title or any other external attributes for html elements, some additional properties such as callbacks for clicks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides we are selecting these elements in mermaidAPI, by the time of calling draw
function we already know what they are.
And render function in mermaidAPI does actually the same
return {
svg: svgCode,
bindFunctions: diag.db.bindFunctions,
};
I don see a reason why diagram-dedicated functions would violate this interface, so that I could call something like mermaidAPI.render
as well as mermaid.Info.render
Closing this, improvement is being continued here #4514 |
📑 Summary
Set repetitive chunk of code aside
📏 Design Decisions
📋 Tasks
Make sure you
develop
branch