Replacing Styles of Backoffice Application

It is possible to replace the standard look and feel of the Backoffice Application. You can change the style sheet used in login page and main application pages including all components.

Follow the steps to replace standard SCSS (or CSS) files for login page and main application page. Create your own SCSS files and amend application configuration, so that it uses your custom files.

Create SCSS

Use Sass and SCSS files to style your Backoffice application.

Context

See an example of changing the login page style using SCSS. (Alternatively, create CSS. For more information, see the Create CSS).

Procedure

  1. Create variables file in the resources/cockpitng/cng/scss directory, for example myextension-variables.scss -variables.scss and define the background color:
    $login-bg: var(--bo-accent-color1);

    The file contains all variables defined for SCSS file. You can also create such variables in other SCSS files.

  2. Create loginpage_myextension.scss file:
    @import "support/extension-variables.scss";
    @import url("login.css");
    
    .login-container,
    .login_grid {
      background-color: $login-bg;
    }
    

    This file replaces styles of the login page.

  3. Create the rest of SCSS files in the similar way. The following is the recommended folder structure:
    |-- resources
    	|-- cockpitng
    		|-- cng
    			|-- css
    				|-- support
    					|-- myextension_variables.scss
    				|-- myextension.scss
    

Create CSS

As an alternative to SCSS, you can use CSS files to style your Backoffice application.

Context

Use the sample CSS files and images to see how to style your application.

Procedure

  1. Create the directory: myextension/resources/cockpitng/cng/css.
  2. Create your custom CSS files in the css folder.
    loginpage_myextension.css
    // Import default login.css
    @import url("login.css"); 
    
    body {
    	background: var(--bo-accent-color6);
    }
    
    .login-container,
    .login_grid {
      background-color: var(--bo-accent-color1);
    }
    

    This file replaces styles of main application page. If you need to modify only part of styles, the best practice is to add @IMPORT url("cockpit.css"); at the beginning of the file.

    mainpage_myextension.css
    // Import default styles in cockpit.css & backoffice.css
    @import url("cockpit.css");
    @import url("backoffice.css");
    
    body {
    	background: var(--bo-base-color);
    }
    
    .yw-systemBarContainer .yw-logoContainer .z-toolbarbutton {
    	display: none;
    }
    
    .yw-systemBarContainer .yw-logoContainer {
    	background: var(--bo-accent-color1);
    	width: 100px;
      height: 32px;
    }
    
    .yw-com_hybris_cockpitng_widgets_common_systembar div.yw-systemBarContainer {
    	background-color: var(--bo-accent-color6);
    }
    

    This file replaces styles of main application page. Go to the backoffice/cng/css/backoffice.css. If need to modify only part of styles, the best practice is to add @IMPORT url("backoffice.css"); at the beginning of file.

    customWidgetsAndEditors.css
    button.yw-toggle-advanced-search {
        background-color: var(--bo-accent-color1);
    }
    
    .yw-toggle-advanced-search {
        width: 100px;
    }
    
    div.ye-default-reference-editor-item-container, div.ye-default-reference-editor-selected-item-container
    {
        background: none repeat scroll 0 0 var(--bo-accent-color2);
    }
    

    This file overrides styles for the advanced search button and selected item container in the Default Reference editor. You can change the styles of widgets and editors in the similar way.

  3. If needed, put the images referred in your CSS files in the images folder: myextension/resources/cockpitng/cng/css/images.

Change Default Configuration

Amend the default configuration to apply the changes.

Procedure

Add the following properties to the project.properties file of your custom extension:
backoffice.cockpitng.mainpage.css=/cng/css/mainpage_myextension.css
backoffice.cockpitng.loginpage.css=/cng/css/loginpage_myextension.css
backoffice.cockpitng.overridewidgetsandeditors.css=/cng/css/customWidgetsAndEditors.css

Configure Fonts

Change the fonts used in Backoffice.

Context

By default, font 72 is used in Backoffice. Other fonts including Open Sans and Roboto are also available. For more information on font 72, see Font 72Information published on SAP site.

