Skip to main content

Themes and colors

The widgets can get their colors, font and light or dark mode from several places. This page explains what those places are, which one wins when they disagree, and how to give a single widget its own look.

Coming soon

Styling a single widget with data-theme-mode and data-theme-palette is not in production yet. Everything marked with πŸ”œ on this page describes that upcoming feature. The global layers (built-in defaults, operator theme and lookAndFeel) are available today.

The short version​

Think of it as layers of paint. The widgets start with a base coat, and every layer painted on top covers what is underneath, but only where it actually adds paint. If a layer only sets the main color, the font and the background from the layers below stay exactly as they were.

So the rule to remember is:

The layer painted last wins, but only for the things it sets.

The layers, from bottom to top​

#LayerWho sets itWhere
1Built-in defaultsGamanzaInside the widgets, you can't change it
2Operator themeYour Gamanza Engage teamGamanza Engage settings (widgets_theme)
3lookAndFeelYou, the websiteThe configuration passed to GamanzaEngageClient.init
4Light or dark mode πŸ”œYou, per widgetdata-theme-mode on the widget's div
5Per-widget colors and theme πŸ”œYou, per widgetdata-theme-palette on the widget's div

Layers 1 to 3 apply to every widget on the page. Layers 4 and 5 apply only to the widget whose div has them.

1. Built-in defaults​

This is what you see if nobody customizes anything: the default font, the purple main color (#8743FF), and the standard error, warning and success colors.

2. Operator theme​

A theme saved in the Gamanza Engage backoffice settings for your brand. If it exists, it is painted over the defaults for all widgets. You don't need to send anything from your website for it to apply.

3. lookAndFeel​

The lookAndFeel object you send in the configuration when you initialize the widgets. It is painted over the operator theme, so anything you put here wins over layers 1 and 2. This is the normal way to brand all the widgets at once. See Look and feel for the available options.

4. Light or dark mode for one widget (data-theme-mode) πŸ”œβ€‹

Add data-theme-mode="light" or data-theme-mode="dark" to a widget's div to switch only that widget to light or dark mode.

<div
class="gamification_widget"
data-type="missions"
data-theme-mode="dark"
></div>

Choosing a mode sets the background and text colors to the standard ones for that mode:

ModeMain backgroundCard backgroundText
light#FFFFFF#FAFAFA#495057
dark#2A2A2A#19191A#FFFFFF

Your main color and font from lookAndFeel are kept, because the mode doesn't touch them.

5. Colors or a full theme for one widget (data-theme-palette) πŸ”œβ€‹

Add data-theme-palette to a widget's div to give that widget its own colors. This is the top layer, so it wins over everything else. The value is written as JSON, inside single quotes so the double quotes of the JSON don't break the HTML.

The simplest form is a list of colors:

<div
class="gamification_widget"
data-type="tournaments"
data-theme-palette='{"mode":"dark","primary":{"main":"#14B8A6"}}'
></div>

You can also pass a bigger theme object, with keys like palette, typography or shape, using the same format as lookAndFeel:

<div
class="gamification_widget"
data-type="reward-shop"
data-theme-palette='{"palette":{"primary":{"main":"#FF5500"}},"typography":{"fontFamily":"Georgia"}}'
></div>

Which mode wins? πŸ”œβ€‹

A widget's light or dark mode is decided by the first of these that is set:

  1. mode inside data-theme-palette
  2. data-theme-mode
  3. The widget's own default. Only the sidebar's collapsed bar has one, and it is dark

If none of them is set, the widget uses whatever mode the global layers (1 to 3) end up with, for example the mode in your lookAndFeel palette.

So this widget ends up light, because the JSON wins over the attribute:

<div
class="gamification_widget"
data-type="missions"
data-theme-mode="dark"
data-theme-palette='{"mode":"light"}'
></div>

A worked example πŸ”œβ€‹

Suppose you set this in your configuration:

lookAndFeel: {
typography: { fontFamily: '"Times New Roman"' },
palette: {
primary: { main: '#C10230' },
background: { default: '#FFF4E5' },
},
},

And you place these two widgets on the page:

<div class="gamification_widget" data-type="reward-shop"></div>

<div
class="gamification_widget"
data-type="missions"
data-theme-mode="dark"
></div>

This is what you get:

WidgetFontMain colorBackground
reward-shopTimes New Roman#C10230#FFF4E5, from lookAndFeel
missionsTimes New Roman#C10230#2A2A2A, from dark mode

The missions widget keeps your font and your main color, but dark mode replaces the background because it is painted on top of lookAndFeel.

Good to know​

  • The sidebar's collapsed bar is dark by default. πŸ”œ Soon you'll be able to add data-theme-mode or data-theme-palette to the sidebar's div to change it.
  • Changes apply live. πŸ”œ If you change data-theme-mode or data-theme-palette on a widget that is already on the page, the widget updates itself. You don't need to call reload or reloadOne.
  • Pop-ups follow their widget. πŸ”œ A dialog opened from a widget uses that widget's theme.
  • Small messages don't. πŸ”œ The short pop-up messages (snackbars) that appear outside the widgets always use the global theme, layers 1 to 3.
  • Mistakes are ignored, not fatal. πŸ”œ If data-theme-mode isn't light or dark, or data-theme-palette isn't valid JSON, the widget ignores that value, keeps working, and writes a warning in the browser console.
NOTE

Once available, the per-widget attributes give you the same power as lookAndFeel, so the same care applies: check that icons and text are still readable with the colors you choose, especially when mixing light and dark widgets on one page.