chriskn / structurizr-c4puml-extension

Kotlin based extension for the struturizr java api with extended C4-PlantUML support
23 stars 8 forks source link

Add support for element and relationship styles (color, background) #247

Open klu2 opened 2 days ago

klu2 commented 2 days ago

Structurizr has the support of elementStyles, where you can assign shapes, colors, backgrounds to tags.

Right now, this library does not pick up those styles to draw it in the diagram.

The C4PlantUml library has support both for element tags and relationship tags

AddElementTag("v1.0", $borderColor="#d73027")
AddElementTag("v1.1", $fontColor="#d73027")
AddElementTag("backup", $fontColor="orange")

AddRelTag("backup", $textColor="orange", $lineColor="orange", $lineStyle = DashedLine())

But these elements are not printed yet.

The original C4 exporter from Structurizr does have decent support there already, maybe we can re-use some stuff from there, see https://github.com/structurizr/java/blob/master/structurizr-export/src/main/java/com/structurizr/export/plantuml/C4PlantUMLExporter.java#L171

If you want, I can also attempt to create a pull request here.

klu2 commented 2 days ago

I added a first draft (it's WIP, don't merge it), to indicate how this could work. feel free to continue to work on it; if I find some minutes more of time, I'd try to continue that way.

as mentioned in the PR, we should probably consider also adding a feature flag to the configuration to print tags or not, just like in the default exporter