In the ZK Framework, you can configure the usage of the Google Font in Atlantic Theme. You can disable it or include it in an alternative way.

In the environments where you can't access Google servers (for example, Backoffice used in intranets), it is necessary to prevent loading Google fonts.

Procedure

  1. Define the environment variable -Dorg.zkoss.theme.atlantic.useGoogleFont.disabled=true, for example in javaoptions of the local.properties file.

    The browser falls back to the next font according to the CSS rules.

  2. Provide an alternative URL for Google fonts.
    1. Define the backoffice.cockpitng.google.fonts.url setting in the local.properties and specify the URL you want to load the fonts from. This setting is empty by default.
    2. Disable Google font by setting the org.zkoss.theme.atlantic.useGoogleFont.disabled=true to allow loading fonts from some other source.

Use Icons

Use icon font in Backoffice.

Context

Backoffice uses icon fonts instead of images. The OOTB icon fonts include SAP Icons and Commerce_BO_extended. All icon names are defined in the fd-icon-settings.scss configuration file.

You’re recommended to implement icon font because of the following reasons:
  • It's in essence simple text. You can use CSS style rules to easily change and modify color and size/resolution, apply box-shadow, and apply CSS animations and transitions.

  • It's able to scale up perfectly to any resolution without any degradation or loss of visual quality.

  • It can change color automatically based on selected theme, no additional effort needed.

Otherwise, you might experience inconsistency between the image icons and the new themes, or additional effort of adding new image icons are needed.

Procedure

  1. Change icons in SCSS/CSS. The best practice is to add font icons in CSS pseudo-class(after/before). The cockpitng-global.scss file provides the _getIconGlyphContentValue() function to fetch icon content by name.

    The sample code adds a search icon in the advanced search button.

  2. Change icons for actions. Change the action configuration parameter <iconUri>:
    • In definition.xml
      <action-definition>
      	<iconUri>{Custom_Icon_Name}</iconUri>
      </action-definition>
      
    • In config.xml
      <y:parameter>
      	<y:name>iconUri</y:name>
      	<y:value>{Custom_Icon_Name}</y:value>
      </y:parameter>
      

Next Steps

Restart the server.

Configure Icons

Backoffice OOTB supports two icon font families, SAP Icons and Commerce-BO-icon. You’re recommended to use these predefined icons when developing extensions, but you can also import and use your own icons in the extensions.

Add new icon font in custom extension

A new extension named iconfont is used as an example.

  1. Put all fonts files into the /cng/css/fonts folder.

  2. Create custom-icons.css in the /cng/css folder.

  3. Import new @font-family custom-icons as the following:
    @font-face
    {
      font-family: "custom-icons";
      font-style: normal;
      font-weight: normal;
      src: src: url("./font/icofont.eot"),
           url("./fonts/icofont.woff2") format("woff2"),
           url("./fonts/icofont.woff") format("woff"),
           url("./font/icofont.ttf") format("truetype"),
           url("./font/icofont.svg#icofont") format("svg");
      /* Better Font Rendering =========== */
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

Edit the local.properties file

In the local.properties file, add the path of the custom-icons.css as the following:

backoffice.cockpitng.custom.iconfont.css=/cng/css/custom-icons.css

Use new icons in different cases

  • Explorer-Tree

    If you want to append some custom navigation nodes to the explorer-tree of Administration Console, for example:

    iconfont-backoffice-config.xml Apply new icons for the first-level nodes (iconfont_treenode_fox and iconfont_treenode_elephant) in explorer-tree by adding the following content in iconfontwidget.scss:
  • Button

    If you want to add display icons for some buttons in the custom widgets, for example:

    iconfontwidget.zul

    Add related classes in the iconfontwidget.scss file:

  • Widget

    If you want to render icons in your widget, for example:

    iconfontwidget.zul
    Add related classes in the iconfontwidget.scss file:
  • Action

    When you implement a new action, you can specify the icon name to the iconUri property. You can find the available icon name from SAP-icons or in your custom icon font family, for example:

    definition.xml
    Add related classes in the iconfontwidget.scss file: