kind: Solution
version: v0
router:
  kind: Router
  routes:
    - frame: home-frame
frames:
  home-frame:
    kind: Frame
    layout:
      kind: GridLayout
      widths: [auto, 300px]
      heights:
        - auto
        - 50px
      areas: 
        - [my-viewer, my-params]
        - [my-viewer, my-popup]
    contents:
      my-data-store:
        kind: DataStore
        value:
          height: 5
          width: 5
        subscribe:
          - kind: PopupForm
            frame: home-frame
            source: my-popup
          - kind: ControlPanel
            frame: home-frame
            source: my-params
      my-model:
        kind: Model
        modelFile: trimbox-part1.gh
        subscribe:
          - kind: DataStore
            frame: home-frame
            source: data
            
      my-form-button:
        kind: Button
        text: Open form
      my-popup: 
        kind: PopupForm
        inputs:
          height:
            kind: TextInput
            label: Height
            required: false
            placeholder: Enter the box height.
          width:
            kind: TextInput
            label: Width
            required: false
            placeholder: Enter the box width.
          my-submit-button:
            kind: SubmitButton
            text: Submit form
        subscribe:
          - kind: Button
            frame: home-frame
            source: my-form-button
          - kind: Model
            frame: home-frame
            source: model
            setMessageOnFailure: Model failed!
            setMessageOnSuccess: Model solved!
      my-viewer:
        kind: Viewer
        materials:
          blue:
            kind: StandardMaterial
            color: [42, 75, 240]
          light-blue:
            kind: StandardMaterial
            color: [119, 173, 238]
        subscribe:
          - kind: Model
            frame: home-frame
            source: my-model
            assignMaterials:
              box: blue
              sphere: light-blue
      my-params: 
        kind: ControlPanel
        controls:
          box-volume-label:
            kind: Text
            text: Box volume
            type: h5
          box-volume:
            kind: Text
            text: ""
          sphere-volume-label:
            kind: Text
            text: Sphere volume
            type: h5
          sphere-volume:
            kind: Text
            text: ""
        subscribe:
          - kind: Model
            frame: home-frame
            setOutputs:
              sphere-volume:
                type: setText
              box-volume:
                type: setText
            source: my-model
            disableControls: true