diff --git a/d2compiler/compile.go b/d2compiler/compile.go
index 902384c1c..125ae344e 100644
--- a/d2compiler/compile.go
+++ b/d2compiler/compile.go
@@ -938,6 +938,17 @@ func (c *compiler) compileEdgeField(edge *d2graph.Edge, f *d2ir.Field) {
_, isReserved := d2ast.SimpleReservedKeywords[keyword]
if isReserved {
c.compileReserved(&edge.Attributes, f)
+ if keyword == "icon" && f.Map() != nil {
+ for _, ff := range f.Map().Fields {
+ if ff.Name.ScalarString() == "style" && ff.Name.IsUnquoted() {
+ if f.Map() == nil || len(f.Map().Fields) == 0 {
+ c.errorf(f.LastRef().AST(), `"style" expected to be set to a map of key-values, or contain an additional keyword like "style.opacity: 0.4"`)
+ return
+ }
+ c.compileIconStyle(&edge.Attributes, ff.Map())
+ }
+ }
+ }
return
} else if f.Name.ScalarString() == "style" {
if f.Map() == nil {
@@ -977,6 +988,17 @@ func (c *compiler) compileArrowheads(edge *d2graph.Edge, f *d2ir.Field) {
isReserved = isReserved && f2.Name.IsUnquoted()
if isReserved {
c.compileReserved(attrs, f2)
+ if keyword == "icon" && f.Map() != nil {
+ for _, ff := range f.Map().Fields {
+ if ff.Name.ScalarString() == "style" && ff.Name.IsUnquoted() {
+ if f.Map() == nil || len(f.Map().Fields) == 0 {
+ c.errorf(f.LastRef().AST(), `"style" expected to be set to a map of key-values, or contain an additional keyword like "style.opacity: 0.4"`)
+ return
+ }
+ c.compileIconStyle(attrs, ff.Map())
+ }
+ }
+ }
continue
} else if f2.Name.ScalarString() == "style" && f2.Name.IsUnquoted() {
if f2.Map() == nil {
diff --git a/d2exporter/export.go b/d2exporter/export.go
index f52134da1..56f4b9146 100644
--- a/d2exporter/export.go
+++ b/d2exporter/export.go
@@ -416,6 +416,10 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection
}
}
+ if edge.IconStyle.BorderRadius != nil {
+ connection.IconBorderRadius, _ = strconv.ParseFloat(edge.IconStyle.BorderRadius.Value, 64)
+ }
+
if edge.Style.Italic != nil {
connection.Italic, _ = strconv.ParseBool(edge.Style.Italic.Value)
}
diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go
index 7c7482b25..f6dab0bbd 100644
--- a/d2renderers/d2svg/d2svg.go
+++ b/d2renderers/d2svg/d2svg.go
@@ -590,13 +590,25 @@ func drawConnection(writer io.Writer, diagramHash string, connection d2target.Co
if connection.Icon != nil {
iconPos := connection.GetIconPosition()
if iconPos != nil {
- fmt.Fprintf(writer, ``,
- html.EscapeString(connection.Icon.String()),
- iconPos.X,
- iconPos.Y,
- d2target.DEFAULT_ICON_SIZE,
- d2target.DEFAULT_ICON_SIZE,
- )
+ if connection.IconBorderRadius != 0 {
+ fmt.Fprintf(writer, ``,
+ html.EscapeString(connection.Icon.String()),
+ iconPos.X,
+ iconPos.Y,
+ d2target.DEFAULT_ICON_SIZE,
+ d2target.DEFAULT_ICON_SIZE,
+ connection.IconBorderRadius,
+ )
+ } else {
+
+ fmt.Fprintf(writer, ``,
+ html.EscapeString(connection.Icon.String()),
+ iconPos.X,
+ iconPos.Y,
+ d2target.DEFAULT_ICON_SIZE,
+ d2target.DEFAULT_ICON_SIZE,
+ )
+ }
}
}
diff --git a/d2target/d2target.go b/d2target/d2target.go
index c8b0e8a07..cfd858d5d 100644
--- a/d2target/d2target.go
+++ b/d2target/d2target.go
@@ -625,10 +625,11 @@ type Connection struct {
Route []*geo.Point `json:"route"`
IsCurve bool `json:"isCurve,omitempty"`
- Animated bool `json:"animated"`
- Tooltip string `json:"tooltip"`
- Icon *url.URL `json:"icon"`
- IconPosition string `json:"iconPosition,omitempty"`
+ Animated bool `json:"animated"`
+ Tooltip string `json:"tooltip"`
+ Icon *url.URL `json:"icon"`
+ IconPosition string `json:"iconPosition,omitempty"`
+ IconBorderRadius float64 `json:"iconBorderRadius,omitempty"`
ZIndex int `json:"zIndex"`
}