Skip to content

Commit

Permalink
Merge pull request #2094 from alixander/connection-style-fill
Browse files Browse the repository at this point in the history
d2render: connection style fill
  • Loading branch information
alixander authored Sep 14, 2024
2 parents fe64773 + 890e87f commit 3da25c7
Show file tree
Hide file tree
Showing 15 changed files with 2,152 additions and 8 deletions.
1 change: 1 addition & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Compiler: Error on multi-line labels in `sql_table` shapes [#2057](https://github.com/terrastruct/d2/pull/2057)
- Sequence diagram: Image shape actors can use spans and notes [#2056](https://github.com/terrastruct/d2/issues/2056)
- Globs: Filters work with default values (e.g. `&opacity: 1` will capture everything without opacity explicitly set) [#2090](https://github.com/terrastruct/d2/pull/2090)
- Render: connection label fills have a bit of padding and border-radius for better aesthetics [#2094](https://github.com/terrastruct/d2/pull/2094)

#### Bugfixes ⛑️

Expand Down
21 changes: 21 additions & 0 deletions d2renderers/d2sketch/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,27 @@ C <-> D: triangle {
}
}`,
},
{
name: "connection-style-fill",
script: `
shape: sequence_diagram
customer
employee
rental
item
(* -> *)[*].style.fill: black
(* -> *)[*].style.font-color: white
customer -> employee: "rent(this, i, p)"
employee -> rental: "new(this, i, p)"
rental -> employee
employee -> rental: isValid()
rental -> item: isRentable(c)
item -> customer: is(Adult)
customer -> item: true
`,
},
}
runa(t, tcs)
}
Expand Down
119 changes: 119 additions & 0 deletions d2renderers/d2sketch/testdata/connection-style-fill/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.
5 changes: 3 additions & 2 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,9 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
}
if connection.Fill != color.Empty {
rectEl := d2themes.NewThemableElement("rect")
rectEl.X, rectEl.Y = labelTL.X, labelTL.Y
rectEl.Width, rectEl.Height = float64(connection.LabelWidth), float64(connection.LabelHeight)
rectEl.Rx = 10
rectEl.X, rectEl.Y = labelTL.X-4, labelTL.Y-3
rectEl.Width, rectEl.Height = float64(connection.LabelWidth)+8, float64(connection.LabelHeight)+6
rectEl.Fill = connection.Fill
fmt.Fprint(writer, rectEl.Render())
}
Expand Down
2 changes: 1 addition & 1 deletion e2etests/testdata/stable/font_sizes/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.
Loading

0 comments on commit 3da25c7

Please sign in to comment.