Service Apps - Global Style

Last modified on 2023/06/29 15:09

The Global Style functionality is used to define all style elements in CSS code in a single place in the app. These elements are shared with the entire app. As such, they can be used in all pages and widgets in the app.

  • The CSS style sheet of the app can be found in the Global Style section in the graphic editor.
  • This section contains an input field where all CSS attributes and classes in the app are defined.
  • The style elements specified in the section are applicable to all pages and widgets in the app.

Operating principle

CSS style elements are placed in the <header> section of the HTML code generated when the app is run.

This means that the graphic style will be loaded before widgets are loaded in the page. This provides a seamless display of graphic elements and reduces app loading times.

          Global style operating principle.png

Notes

  • The <style> tag is predefined in the Global Style section.
  • Responsive mode is not supported by the Global Style functionality. Open url.png See the procedure

Caution

  • For security reasons, you cannot insert tags in the Global Style section.

Best Practice

  • You can override the Global CSS style sheet for specific pages in the app by defining CSS code specific to those pages.
  • To manage CSS code based on the type of device (i.e. desktop, tablet or smartphone) in a given style zone, you can use media query @media screen instructions. Open url.png See the procedure

Access

In the graphic editor > Objects pane > Apps - Global Style icon.png Global Style

Procedures

How to define the Global Style section

Step 1: Open the graphic editor

1. Go to the App Gallery.

2. Click Apps - Application properties icon.png in the app toolbar.
 

Step 2: Add the CSS code for the entire app

1. Click Apps - Global Style icon.png Global Style in the Objects pane.

          Graphic editor - Global style section.png

2. In the CSS Content field, define all of the CSS code to be used in the app.

Best Practice icon.png  Use media query @media screen instructions to manage CSS code based on the type of device. Open url.png See the procedure

How to manage CSS code based on the type of device

Because Responsive mode is not supported by the Global Style functionality, you must use media query @media screen instructions to adapt CSS code based on the type of device where the app will run.

  • Desktop:
@media screen and (min-width: 900px) {... CSS Code ...}
  • Tablet:
@media screen and (min-width: 400px) and (max-width: 900px) {... CSS Code ...}
  • Smartphone:
@media screen and (max-width: 400px) {... CSS Code ...}

example    Define the CSS code applicable to all screens whose width is greater than 900 px

          Example CSS code for desktop.png

Use case

An app is made up of multiple pages, each of which includes a widget displaying the page heading.

          Example application.png

  • Classes are defined for headings and sub-headings.
    • The heading is encapsulated in a CSS class called .pTitle.
    • The sub-heading is encapsulated in a CSS class called .pSub.
  • Graphic elements are added to the Global Style section. Modifications will therefore be automatically propagated to all app headings and sub-headings with these two classes.
  • CSS code associated with the example
   .pTitle {
       font-size: calc(var(--ezv-font-size-1) * 2);
       font-family: var(--ezv-font-family-2);
       margin: 0 !important;
       letter-spacing: 2px;
       color: var(--ezv-font-color-1) !important
    }
    .pSub {
       font-size: calc(var(--ezv-font-size-1));
       font-family: var(--ezv-font-family-3);
       letter-spacing: 2px;
       color: var(--ezv-font-color-2) !important
    }
Tags:
Powered by XWiki © EasyVista 2022