How to work with brand policies

Learn all the technical details about how to make your brand experience happen using a brand policy's HTML, CSS, and Javascript.

Web resource loading

After a no-code component page is loaded, it synchonously loads branding.css and the main Javascript files content and waits until this content is loaded. Once these files have downloaded, the component's page loader spinner appears.

Afterwards the component will load the branding.json along with translation content, if the selected language is not English U.S. (en-US). Once the branding.json has been downloaded, the configured additional script will start.

CSS usage

To make CSS easier to use, each page's block name is added to the app's DOM element. You can use this as a selector to add CSS code to a specific screen.

CSS selector examples

:root {
  // NOTE: You can check all CSS variable when you start typing the following in the CSS code editor: --sty
  --sty-primary-color: #db3725; // Override primary color manually
  --sty-danger-color: #b21f13; // Override danger/error color
  --sty-text-color: #001823; // Override text color
  --sty-link-color: var(--sty-text-color); // Override link color
  --sty-link-decoration: underline;// Override link text decoration style
  --sty-link-hover-color: var(--sty-primary-color); // Override link hover state color
  --sty-link-hover-decoration: underline; // Override link hover state text decoration style
}

#app.login.registration { ... } // If you want to modify registration block design
#app.login [data-section="panelHeader"] { ... } // If you want to modify the login panel header design
#app.login:not(.identifier) [data-section="panelContainer"] { ... } // If you want to modify the login panel container if the current block is not the identifier

sty-input-phone[focused],
sty-input-text[focused],
sty-input-textarea[focused],
sty-select[focused] {
  // Update input-* focused state box shadow
  --sty-input-box-shadow: ...;
}

List of CSS variables

Here are examples of the types of variables that can be used. To see the full list, hit Control + Space keys inside of the brand policy IDE.

CSS VariableDescription
--sty-checkbox-border-widthCheckbox "border-width" property
--sty-tab-slider-colorTab slider "color" property
--sty-calendar-disabled-bgCalendar "background" property
--sty-link-focus-ring-styleApplication link focus-ring "border-style" property
--sty-calendar-weekday-border-colorCalendar navigation weekday "border-color" property
--sty-calendar-cell-disabled-colorCalendar cell disabled state "color" property
--sty-language-selector-colorLanguage selector "color" property
--sty-input-list-bgInput list "background" property
--sty-button-danger-hover-colorButton danger variant hover "color" property
--sty-alert-border-widthAlert "border-width" property
--sty-form-section-description-line-heightForm section description "line-height" property
--sty-button-info-text-focus-colorButton info-text variant focus "color" property
--sty-button-success-outline-disabled-bgButton success-outline variant disabled "background" property
--sty-toast-box-shadowToast "box-shadow" property
--sty-button-success-hover-bgButton success variant hover "background" property
--sty-alert-warning-border-colorAlert warning variant "border-color" property
--sty-bg-sizeApplication "background-size" property
--sty-link-hover-decorationApplication link hover state "text-decoration" property
--sty-empty-state-line-heightEmpty state "line-height" property
--sty-calendar-panel-year-cell-padding-inlineCalendar year cell "padding-inline" property
--sty-button-warning-outline-bgButton warning-outline variant "background" property
--sty-button-info-outline-disabled-border-colorButton info-outline variant disabled "border-color" property
--sty-bgApplication "background" property
--sty-loader-bg-sizeApplication loader "background-size" property
--sty-calendar-cell-hover-colorCalendar cell hover state "color" property
--sty-input-modeInput mode style (united / separated)
--sty-alert-info-bgAlert info variant "background" property
--sty-button-secondary-outline-colorButton secondary-outline variant "color" property
--sty-input-colorInput "color" property
--sty-action-panel-border-radiusAction panel "border-radius" property
--sty-button-warning-text-disabled-colorButton warning-text variant disabled "color" property
--sty-button-success-outline-disabled-border-colorButton success-outline variant disabled "border-color" property
--sty-button-warning-colorButton warning variant "color" property
--sty-button-secondary-text-bgButton secondary-text variant "background" property
--sty-calendar-cell-border-radiusCalendar cell "border-radius" property
--sty-switch-border-styleSwitch "border-style" property
--sty-input-focus-box-shadowInput focus state "box-shadow" property
--sty-h1-font-sizeApplication <h1> "font-size" property
--sty-switch-disabled-thumb-bgSwitch disabled state thumb icon "background" property
--sty-button-info-text-disabled-colorButton info-text variant disabled "color" property
--sty-menu-item-selected-bgMenu item selected "background" property
--sty-switch-border-radius-smSwitch small size "border-radius" property
--sty-calendar-box-shadowCalendar "box-shadow" property
--sty-bg-attachmentApplication "background-attachment" property
--sty-action-panel-bgAction panel base "background" property
--sty-checkbox-focus-ringCheckbox focus-ring "background" property
--sty-dialog-danger-colorDialog danger variant "color" property
--sty-button-focus-ring-offsetButton focus-ring "margin" property
--sty-toast-border-styleToast "border-style" property
--sty-dialog-backdrop-transition-timing-functionDialog backdrop "transition-timing-function" property

JavaScript usage

Events

You can add the following code snippets into the additional script login section.

block-ready

Listen to this event if you want to do something on block change

/**
 * Login "block-ready" event.
 * Fires on every login block change.
 *
 * @event block-ready
 * @property {BlockReadyEvent} event
 */
document.addEventListener('block-ready', (event) => {
	if (event.detail.state.activeBlock === 'identifier') {
		// Do something
	}
});
/**
 *  @typedef {Object} BlockReadyEvent
 *
 *  @property {BlockReadyDetail} detail - CustomEvent detail object.
 */
/**
 *  @typedef {Object} BlockReadyDetail
 *
 *  @property {State} state - Current state.
 *  @property {State} previousState - Previous state.
 */
/**
 *  @typedef {Object} State
 *
 *  @property {string} activeBlock - activeBlock value of state.
 *  @property {Object.<string, Object>} blocks - Stores the state blocks and their data.
 *  @property {Object.<string, Object>} formValues - Stores the previous or actual state form values.
 *  @property {Object.<string, Message>} messages - Stores the global or field specific messages.
 *  @property {Account} account - Stores the login identified account information.
 *  @property {Organization} organization - Stores the login identified organization information.
 */
/**
 *  @typedef {Object} Message
 *
 *  @property {string} text - Text of the message.
 *  @property {string} type - Type of the message. (Possible values: error, info)
 */
/**
 *  @typedef {Object} Account
 *
 *  @property {string} identifier - Identified account. (Email or username)
 */
/**
 *  @typedef {Object} Organization
 *
 *  @property {string} name - Identified organization name.
 */

block-request

Listen to this event if you want to do something right after we call

/**
 * Login "block-request" event.
 * Fires on every login block request.
 *
 * @event block-request
 * @property {BlockRequestEvent} event
 */
document.addEventListener('block-request', (event) => {
	if (event.detail.previousState.activeBlock === 'identifier') {
		// Do something if an identifier block request response is returned
	}
});
/**
 *  @typedef {Object} BlockRequestEvent
 *
 *  @property {BlockRequestDetail} detail - CustomEvent detail object.
 */
/**
 *  @typedef {Object} BlockRequestDetail
 *
 *  @property {State} state - Current state.
 *  @property {State} previousState - Previous state.
 *  @property {string} block - Name of the block that started the request.
 *  @property {Object} request - Request data.
 *  @property {Object} response - Response to the request.
 */
/**
 *  @typedef {Object} State
 *
 *  @property {string} activeBlock - activeBlock value of state.
 *  @property {Object.<string, Object>} blocks - Stores the state blocks and their data.
 *  @property {Object.<string, Object>} formValues - Stores the previous or actual state form values.
 *  @property {Object.<string, Message>} messages - Stores the global or field specific messages.
 *  @property {Account} account - Stores the login identified account information.
 *  @property {Organization} organization - Stores the login identified organization information.
 */
/**
 *  @typedef {Object} Message
 *
 *  @property {string} text - Text of the message.
 *  @property {string} type - Type of the message. (Possible values: error, info)
 */
/**
 *  @typedef {Object} Account
 *
 *  @property {string} identifier - Identified account. (Email or username)
 */
/**
 *  @typedef {Object} Organization
 *
 *  @property {string} name - Identified organization name.
 */