d2 icon indicating copy to clipboard operation
d2 copied to clipboard

Style keyword

Open pleshevskiy opened this issue 3 years ago • 1 comments

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

image

Actual

image

It's almost hard to see, but there's only one style left (opacity: 0.5)

pleshevskiy avatar Dec 09 '22 12:12 pleshevskiy

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

alixander avatar Dec 09 '22 18:12 alixander

fixed in https://github.com/terrastruct/d2/pull/714

alixander avatar Feb 04 '23 08:02 alixander