Parameters: select to output multiple values?

Hi there! I’m really excited about the parameters. When I read the documentation I immediately thought it was very interesting if I can use the ‘select’ type to output multiple values.

For example I have a dropdown with three values and each value has multiple output-values. The options would look like something like this:

"h1" : [
	{ "text-size" : "3em" },
	{ "line-height" : "2" },
],
"h2" : [
	{ "text-size" : "2em" },
	{ "line-height" : "1.6" },
],
"h3" : [
	{ "text-size" : "1em" },
	{ "line-height" : "1.25" },
]

The result would be that I can select a tag and automatically both the text-size and the line-height will be the output. Both values are connected to the option provided by the dropdown. So if I select option h1 the text-size is 3em and the line-height would be 2.

Is something like this possible or is this in development? I feel like this would unleash a great amount of possibilities.

Looking forward to it!

Howdy, @Dagaloni! Thanks for writing in, I’m glad you’re enjoying Parameters and seeing a lot of potential for use-cases in your builds. :slight_smile:

What you’re describing is not possible at the moment, nor is it something we have any plans to get into at the moment as it gets into a whole slew of data management and dealing with edge-cases that grow exponentially when you’re dealing with multi-dimensional values like this.

However, that being said…allow me to provide you with some ideas you could leverage via Parameters that could help you achieve a similar end result based on the example you’re providing here. :slight_smile:

If what you’re trying to do is build out some sort of type scale, or typography system where maybe you just want users to select from a pre-defined set of styles, you could very easily do this by making your select return a unique identifier, use that identifier to generate a unique CSS class, then style that class using the Component CSS sheet, which will get loaded whenever a Component from that set is used on the frontend.

I’m going to take this idea a bit and expand on it some to get you thinking of potential use-cases, but here’s what I’m starting with:

We have a “Headline” Element renamed to “Type System,” with a set of Parameters mapped to it. Those Parameters are here if you’d like to try this out personally:

{
  "content" : {
    "label"      : "Content",
    "type"       : "text-editor",
    "initial"    : "Type System",
    "expandable" : true
  },
  "tag" : {
    "type"    : "choose",
    "label"   : "Tag",
    "initial" : "p",
    "options" : [
      { "value" : "h1", "label" : "h1" },
      { "value" : "h2", "label" : "h2" },
      { "value" : "h3", "label" : "h3" },
      { "value" : "h4", "label" : "h4" },
      { "value" : "h5", "label" : "h5" },
      { "value" : "h6", "label" : "h6" },
      { "value" : "p",  "label" : "P"  }
    ]
  },
  "style" : {
    "type"    : "select",
    "label"   : "Style",
    "initial" : "body",
    "options" : [
      { "value" : "display", "label" : "Display"    },
      { "value" : "head-1",  "label" : "Headline 1" },
      { "value" : "head-2",  "label" : "Headline 2" },
      { "value" : "body",    "label" : "Body"       },
      { "value" : "caption", "label" : "Caption"    },
      { "value" : "label",   "label" : "Label"      }
    ]
  },
  "color" : {
    "label"   : "Color",
    "type"    : "color",
    "initial" : "#000000"
  },
  "margin" : {
    "type"   : "group",
    "label"  : "Margin",
    "params" : {
      "top" : {
        "type"        : "margin",
        "label"       : "Top",
        "labelBefore" : "css:margin-top",
        "initial"     : "0px",
        "isVar"       : true
      },
      "bottom" : {
        "type"        : "margin",
        "label"       : "Bttm",
        "labelBefore" : "css:margin-bottom",
        "initial"     : "0px",
        "isVar"       : true
      }
    }
  }
}

To being, take note of the "style" key in this object. It is a "select" with a list of associated styles we’re going to build out in our “typography library.” I am using the "value"s of each option in that list to generate a unique class on this Element using the following as a custom class:

is-type-scale-{{dc:p:style}}

This will generate classes like is-type-scale-display, is-type-scale-head-1, et cetera as you make your selections from the list of options. We can use these as unique identifiers to build out our styles in the Component CSS of the Set like so:

/* Display
// ------- */

.is-type-scale-display {
  font-size: 4.768em !important;
}

.is-type-scale-display .x-text-content-text-primary {
  font-family: Poppins !important;
  font-style: normal !important;
  font-weight: 400 !important;
  letter-spacing: -0.025em !important;
  line-height: 1 !important;
  text-transform: none !important;
}


