Tutor Indigo v22.2.0: let every learner theme their own Open edX

A few weeks ago @tutor-maintainers wrote here about making MFE styling easier for operators. This release points the same idea at learners. From the Account page, each learner can choose a Light or Dark appearance and personalize the core colors of the interface. The choice is saved to their account, so it follows them across the micro-frontends and from one device to another.

This is Tutor Indigo v22.2.0, for Verawood.

What learners see

In Account settings, under Profile Information, there is a new theme block. Learners pick an appearance preset, Light or Dark, and if they want, personalize five core Paragon colors. @tutor-maintainers labelled them by what they change rather than by token name:

  • buttons and links
  • button and link highlights
  • brand accents
  • body text
  • navigation links

The appearance preset is saved as soon as it is picked. Colour changes are previewed live and only stored when Save is pressed. Colors are kept separately for each preset, so a learner can run one palette in Light and a different one in Dark.

The light/dark toggle in the header still works the way it always did. It switches between the two presets, and it stays in sync with the Account page in both directions.

Accessibility is built into the picker

While a colour is being edited, the picker shows its contrast ratio against the page background. It measures against both WCAG levels, AA (4.5:1) and AAA (7:1), and draws threshold lines over the picker so the learner can see where those boundaries fall.

Colors below AA are still saved. @tutor-maintainers decided not to block them. A warning names the ones that fall short, and the decision stays with the learner. The colour behind button and link highlights is measured against the body text drawn on it, rather than against the page background, because that is the pairing that actually has to be readable.

If a learner does end up with a theme they cannot read, adding ?indigo-theme-reset=1 to any micro-frontend URL offers to clear their stored colors:

https://apps.example.com/account/?indigo-theme-reset=1

The confirmation is a browser dialog, so it stays legible no matter what colors have been chosen. And because it asks first, a link sent by someone else cannot wipe a learner’s choices silently.

How preferences are stored

Preferences are stored by the indigo_theme Django app. It ships with this plugin, is installed into the openedx image, and serves them from /api/indigo/v1/theme/. The presets table is prefilled with the default token values for the light and dark variants by a database migration.

Settings

Setting Default What it does
INDIGO_ENABLE_DYNAMIC_THEME True Enables the whole feature
INDIGO_ENABLE_DARK_TOGGLE True When off, the Dark preset is not offered and the dark variant is not applied to new choices

Upgrading

pip install --upgrade "tutor-indigo>=22.2.0,<23"
tutor config save
tutor images build openedx mfe
tutor local launch

Both images need rebuilding this time. The openedx image so the Django app is installed and its migrations run, and the mfe image for the settings block itself.

To turn the feature off:

tutor config save --set INDIGO_ENABLE_DYNAMIC_THEME=false
tutor images build openedx mfe
tutor local start -d

Things worth knowing before you upgrade

Nothing changes until a learner changes it. Only the colors a learner has actually chosen get applied. If your site has its own brand CSS, it stays exactly as it is until someone personalizes something.

The settings block needs the legacy Account MFE. It is registered through the only plugin slot that micro-frontend offers for this, additional_profile_fields, which is why it shows up under Profile Information rather than Site Preferences. Sites running the frontend-base version of frontend-app-account will not see the block at all, because the compatibility layer does not map that slot. Learners there can still switch Light and Dark with the header toggle, but they cannot personalize colors.

Legacy Django pages are only partly covered. Their stylesheets are compiled from SASS with literal colors, so a runtime script retints what it can read. In practice that covers the primary color, but not brand accents or navigation links, whose defaults do not appear in the compiled legacy CSS. It is skipped entirely for stylesheets served from another domain, such as a CDN.

Colors apply in every MFE, including the ones Indigo does not otherwise style, because the theme script runs on load rather than waiting for a slot to render.

Checking it works

Sign in, open Account settings, and look for the theme block under Profile Information. Pick Dark, then reload a different micro-frontend. The appearance should follow. Change a color, press Save, and check that the header toggle still flips between your two personalized presets.

Developing

To work on the Django app with a local copy mounted in place of the one from the plugin’s build context:

tutor mounts add ./tutorindigo/templates/indigo_theme

Links

Feedback is welcome, particularly from anyone running the frontend-base Account MFE. That is the gap @tutor-maintainers would most like to close next.

3 Likes