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

Adding "resources" section #1891

Open
mauroexe opened this issue Apr 6, 2024 · 2 comments
Open

Adding "resources" section #1891

mauroexe opened this issue Apr 6, 2024 · 2 comments

Comments

@mauroexe
Copy link

mauroexe commented Apr 6, 2024

Hey Alixander!

I've been doing lots and lots of diagrams and I struggled with something...

When you define your objects, there's no way to keep them invisible and use them later... I came across an idea of creating a section of resources; just like D2 classes but those "resources" could be based on classes too.

To help you understand the idea better, I share you a link to a diagraming tool that a friend of mine found. This tool has a resources section (coincidently LOL).

If you can implement that "resources" behavior, D2 will be strong enough to have no competitors, I have all the faith in your efforts; I wish I had the time to spare helping you coding it.

Imagine if the next scenario could be possible:

FILE: styles.d2

classes: {
  dog: {
    shape: circle
  }
  male: {
    style.fill: brown
    style.fill: brown
    style.font-color:white
  }
  female: {
    style.fill: orange
  }
}

FILE: dogs.d2

resources: {
  dog1: Frido {
    class: [dog; male]
  }
  dog2: Snoopy {
    class: [dog; male]
  }
  dog3: Paulette {
    class: [dog; female]
  }
}

FILE: houses.d2

resources: {
  my-house: {
    label: "Home"
  }
  friends-house: {
    label: "Friend's House"
  }
}

FILE: diagram.d2


...@styles
...@dogs
...@houses

relations: {
  my-house: {
    dog1 -- dog3: "Couple"
  }
  friends-house: {
    dog2
  }
}

The previous example should compile into something like this:

image

It really improves the readability of what really matters: the relations, ¿Don't you think?

¿What do you say, can you implement it sometime in the future?

@alixander
Copy link
Collaborator

vars should actually be flexible enough to do this. but needs some compiler work to make it work. good suggestion, thank you

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

No branches or pull requests

2 participants