/* Headline 1
// ---------- */

.is-type-scale-head-1 {
  font-size: 3.052em !important;
}

.is-type-scale-head-1 .x-text-content-text-primary {
  font-family: Poppins !important;
  font-style: normal !important;
  font-weight: 700 !important;
  letter-spacing: -0.005em !important;
  line-height: 1.2 !important;
  text-transform: none !important;
}


/* Headline 2
// ---------- */

.is-type-scale-head-2 {
  font-size: 1.563em !important;
}

.is-type-scale-head-2 .x-text-content-text-primary {
  font-family: Poppins !important;
  font-style: normal !important;
  font-weight: 600 !important;
  letter-spacing: -0.005em !important;
  line-height: 1.3 !important;
  text-transform: none !important;
}


/* Body
// ---- */

.is-type-scale-body {
  font-size: 1em !important;
}

.is-type-scale-body .x-text-content-text-primary {
  font-family: Poppins !important;
  font-style: normal !important;
  font-weight: 400 !important;
  letter-spacing: 0em !important;
  line-height: 1.8 !important;
  text-transform: none !important;
}


/* Caption
// ------- */

.is-type-scale-caption {
  font-size: 0.8em !important;
}

.is-type-scale-caption .x-text-content-text-primary {
  font-family: Poppins !important;
  font-style: italic !important;
  font-weight: 400 !important;
  letter-spacing: 0em !important;
  line-height: 1.35 !important;
  text-transform: none !important;
}


/* Label
// ----- */

.is-type-scale-label {
  font-size: 0.8em !important;
}

.is-type-scale-label .x-text-content-text-primary {
  font-family: Poppins !important;
  font-style: normal !important;
  font-weight: 600 !important;
  letter-spacing: 0.15em !important;
  line-height: 1.35 !important;
  text-transform: uppercase !important;
}

A couple notes on what I’ve done above to make this more flexible:

  1. I am applying the font-size to the base of the Element, so any relative sizing I use will be working appropriately all the way down the tree.
  2. I am applying the individual typography styles to the .x-text-content-text-primary tag within the parent, as that is where the styles need to be set to be output correctly.
  3. I am using !important on everything here because we are trying to build a very strict set of rules we want to follow.

Beyond that, what I’ve done is map in a “Content” "text-editor", a “Tag” "choose" control to give me a little flexibility on the semantics of the item, and a “Color” control, for some aesthetic control. These are wired up using {{dc:p:content}}, {{dc:p:tag}}, and {{dc:p:color}} in their respective inputs on the main Element’s controls. Additionally, I’ve also got {{dc:p:margin.top}} and {{dc:p:margin.bottom}} for basic vertical spacing. These to me are essentially the bare minimum you’d need to make this the perfect blend of flexible yet streamlined on the frontend.

Now in practice on a page, we can do something like this:

Notice that we’re only using one Component to power all of this typography, but inside each one I’ve got unique content, unique HTML tags set, color adjustments, and top / bottom spacing applied to give things a vertical rhythm, but I’ve abstracted away all of my type styles into the Component CSS.

This is of course just a very quick example of one way you could slice all of this and build out systems that cater to your needs. Hopefully that gets you thinking though and helps you out on your journey!

5 Likes

Hi @kory,

Thank you so much for your extensive post! You really took the time for this one. Totally different approach but I like it! Great thing that dynamic content can now be used in custom CSS.

Thanks again Kory!

1 Like

@Dagaloni, no problem! It’s definitely a situation I can see many people wanting to explore, so I wanted to have something to point them back to and get them thinking about how to leverage Parameters creatively. Have fun!

1 Like

Detailed and amazing as always!

For future reference, it seems that some people might be left wondering how you managed to map the {{dc:p:tag}} to the HTML tag field, since it doesn’t accept anything to paste into it.

I guess you entered into the Breakout mode (Found in the Dev Toolkit) and then pasted it in. :slight_smile:

Speaking of the Dev toolkit, on my QWERTZ keyword, I mapped it to “open:dev-toolkit:tools”: “mod+y”, because the mod+d was already mapped to duplicate.

1 Like

@Misho, yep! The tag was mapped via Breakout Mode for me personally, but you can also hop into Dev Toolkit and access any non-boolean value using Parameters!

2 Likes

Just learned about Breakout Mode. :exploding_head:

1 Like

:exploding_head: indeed!

1 Like