Crestron Components Lib - Showcase App

Component Configuration: template variables for ch5-list

Component Configuration (click to expand)
{
  "attributes": {
    "component":{
      "ch5-list":{
        "size":"5",
        "orientation":"horizontal",
        "indexId":"idx",
        "minWidth":"250px",
        "maxWidth":"500px",
        "minHeight":"100px",
        "maxHeight":"150px",
        "itemWidth":"125px",
        "itemHeight":"75px"
      }
    }
  },
  "templatevariables":{
    "id":{
      "list1":[
        {"label":"Rewind","cssClass":"green"},
        {"label":"Play","cssClass":"blue"},
        {"label":"FWD","cssClass":"blue"},
        {"label":"Stop","cssClass":"green"},
        {"label":"Record","cssClass":"red"}
      ]
    }
  }
}

Press the Load button to load the configuration.

Ch5 components can be preconfigured with default values for attributes and for templatevariables. The configuration can be done using Ch5Config and its methods:

  • loadConfig(config:TCh5Config) loads a new configuration and overrides the existing one.
  • setAttributeForId(elementId:string, attributeName:string, attributeValue:string) sets an attributeValue for an attributeName of the specified HTML elementId
  • setAttributeForComponent(componentName:string, attributeName:string, attributeValue:string) sets an attributeValue for an attributeName of the specified ch5 component (componentName)
  • setTemplateVarsForId(elementId:string, tempVarsItems:any[]) sets the template variables for the ch5 component having the specified elementId
  • getConfig() returns the current configuration object
  • getAttributesForId(elementId:string):TCh5ConfigAttributes returns the configrued attributes for the component having the specified elementId
  • getAttributesForComponent(componentName:string):TCh5ConfigAttributes returns all configured attributes for the component specified in componentName ( for example 'ch5-button')
  • getTemplateVarsForElementById(elementId:string):TCh5ConfigTemplateVars[] returns the configured template variables for the component having the specified elementId
  • getAttributesForElement(cr:Ch5Common):TCh5ConfigAttributes returns all configured attributes for a ch5 component
  • getTemplateVarsForElement(cr:Ch5Common):TCh5ConfigTemplateVars[] returns all configured templatevariables for a ch5 component


type TCh5ConfigAttributes={
    [attrName:string]: string
}
type TCh5ConfigTemplateVars={
    [varName:string]: string
}
type TCh5Config={
    "attributes": {
        "id": {
            [id:string]:TCh5ConfigAttributes
        },
        "component": {
            [component:string]:TCh5ConfigAttributes
        }
    },
    "templatevariables": {
        "id": {
            [id:string]:TCh5ConfigTemplateVars[]
        }
    }
}

Component configuration: template variables for ch5-list

    <ch5-list id="list1">
        <template>
            <div class="horizontal-list-item">
                <span class="{{cssClass}}">item_{{idx}} {{label}}</span>
            </div>
        </template>
    </ch5-list>