Popup Builder – Advanced Settings

  1. Overview
  2. Extended settings
  3. Custom layouts
  4. Custom styles (aka “Themes”)
  5. Custom styles
  6. A brief word about design modes
  7. The popup HTML
  8. Order of operations
  9. Starting from scratch
  10. Applying custom styles
  11. Deep-dive into CSS properties
  12. Custom layouts
  13. The layout HTML
  14. Changing the position of a layout

Overview

This section provides more information on how to leverage PopUp Builder in your application. If you are just getting started with PopUp Builder, make sure to first review Popup Builder – Getting Started.

Extended settings

What if the default styles and common settings aren’t enough? No worries! In the following sections, we will look at styling your popup to make it look and feel more like the one that you use in your application. We’ll start with some basic concepts and work our way to create a full custom popup workspace.

Custom layouts

We covered the layout set in the previous section. To recap, the layout determines the type of popup (e.g., a bar) and its location on the screen (e.g., bottom). Our research team looked into it, and it turns out, nearly all popups fall into one of the most popular layouts, which we’ve included as presets. But, when that’s not enough, the configuration option customLayout can be used to make minor adjustments to a preset layout or create an entirely new layout from scratch.

Here a preview of the configuration:



workspace: {
  popup: {
    customLayout: {
      ...
    },
  }
}

Custom styles (aka “Themes”)

A theme is simply a set of custom styles that give the popup its look and feel. Separate from your layout, BEE Popup Builder comes with two themes.  The first is our default theme that is loaded when no settings are specified.  We also provide an empty theme that has no styles, which you can use a blank canvas to create your own theme.  This is one of the most powerful features of Popup Builder, and we’ll be covering custom styles in depth below.

Here a preview of the configuration:




workspace: {
  popup: {
    customStyles: {
      ...
    },
  }
}


Custom styles

A brief word about design modes

The popup HTML

To understand the best way to apply your styles, let’s start by inspecting the underlying HTML structure so you can view where BEE will map your styles.

Popup HTML




  


Here is a quick break down of what each div does:

popup-container

This is where you will apply any styles related to how the popup looks, such as border radius, drop shadows, background colors, or padding.

popup-header

The header is sometimes used to add a close icon to a popup or display a title.

popup-content

The div that holds the editable content of the BEE Plugin.

popup-footer

You can use this div to show a traditional footer for your popup or to position some icons outside the popup container (e.g., a close button).

The above HTML structure is represented in your bee config as the following JSON object.




customStyles: {
  container: {},
  header: {},
  content: {},
  footer: {},
  overlay: {},
},   


Add styles to the JSON section that corresponds to the HTML element you want to style.

For example, if you want to apply styles to the div with id popup-container, then you would add the styles to the following JSON:




customStyles: {
  container: {
    ...styles,
  },
},   


We’ll go deeper into styling in the following sections.

Order of operations

You may be wondering at this point if you have to design an entire theme to get started.  Well, you can if you want to, but thanks to the order of operations, you don’t have to.  You can start with our default theme and pass in the styles that you want to override.  Any style you provide will take priority over any of the defaults.

Starting from scratch

We said that you could start from scratch if you want, and the easiest way to do that is by using our theme parameter.  This allows you to avoid overriding every default style and gives you more of an empty canvas to build your own theme.

Example:




beeConfig: {
  workspace: {
    popup: {
      theme: 'custom'
    }
  }
}


Applying custom styles

Now that you have seen what the HTML looks like and have some idea where to apply your styles let’s look at how you get your styles into the editor. The best way to show you is by example, so let’s get started with some common use cases!

Adding a border

Using the schema JSON above and your HTML structure knowledge, you probably guessed that the border is defined on the popup container. Here’s what that would look like:

Example:



workspace: {
  popup: {
    customStyles: {
      container: {
        border: '1px solid black'
      }   
    }
  }
}

Adding a drop shadow

Example:




workspace: {
  popup: {
    customStyles: {
      container: {
        boxShadow: '0 5px 15px rgba(0, 0, 0, 0.5)'
      }
    }
  }
}


Deep-dive into CSS properties

After looking at a couple of samples, you may notice these parameters are looking familiar. That’s because every layer of our schema maps to a layer of HTML with the same name AND can be styled with any valid CSS property.

Basically, CSS properties are the same as CSS used by web developers in style sheets, but instead of dashes to separate words, it uses a camel case.

Example:

The CSS property of the style box-shadow would be boxShadow.

Why not use CSS styles as defined by CSS3 specification directly? Well, simply put, CSS properties are better suited for JSON and can easily be shared with any FE application using the popular React framework.

Custom layouts

The layout HTML

The popup is positioned in the workspace using divs and CSS flexbox. We created a layout structure that mimics an actual HTML page to map your page’s styles to the workspace.

Layout HTML:




Overview

Here is a quick break down of what each div does:

HTML

We will apply the styles placed here to the document HTML tag.

body

We will apply the styles placed here to the HTML body tag

main

This is the main container div of the workspace.

popup-wrapper

The wrapper of the popup is used entirely for positioning the popup within the workspace main div.

Changing the position of a layout

Example:




workspace: {
  popup: {
    layout: 'classic-center',
    customLayout: {
       wrapper: {
        maxWidth: '700px'
      }  
    }
  }
}