Skip to content

Commit

Permalink
Merge pull request #1836 from alixander/connection-label-underline
Browse files Browse the repository at this point in the history
allow underlines for connections
  • Loading branch information
alixander authored Feb 15, 2024
2 parents 4c845ed + 4db1f72 commit e7bbda6
Show file tree
Hide file tree
Showing 8 changed files with 577 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#### Features 🚀

- `style.underline` works on connections [#1836](https://github.com/terrastruct/d2/pull/1836)

#### Improvements 🧹

#### Bugfixes ⛑️

- Fixes `null` being set on a nested shape not working in certain cases when connections also pointed to that shape [1830](https://github.com/terrastruct/d2/pull/1830)
- Fixes edge case of bad import syntax crashing using d2 as a library [1829](https://github.com/terrastruct/d2/pull/1829)
- Fixes `null` being set on a nested shape not working in certain cases when connections also pointed to that shape [#1830](https://github.com/terrastruct/d2/pull/1830)
- Fixes edge case of bad import syntax crashing using d2 as a library [#1829](https://github.com/terrastruct/d2/pull/1829)
3 changes: 3 additions & 0 deletions d2exporter/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection
if edge.Style.Bold != nil {
connection.Bold, _ = strconv.ParseBool(edge.Style.Bold.Value)
}
if edge.Style.Underline != nil {
connection.Underline, _ = strconv.ParseBool(edge.Style.Underline.Value)
}
if theme != nil && theme.SpecialRules.Mono {
connection.FontFamily = "mono"
}
Expand Down
3 changes: 3 additions & 0 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co
} else if connection.Italic {
fontClass += "-italic"
}
if connection.Underline {
fontClass += " text-underline"
}
if connection.Fill != color.Empty {
rectEl := d2themes.NewThemableElement("rect")
rectEl.X, rectEl.Y = labelTL.X, labelTL.Y
Expand Down
6 changes: 6 additions & 0 deletions e2etests/testdata/txtar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,9 @@ monsters: {
}

costumes.monster -> monsters.id

-- connection-underline --

a -> b: hi {
style.underline: true
}
178 changes: 178 additions & 0 deletions e2etests/testdata/txtar/connection-underline/dagre/board.exp.json

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

107 changes: 107 additions & 0 deletions e2etests/testdata/txtar/connection-underline/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 e7bbda6

Please sign in to comment.