d2
d2 copied to clipboard
Style keyword
References:
- https://d2lang.com/tour/style
- https://github.com/terrastruct/d2/blob/master/docs/examples/twitter/in.d2
I'm a little confused why we need the style attribute if I can set all of its internal properties directly.
foo.3d: true
# This is equal to this
foo.style.3d: true
but! style overwrite all (!) styles if they were defined without style
foo: {
opacity: 0.6
fill: orange
stroke: "#53C0D8"
stroke-width: 5
stroke-dash: 5
border-radius: 4
font-color: red
shadow: true
multiple: true
3d: true
style.opacity: 0.5
}
Expected

Actual

It's almost hard to see, but there's only one style left (opacity: 0.5)
foo.3d: true
# This is equal to this
foo.style.3d: true
it is not supposed to be equal. it'll be fixed such that they only work under style keyword
fixed in https://github.com/terrastruct/d2/pull/714