Assigning Variables within components and parameters (feature request?)

Hi, maybe there already is a way of doing this, but I have not yet figured it out. Let’s say we have designed a component with a limited set of parameters. I am looking for a way to change various pieces of design when one changes one parameter. Two examples:

  • I have a “choose” parameter “color scheme” that let’s me pick: “light” and “dark”. In my JSON, I would set for example three variable, such as “text color”, “bottom color”, “background color”, to different values depending on the choice. When designing the element, I could for example access those variables with {{dc:p:color-scheme.text-color}}, and that value is of course different depending on the choice “light” vs. “dark”.
  • I have a Grid layout with placed cells (specific x-start, x-end values, etc.). I have a “choose” parameter “Design” that let’s me pick “Design 1”, “Design 2” (for example: text on the left, image on the right for design 1, and the opposite for design 2), which requires to set SEVERAL numeric values for the placement of the cells (x-start etc). Again, in the JSON definition, for each choice, one could assign all of these values to the numerous variables that are affected by the design choice, and one could access it with something like {{dc:p:design.x-start}}
1 Like

I added some needed docs on using an object as a value. What your referencing is something you can already do if your choose value is an object.

So for the first example. You are adding to the value object your values like text-color. Then grabbed from {{dc:p:design.color}}. Let me know if this helps!

{
  "design": {
    "label": "Design",
    "type": "choose",
    "initial": "light",
    "options": [
      {
        "value": {
          "color": "black",
          "background": "white"
        },
        "label": "light"
      },
      {
        "value": {
          "color": "white",
          "background": "black"
        },
        "label": "dark"
      }
    ]
  }
}
1 Like

Thank you, @charlie, exactly what I have been looking for!

1 Like