awslabs / aws-icons-for-plantuml

PlantUML sprites, macros, and other includes for Amazon Web Services services and resources
Other
882 stars 150 forks source link

Define variable in puml files to reference color #54

Closed bschwarz closed 1 year ago

bschwarz commented 1 year ago

Define a variable for each puml file that defines the color for that resource based on the category color. This way the color for the resource can be referenced directly instead of looking up the color manually. For example, using this value in sequence diagrams activate bars.

I believe there is just a small changed needed in icon.py, in the generate_puml() method:

puml_content += f"!define AWS_COLOR_{target} {color}\n\n"

which will produce, for example: !define AWS_COLOR_Lambda #D86613

or perhaps for capitalized: puml_content += f"!define AWS_COLOR_{target.upper()} {color}\n\n"

which will produce, for example: !define AWS_COLOR_LAMBDA #D86613

gadams999 commented 1 year ago

Hi @bschwarz,

Thanks for the suggestion which I can see help reduce the complexity of coloring the icons in PUML diagrams. Depending upon the next release of the AWS Icon set we may incorporate into that sprint.

hakanson commented 1 year ago

I do have colors defined in AWSCommon.puml using the color name with a comment for the categories it applies to.

' Customer Enablement; Database; Developer Tools; Satellite
!define AWS_COLOR_BLUE #3A47CB
' Cloud Financial Management; Internet of Things; Storage
!define AWS_COLOR_GREEN #3F8624
' Blockchain; Compute; Containers; Media Services; Quantum Technologies
!define AWS_COLOR_ORANGE #D86613
' Application Integration; Management & Governance; VR & AR
!define AWS_COLOR_PINK #CD2264
' Analytics; Game Tech; Networking & Content Delivery; Serverless
!define AWS_COLOR_PURPLE #693BC5
' Business Applications; Contact Center; Front-End Web & Mobile; Robotics; Security, Identity & Compliance
!define AWS_COLOR_RED #D6232C
' End User Computing; Machine Learning; Migration & Transfer
!define AWS_COLOR_TURQUOISE #1B7B67

Example of usage from examples /S3 Upload Workflow.puml

' define custom group for Amazon S3 bucket
AWSGroupColoring(S3BucketGroup, #FFFFFF, AWS_COLOR_GREEN, plain)
!define S3BucketGroup(g_alias, g_label="Amazon S3 bucket") AWSGroupEntity(g_alias, g_label, AWS_COLOR_GREEN, SimpleStorageService, S3BucketGroup)

and multiple examples in https://github.com/awslabs/aws-icons-for-plantuml/tree/main/examples/architecture-blog

Do you think using AWS_COLOR_LAMBDA would be a better experience over AWS_COLOR_ORANGE ? Maybe these need to be documented better on home page or on AWSSymbols.md

bschwarz commented 1 year ago

Yes, I do believe AWS_COLOR_LAMBDA would be better. If I am composing a sequence diagram, and I want to make the activation bar the color of the resource, currently (and this is what I do now), I have to lookup that resource to find the category it belongs to, and then find the color. Lambda is easy because I just know it is orange. But some of the other resources not so obvious. I think the bang for the buck is worth it, since it's such a small change.

Another option would be to have some sort of puml lookup function, so you could do get_color("lambda"), but this might be a little harder to implement...although might be better from a user experience.

hakanson commented 1 year ago

Do you think per service and resource colors would be too many, vs using the categories from AWSSymbols.md like AWS_COLOR_COMPUTE or AWS_COLOR_INTERNETOFTHINGS - e.g.. do we want to go as deep as AWS_COLR_IoTThingTemperatureHumiditySensor ?

The !include files are organized per category so that is likely easier to figure out that the associated color.

hakanson commented 1 year ago

To better document the color definitions, I'm thinking of adding this table this into AWSSymbols.md

PUML Macro (Name) Color Categories
AWS_COLOR #232F3E
AWS_BG_COLOR #FFFFFF
AWS_BORDER_COLOR #FF9900
AWS_COLOR_BLUE #3A47CB Customer Enablement; Database; Developer Tools; Satellite
AWS_COLOR_GREEN #3F8624 Cloud Financial Management; Internet of Things; Storage
AWS_COLOR_ORANGE #D86613 Blockchain; Compute; Containers; Media Services; Quantum Technologies
AWS_COLOR_PINK #CD2264 Application Integration; Management & Governance; VR & AR
AWS_COLOR_PURPLE #693BC5 Analytics; Game Tech; Networking & Content Delivery; Serverless
AWS_COLOR_RED #D6232C Business Applications; Contact Center; Front-End Web & Mobile; Robotics; Security, Identity & Compliance
AWS_COLOR_TURQUOISE #1B7B67 End User Computing; Machine Learning; Migration & Transfer
bschwarz commented 1 year ago

Yes, that would be good to have. I also would almost like to see the reverse table, where the first column is either the category or resource, because when I am looking up a color for reference, I am usually looking to see which color corresponds to a particular resource. At least that is 90% of my use cases.