@wise/components-theming
Version:
Provides theming support for the Wise Design system components
52 lines (48 loc) • 1.9 kB
JavaScript
;
var _const = require('./const.js');
/**
* @deprecated "modern" theme is released, you should not need check for "modern" theme anymore
*/
const isThemeModern = theme => true;
const isExtraTheme = theme => _const.extraThemes.includes(theme);
const isForestGreenTheme = theme => theme === _const.extraThemes[0];
const isScreenModeDark = (theme, screenMode) => _const.screenModes[1] === screenMode;
const getThemeClassName = (theme, screenMode) => {
// Personal light is always there by default
const themeClasses = ['np-theme-personal'];
/* eslint-disable functional/immutable-data */
// Personal dark theme
if (theme === 'personal' && screenMode === 'dark') {
themeClasses.push(`np-theme-personal--${screenMode}`);
}
// Personal forest-green and bright-green themes
else if (['forest-green', 'bright-green'].includes(theme)) {
themeClasses.push(`np-theme-personal--${theme}`);
}
// Business light
else if (theme === 'business') {
themeClasses.push(`np-theme-business`);
// Business dark theme
if (screenMode === 'dark') {
themeClasses.push(`np-theme-business--${screenMode}`);
}
}
// Business forest-green and bright-green themes
else if (['business--forest-green', 'business--bright-green'].includes(theme)) {
themeClasses.push(`np-theme-${theme}`);
}
// Platform themes
else if (theme.startsWith('platform')) {
themeClasses.push(`np-theme-${theme}`);
}
/* eslint-enable functional/immutable-data */
return themeClasses.join(' ');
};
const normalizeTheme = theme => theme === 'light' ? 'personal' : theme;
exports.getThemeClassName = getThemeClassName;
exports.isExtraTheme = isExtraTheme;
exports.isForestGreenTheme = isForestGreenTheme;
exports.isScreenModeDark = isScreenModeDark;
exports.isThemeModern = isThemeModern;
exports.normalizeTheme = normalizeTheme;
//# sourceMappingURL=helpers.js.map