Crestron Components Lib - Showcase App

ch5-modal-dialog (common): customClass, receiveStateCustomClass

Emulator Scenario (click to expand) (click to collapse)
{
  "cues": [
    {
      "type": "boolean",
      "event": "sig_trig_class1",
      "trigger": true,
      "actions": [
        {
          "type": "string",
          "state": "sig_custom_class",
          "logic": "set",
          "value": "blue-dashed-border bg1"
        }
      ]
    },
    {
      "type": "boolean",
      "event": "sig_trig_class2",
      "trigger": "&change",
      "actions": [
        {
          "state": "sig_custom_class",
          "type": "s",
          "logic": "set",
          "value": "green-dotted-border bg2"
        }
      ]
    },
    {
      "type": "boolean",
      "event": "sig_trig_class3",
      "trigger": true,
      "actions": [
        {
          "state": "sig_custom_class",
          "type": "s",
          "logic": "set",
          "value": "red-solid-border"
        }
      ]
    }
  ]
}
Emulator actions

Press the Load button to load the scenario. This will also reload all of the existing examples on the page.

Press the Run button to run the scenario. You only need to do this if the scenario (the json) has an onStart key.

Events and states

The Emulator Scenario JSON contains an array of cues and an optional array onStart.

→ A cue is defined by: type:string, event:string, trigger:boolean|string|number, actions:array
→ An action is defined by: type:string, state:string, logic:string ... plus other fields ( depending on type)

The value of the state or event for a cue or for an action is a string which represents the name of that state or action.

Type field

The type for cue or for action can be the string:

  • b or boolean - for a boolean state or event
  • n or number or numeric - for a number state or event
  • s or string - for a string state or event
  • o or object - for an object state or event
Trigger field

The trigger can be either a fixed value of the same type as the state or event, or the string "&change". If it is a fixed value then, when the emulator detects that the state or event has changed to the value given in trigger, it also executes the actions for that state or event. If the value is the string is "&change", regardless of state or event type, the actions are executed on any change in the value of the state or event.

Logic Field

The logic can be:

  • link - passes the value received on the incoming join through to the outgoing join. Using this between incompatible join types will attempt to cast the value. In the event of a cast failure, the value will be set to false, 0 or "" (empty string).
  • set - assigns a specific value to the join. This requires a 5th key of 'value' and the specific value to assign. ie. {"state":"light_level", "type":"n", "logic": "set","value":5}. If the 5th key is omitted, the default value will be sent (false, 0, "" or {}).
  • toggle - (boolean Only) reads the current state and changes it to the opposite state.
  • pulse - (boolean Only) value goes high and then low.
  • increment - (Numeric Only) reads the current value of the analog and adds an offset. This logic accepts an optional 5th key of 'offset which determines how many times to increment by. ie. {"event":"volume_level","type":"n", "logic":"increment","offset":5}. If this 5th key is omitted, the default offset of 1 will be applied.
  • decrement - (Numeric Only) reads the current value of the analog and subtracts an offset. This logic accepts an optional 5th key of 'offset which determines how many times to decrement by. ie. {"event":"volume_level","type":"n", "logic":"decrement","offset":5}. If this 5th key is omitted, the default offset of 1 will be applied.
  • RCB logic can be accomplished by defining an action containing an object state or event of RCB type. A 5th key is expected as the amount of time in milliseconds to reach the level. {"signal":"light_level", "type":"n", "logic": "rcb","value":65535, "time":2000}
    { "rcb":{ "value": numeric_value, "time": duration_in_ms } }
Scenario example:

    {
      "cues": [
        {
          "type": "boolean",
          "event": "trigger",
          "trigger": true,
          "actions": [
            {
              "state": "action1",
              "type": "boolean",
              "logic": "toggle"
            },
            {
                "state": "rcb_signal",
                "type": "object",
                "logic": "set",
                "value": {
                    "rcb":{
                        "value": 101,
                        "time": 1500
                    }
                }
            }
          ]
        }
      ],
      "onStart": [
      ]
    }
    

Inherited from the common: customClass attribute.

Pressing this button will show the modal

Sample text

<p>
    Pressing this button will show the modal <ch5-button label="Show modal" sendEventOnClick="trig_show_1"></ch5-button>
</p>

<ch5-modal-dialog
        dismissable="false"
        receiveStateCustomClass="sig_custom_class"
        customClass="blue-dashed-border"
        receiveStateShowPulse="trig_show_1"
        closable
    >
    <p>Sample text</p>
    <ch5-image
            id="ex1-img"
            url="https://picsum.photos/200/300/?random">
    </ch5-image>
</ch5-modal-dialog>

Receiving custom CSS classes from a signal

Clicking the "trigger" buttons will change the value of the signal defined in receiveStateCustomClass.

Pressing this button wil show the modal

This changes the value of the sig_custom_class signal to "blue-dashed-border bg1" ( see Emulator Scenario )

This changes the value of the sig_custom_class signal to "green-dotted-border bg2" ( see Emulator Scenario )

This changes the value of the sig_custom_class signal to "red-solid-border bg3" ( see Emulator Scenario )


Sample text

<p>
    Pressing this button wil show the modal <ch5-button label="Show modal" sendEventOnClick="trig_show_2"></ch5-button>
</p>

<p>
    This changes the value of the <b>sig_custom_class</b> signal to "blue-dashed-border bg1" ( see Emulator Scenario )
    <ch5-button label="trigger 1" sendEventOnClick="sig_trig_class1"></ch5-button>
</p>
<p>
    This changes the value of the <b>sig_custom_class</b> signal to "green-dotted-border bg2" ( see Emulator Scenario )
    <ch5-button label="trigger 2" sendEventOnClick="sig_trig_class2"></ch5-button>
</p>
<p>
    This changes the value of the <b>sig_custom_class</b> signal to "red-solid-border bg3" ( see Emulator Scenario )
    <ch5-button label="trigger 3" sendEventOnClick="sig_trig_class3"></ch5-button>
</p>

<hr>

<ch5-modal-dialog
        dismissable="false"
        receiveStateCustomClass="sig_custom_class"
        customClass="blue-dashed-border"
        receiveStateShowPulse="trig_show_2"
    >
    <p>Sample text</p>
    <ch5-image
            id="ex1-img"
            url="https://picsum.photos/200/300/?random">
    </ch5-image>
</ch5-modal-dialog>