Skip to main content

Theme presets

A theme preset is a named set of custom property values that an admin designs on Admin → Theme → Presets, as Design and apply a theme in the admin area describes. An organization keeps up to 50 presets, and at most one of them is applied to its users at a time. This page describes how a preset is stored, what the API accepts, how the app applies a theme and which properties the editor lists.

What is stored​

The API stores the presets of an organization in the settings document of its entity_theme_settings row, next to the grouping colors. The document has two keys for presets:

KeyValue
presetsThe list of the organization's presets.
active_presetThe uuid of the applied preset, or null when the FINOS theme applies.

Each preset has four fields:

FieldValue
uuidThe preset's identifier, which is a UUID.
nameThe preset's name, between 1 and 60 characters after trimming. It is unique within the organization, without regard to case.
lightAn object of custom property declarations that the app applies on :root.
darkAn object of custom property declarations that the app applies on .dark.

In light and in dark, each key is a property name and each value is a CSS value. A rule on :root also applies in the dark theme, so a property that dark does not hold keeps its light value there, as Theme scopes and cascade describes.

What the server accepts​

The API refuses a preset that breaks one of these rules with the status 422:

RuleLimit
The name of a propertyIt must match ^--[a-z][a-z0-9-]{0,80}$.
The value of a propertyIt has 1 to 200 characters, taken from letters, digits, the space and the characters # % . , ( ) / _ + * " ' -. The text url( is refused in any letter case.
The declarations in light or in darkThere may be at most 400 of them.
The presets of an organizationThere may be at most 50 of them.

Routes​

Every route under /admin needs a user of type Admin. FINOS Workspace API lists the other routes, and FINOS Workspace API schemas lists the request and response types.

RouteWhat it does
GET /admin/theme-presetsIt returns presets and active_preset.
PUT /admin/theme-presets/{preset_uuid}It creates the preset or replaces it, and it answers 409 when another preset already has the name.
DELETE /admin/theme-presets/{preset_uuid}It deletes the preset, and it sets active_preset to null when the deleted preset was applied. It answers 404 for an unknown preset.
PUT /admin/theme-presets/activeIt applies the preset that {"uuid": ...} names, or the FINOS theme when the value is null. It answers 404 for an unknown preset.
PATCH /admin/theme-settingsIt stores the grouping colors, and it leaves presets and active_preset as they are.
GET /app/theme-settingsIt returns the grouping colors and properties, which holds the light and dark declarations of the applied preset, or null when none applies. Any signed-in user may call it.

The sign-in response and the dashboard sync carry the same properties in their entity_theme_settings, so the app applies the theme without a request of its own.

How the app applies a theme​

The app adds two style elements to head, which are style[data-theme="saved"] and style[data-theme="preview"]. Each of them has a :root rule and a .dark rule. The app sets the declarations through the CSS object model, one property at a time, so that a value never becomes stylesheet text.

Four layers decide what a user sees, and a later layer wins over an earlier one at equal specificity:

  1. The base stylesheets, tokens.css and index.css, come first.
  2. The theme stylesheet that WL_STYLESHEET names comes second.
  3. The element style[data-theme="saved"] holds the applied preset. The app fills it when it loads and when a user signs in, and again after an admin applies or changes a preset.
  4. The element style[data-theme="preview"] holds the values that are in the editor. It holds values only while the Presets tab is open. While it does, the saved layer is empty, so that a preset chosen in the editor stands alone and does not inherit from the applied one.

The sign-in page loads before the app knows any organization, so it shows only the first two layers.

What the editor lists​

The editor lists every custom property that tokens.css and index.css declare on :root or on .dark, except --text-scale, which the font size setting drives. It arranges them in groups:

GroupWhat it holds
BrandThe --color-main-* steps, --font-family and --radius.
Palette: rampThe steps of one ramp of the color palette.
One group for each prefixThe semantic properties that share a prefix, such as btn or tab.
BaseThe base properties of index.css.

In dark mode, the editor shows a property's value as the dark theme gets it. That is the preset's dark value if there is one, otherwise the preset's light value, otherwise the dark declaration of the base stylesheets, and otherwise the light declaration of the base stylesheets.