Skip to content
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

add folder shape (container & component) #329

Closed
wants to merge 1 commit into from

Conversation

mdreano
Copy link

@mdreano mdreano commented Nov 30, 2023

Will be used by structurizr/export#85

Signed-off-by: Mathieu D <mathieu.dreano@decathlon.com>
@mdreano mdreano changed the title add support for folder shape add support for folder shape (container & component) Nov 30, 2023
@mdreano mdreano changed the title add support for folder shape (container & component) add folder shape (container & component) Nov 30, 2023
@kirchsth
Copy link
Member

Hi @mdreano,

thank you for your suggestion, but I'm really not sure if we should add a new shape to the standard,
because it would requires also 6 additional Element calls (SystemCollection, SystemCollection_Ext, ContainerCollection, ContainerCollection_Ext, ComponentCollection, ComponentCollection_Ext), a detailed discussion can found Support more shapes.

But you can add your own shapes based on following pattern (it is the updated version from #145, that it matches with the newest features too).

@startuml
' convert it with additional command line argument -DRELATIVE_INCLUDE="." to use locally
!if %variable_exists("RELATIVE_INCLUDE")
  !include ./../C4_Component.puml
!else
  !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
!endif

' ===========================

' define additional calls
!unquoted procedure UpdateHexagonStyleToo($tagStereo, $bgColor, $fontColor="", $borderColor="", $shadowing="", $shape="", $borderStyle="", $borderThickness="")
$elementTagSkinparams("hexagon", $tagStereo, $bgColor, $fontColor, $borderColor, $shadowing, "", $borderStyle, $borderThickness)
!endprocedure


!unquoted procedure ComponentHexagon($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  $getElementLine("hexagon", "component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
!endprocedure

!unquoted procedure ComponentHexagon_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  $getElementLine("hexagon", "external_component", $alias, $label, $techn, $descr, $sprite, $tags, $link)
!endprocedure

!unquoted procedure ContainerHexagon($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  $getElementLine("hexagon", "container", $alias, $label, $techn, $descr, $sprite, $tags, $link)
!endprocedure

!unquoted procedure ContainerHexagon_Ext($alias, $label, $techn="", $descr="", $sprite="", $tags="", $link="")
  $getElementLine("hexagon", "external_container", $alias, $label, $techn, $descr, $sprite, $tags, $link)
!endprocedure

!unquoted procedure SystemHexagon($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="")
  ' $type reuses $techn definition of $tags
  $getElementLine("hexagon", "system", $alias, $label, $type, $descr, $sprite, $tags, $link)
!endprocedure

!unquoted procedure SystemHexagon_Ext($alias, $label, $descr="", $sprite="", $tags="", $link="", $type="")
  ' $type reuses $techn definition of $tags
  $getElementLine("hexagon", "external_system", $alias, $label, $type, $descr, $sprite, $tags, $link)
!endprocedure

' set default styles 
skinparam hexagon {
    StereotypeFontSize 12
    shadowing false
}

UpdateHexagonStyleToo("system", $SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $SYSTEM_BORDER_COLOR, false)
UpdateHexagonStyleToo("external_system", $EXTERNAL_SYSTEM_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_SYSTEM_BORDER_COLOR, false)
UpdateHexagonStyleToo("container", $CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $CONTAINER_BORDER_COLOR, false)
UpdateHexagonStyleToo("external_container", $EXTERNAL_CONTAINER_BG_COLOR, $ELEMENT_FONT_COLOR, $EXTERNAL_CONTAINER_BORDER_COLOR, false)
UpdateHexagonStyleToo("component", $COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $COMPONENT_BORDER_COLOR, false)
UpdateHexagonStyleToo("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COMPONENT_FONT_COLOR, $EXTERNAL_COMPONENT_BORDER_COLOR, false)

' =====================================================

' if custom styless are required call additional $UpdateHexagonStyleToo()
!$COLOR_A_5 = "#7f3bf7"
!$COLOR_A_1 = "#fe00f7"
!$COLOR_NEUTRAL = "#6633f7"
UpdateElementStyle("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COLOR_A_5, $COLOR_A_1, false)
UpdateHexagonStyleToo("external_component", $EXTERNAL_COMPONENT_BG_COLOR, $COLOR_A_5, $COLOR_A_1, false)


' if an additional cutom tag is required then call UpdateHexagonStyleToo() too
AddElementTag("special", $bgColor=$COLOR_NEUTRAL)
UpdateHexagonStyleToo("special", $bgColor=$COLOR_NEUTRAL)


ContainerHexagon(containerHex, "Special Container", "techn", "special version", $tags="special")

ComponentHexagon(compHex, "Componet", "techn", "Optional Description")
ComponentHexagon_Ext(compHexExt, "Component Ext", "techn")

SHOW_LEGEND("false")
@enduml

As an alternative you could use sprites or other images (like in e.g. #309) too

BR Helmut

@MathieuDreano
Copy link

Hello.

Thank you for taking the time to answer.

I have read the discussions but I am not so sure about the reason why you do not want more shapes. I feel like C4 more about levels rather than shapes used to represent them. We should be allowed use whatever shape fits our need to represent our components. So extending the set of shapes would be nice.

As for me, sprite will fit my needs, thanks !

And thanks again for all the work done so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants