Add a theme part

This procedure explains how to add a new theme part to a customization project.

About this task

A theme part can set:

  • theme variables
  • resources
  • conditions

Theme parts can be defined as global (for all customizations in a project) or local (within a specific customization).

Tip:

To ease migration, it is recommended that you use local theme parts. The migration process has you copy only the gbc-project-dir/customization directory when migrating to a new gbc-project-dir.

Before you begin

  • You must understand how customization works.
  • You must have a project directory, which includes a theme folder at gbc-project-dir/theme. This directory contains the collection of global theme parts. Each theme part is saved in its own directory.
  • You must have a customization project, which includes a theme folder at gbc-project-dir/customization/customization-project-dir/theme. This directory contains the collection of local theme parts. Each theme part is saved in its own directory.
  1. Determine whether you are creating a local or global theme part. The decision will identify which directory you are working in:
    • gbc-project-dir/theme for global theme parts.
    • gbc-project-dir/customization/customization-project-dir/theme for local theme parts.
    Tip:

    To ease migration, it is recommended that you use local theme parts. The migration process has you copy only the gbc-project-dir/customization directory when migrating to a new gbc-project-dir.

  2. Create the root folder for the theme part.

    The content that you put in the root folder will depend on what you need to customize.

    For example, let us set up for a local theme part that we will call "foo". We would navigate to customization-project-dir/theme/ and create the directory foo. Within this folder, we could add directories and files, as listed in Table 1.

    Table 1. Directories and files for theme parts
    Directory or file Description
    foo A theme part folder named "foo".
    foo/resources Folder containing theme resources, such as images and fonts. Any and all theme part resources can be stored here, to include html and JavaScript files (if necessary).
    foo/resources/img The subdirectory containing images.
    foo/sass Folder containing Cascading Style Sheet files for instructing the browser how to display specific widgets. You can change colors, font, how text is layed out, and so on.
    foo/sass/theme.scss Entries here modify the stylesheet. While you can add css details directly into this file, a preferred method is to use the @import statement to import other stylesheets contained in the sass folder. For example, if you had a file named myHeader.scss in the theme's sass folder, you would include @import "myHeader" at the top of the theme.scss file.
    foo/theme.config.json Details any conditions and identifies any custom widgets for the theme part.
    foo/theme.scss.json Defines any theme variables for the theme part.

    We would not necessarily add all the folders and files for every theme part we create. If you examine the theme parts that come with the default installation, you will see that they contain only those files and folders needed.

What to do next

Once you define the theme part, you are ready to add it to one or more themes.