HtmlBoxLayout

HtmlBoxLayout is a container that allows you to define the location of components in an HTML template.

Component’s XML-name: htmlBox.

Do not use HtmlBoxLayout for dynamic content or if you want to embed JavaScript code. Use BrowserFrame instead.

Basics

To use templates in the container, you need to create a custom theme. In the subdirectory of the custom theme, you need to create the layouts directory, in which all HTML templates will be placed. Now you can create a template file:

<div location="logo" class="logo"></div>
<table class="component-container">
    <tr>
        <td>
            <div location="email" class="email"></div>
        </td>
        <td>
            <div location="submit" class="submit"></div>
        </td>
    </tr>
</table>

A template should contain <div> elements with location attributes. These elements will display components defined in the XML descriptor with corresponding identifiers.

In the helium-extended.scss file, configure the styles for the variables specified in the location attribute of the template file:

@import "../helium/helium";

@mixin helium-extended {
  @include helium;

  .email {
    width: 390px;
  }

  .submit {
    width: 100px;
  }

  .logo {
    font-size: 96px;
    text-transform: uppercase;
    margin-top: 50px;
  }

  .component-container {
    display: inline-block;
    vertical-align: top;
    width: 100%;
  }
}

The project tree looks like this:

html box layout tree

You can now use the template in the XML screen descriptor:

<htmlBox align="TOP_CENTER"
         template="sample"
         width="500px">
    <label id="logo"
           value="Subscribe"
           stylename="logo"/>
    <textField id="email"
               width="100%"
               inputPrompt="email@test.test"/>
    <button id="submit"
            width="100%"
            caption="Subscribe"/>
</htmlBox>
html box layout

templateContents Element

You can also use the templateContents element to directly set the template’s contents and draw the custom layout. For example:

<htmlBox id="htmlSample"
         height="275px"
         htmlSanitizerEnabled="false"
         stylename="html-sample">
    <templateContents>
        <![CDATA[
                <div class="box-container">
                    <label class="logo">Jmix</label>
                    <div class="button-container">
                        <div class="sample-button addons-button"
                             location="addons">
                        </div>
                        <div class="sample-button buy-button"
                             location="buy">
                        </div>
                        <div class="sample-button support-button"
                             location="support">
                        </div>
                    </div>
                </div>
            ]]>
    </templateContents>
    <button id="addons"
            caption="Addons"
            width="100%"/>
    <button id="buy"
            caption="Buy"
            width="100%"/>
    <button id="support"
            caption="Support"
            width="100%"/>
</htmlBox>
@import "../helium/helium";

@mixin helium-extended {
  @include helium;
  .box-container {
    text-align: center;
  }

  .box-container .logo {
    width: 500px;
    margin: 50px auto;
  }

  .button-container {
    width: 500px;
    margin: 0 auto;
  }

  .button-container .sample-button {
    width: 166px;
    display: inline-block;
    vertical-align: top;
  }

  .box-container .button-container {
    width: 500px;
    margin: 0 auto;
    text-align: left;
  }

  .html-sample {
    white-space: nowrap;
    position: relative;
  }

  .button-container .sample-button:first-child .v-widget {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    margin-left: 3px;
  }

  .button-container .sample-button .v-widget {
    vertical-align: middle;
    margin-left: -4px;
    height: 50px;
    font-size: 20px;
  }

  .button-container .sample-button ~ .sample-button:not(:last-child) .v-widget {
    border-radius: 0;
  }

  .button-container .sample-button:last-child .v-widget {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    margin-left: -8px;
  }
}
html box layout template contents