Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3615 from matrix-org/travis/base-theme
Browse files Browse the repository at this point in the history
Add a function to get the "base" theme for a theme
  • Loading branch information
turt2live authored Nov 14, 2019
2 parents 58d15ac + 56ad164 commit 4258a82
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ function getCustomTheme(themeName) {
return customTheme;
}

/**
* Gets the underlying theme name for the given theme. This is usually the theme or
* CSS resource that the theme relies upon to load.
* @param {string} theme The theme name to get the base of.
* @returns {string} The base theme (typically "light" or "dark").
*/
export function getBaseTheme(theme) {
if (!theme) return "light";
if (theme.startsWith("custom-")) {
const customTheme = getCustomTheme(theme.substr(7));
return customTheme.is_dark ? "dark-custom" : "light-custom";
}

return theme; // it's probably a base theme
}

/**
* Called whenever someone changes the theme
*
Expand Down

0 comments on commit 4258a82

Please sign in to comment.