d2
d2 copied to clipboard
💡 Idea: Allow direct referencing of theme colours in new styles?
It'd be super helpful to define custom styles for a diagram (or class) which properly adapt to theme changes, eg. by referencing the colour palette categories or indices
Hypothetical syntax (a few options - but entirely off the cuff to demonstrate intent):
example1: "allowing theme indices as valid CSS names" {
style: {
fill: "base" // use the base colour, select the index based on depth as usual
stroke: "supportingA" // use the analogous accent for stroke, also selecting index based on depth
}
}
example2: "(preferred but more effort) using a theme keyword for access" {
style: {
fill: theme.base
stroke: theme.supportingA
}
}
example3: "specifying an index directly" {
style: {
fill: theme.base.1
}
note: |md
(Not sure the best way to encode indices here - using dot form seems weird for numbers, but don't think array syntax is supported by d2?)
|
}