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

Feature: ability to import d2 files and reuse common components #670

Closed
shikharid opened this issue Jan 16, 2023 · 2 comments · Fixed by #1371
Closed

Feature: ability to import d2 files and reuse common components #670

shikharid opened this issue Jan 16, 2023 · 2 comments · Fixed by #1371

Comments

@shikharid
Copy link

shikharid commented Jan 16, 2023

Ability to import d2 files inside another and ways to inherit styling will be a very useful feature for large scale projects.

Something like this should make:

  • maintaining these diagrams easier
  • teams will be able build a base set of components with custom styling, common lingo and shapes and reuse them

Also conforms to how software teams operate, in a declarative way.
Some leads create a set of guidelines on how to document stuff and the team follows it.

We will need some syntax for defining shape styling (which are not to be rendered) and ability to inherit/override them in nodes

Something like:

microservice-base.d2

d2-templates: {
  microservice-server: {
    shape: rectangle
    style: {
      stroke: "#53C0D8"
      stroke-width: 5
      shadow: true
    }
  }
  
  microservice-db: {
    shape: cylinder
    style: {
      stroke: "#53C0D8"
      stroke-width: 5
      shadow: true
    }
  }
}

my-monolith.d2

import: ./microservice-base.d2

my-monolith: {
  shape: microservice-server
  my-monolith-db {
    shape: shape-microservice-db
  }
}

@iAdanos
Copy link

iAdanos commented Feb 27, 2023

+1, since it's the painkiller for complex diagrams

@iAdanos
Copy link

iAdanos commented Feb 27, 2023

I think it's related to #554

@nhooyr nhooyr mentioned this issue Jun 5, 2023
2 tasks
@github-project-automation github-project-automation bot moved this to Done in D2 Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants