-
Notifications
You must be signed in to change notification settings - Fork 492
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
compiler: class should take priority over glob #1766
Comments
I think whichever comes later in the d2 file should take priority, in case you want to use a glob to set classes or override a value in a class In your example However you may want to do something like the following where you overwrite a class with a glob: classes: {
x: {
style.fill: red
style.stroke: yellow
}
}
a1.class: x
a2.class: x
b.class: x
a*.style.fill: green |
implementation note: I think the only way is to reimplement classes into the IR. Since globs are at the IR level, the IR produced will show |
@gavin-ts setting classes is orthogonal to this issue. As for order, globs apply to current objects and lazily to future objects. You can stick |
agree not class specific but in general shouldn't setting anything later in the file overwrite what is earlier? whether it is classes, globs, or labels such as the example above? |
Mechanisms have different priorities over each other, and ordering matters within those same priorities. If I have a shape with To me, the rationale is specificity. Globs target most. So more specific rules override less specific. |
I can see the specificity rationale. However in the example reposted below the glob is used to target something more specific than the class. With those rules the glob would be ineffective and you may need a separate class for a's just to set the fill (and you wouldn't be able to override that class with a glob As a tangent, is there a good way to add an additional class to an object (rather than overwriting all classes)?
I can see that but wouldn't it be possible to just move the class definition before the shape-specific styles (or vice versa)? Having the property later values override earlier ones seems like a nice and useful property allowing globs to be much more capable e.g. used as above. This could also be useful to use classes to override a set of values (maybe you want to reset styles to a certain class in a scenario/step?) |
a
should be red andb
should be green. Currently they are both green.The text was updated successfully, but these errors were encountered: