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

d2svg: parse connection label fill gradients #2326

Merged
merged 2 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
- Globs: fixes edge case where globs with imported boards would create empty boards [#2247](https://github.com/terrastruct/d2/pull/2247)
- Sequence diagrams: fixes alignment of notes when self messages are above it [#2264](https://github.com/terrastruct/d2/pull/2264)
- Null: fixes `null`ing a connection with absolute syntax [#2318](https://github.com/terrastruct/d2/issues/2318)
- Gradients: works with connection fills [#2326](https://github.com/terrastruct/d2/pull/2326)
3 changes: 3 additions & 0 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1906,6 +1906,9 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) {
if color.IsGradient(c.Stroke) {
defineGradients(buf, c.Stroke)
}
if color.IsGradient(c.Fill) {
defineGradients(buf, c.Fill)
}
}

// Apply hash on IDs for targeting, to be specific for this diagram
Expand Down
23 changes: 12 additions & 11 deletions e2etests/testdata/txtar/gradient/dagre/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 91 additions & 80 deletions e2etests/testdata/txtar/gradient/dagre/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 9 additions & 8 deletions e2etests/testdata/txtar/gradient/elk/board.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

171 changes: 91 additions & 80 deletions e2etests/testdata/txtar/gradient/elk/sketch.exp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion e2etests/txtar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ colors: {
style.stroke: "linear-gradient(to right, red, blue, green)"
style.font-color: "linear-gradient(to bottom right, red 0%, yellow 25%, green 50%, cyan 75%, blue 100%)"
}
gradient -> colors
gradient -> colors: foobar {style.font-color: red; style.stroke: red; style.fill: "radial-gradient(#ffffff, #000000)"}

-- var_in_markdown --
vars: {
Expand Down