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

renderer: dont render label & icon unnecessarily with opacity 0 #1940

Merged
merged 1 commit into from
May 15, 2024
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
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#### Improvements 🧹

- Opacity 0 shapes no longer have a label mask which made any segment of connections going through them lower opacity [#1940](https://github.com/terrastruct/d2/pull/1940)

#### Bugfixes ⛑️

- Local relative icons are relative to the d2 file instead of CLI invoke path [#1924](https://github.com/terrastruct/d2/pull/1924)
Expand Down
4 changes: 2 additions & 2 deletions d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
// Closes the class=shape
fmt.Fprint(writer, `</g>`)

if targetShape.Icon != nil && targetShape.Type != d2target.ShapeImage {
if targetShape.Icon != nil && targetShape.Type != d2target.ShapeImage && targetShape.Opacity != 0 {
iconPosition := label.FromString(targetShape.IconPosition)
var box *geo.Box
if iconPosition.IsOutside() {
Expand All @@ -1234,7 +1234,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
)
}

if targetShape.Label != "" {
if targetShape.Label != "" && targetShape.Opacity != 0 {
labelPosition := label.FromString(targetShape.LabelPosition)
var box *geo.Box
if labelPosition.IsOutside() {
Expand Down
18 changes: 18 additions & 0 deletions e2etests/testdata/txtar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,21 @@ ok: {
}
dog1 -> dog3
}

-- opacity-zero-route --
grid: {
*.style.opacity: 0
grid-columns: 3
a
b
c
d
e
f
g
h

d.style.opacity: 1
}

out -> grid.d
Loading
Loading