apphouse
Version:
Component library for React that uses observable state management and theme-able components.
32 lines (30 loc) • 788 B
text/typescript
import { ApphouseTheme } from '../../styles/defaults/themes.interface';
import { THEMES } from '../presets';
/**
* Function to decide current theme object
* @param theme
* @param themeMode
* @returns
*/
export const getTheme = (theme?: ApphouseTheme, themeMode?: string) => {
let t = theme;
if (!t) {
if (themeMode === 'light') {
t = THEMES.APPHOUSE_LIGHT;
} else {
t = THEMES.APPHOUSE_DARK;
}
}
return t;
};
export const getThemeWithMode = (mode: string, customTheme?: ApphouseTheme) => {
switch (mode) {
// if no custom theme is provided, we default to dark theme
case 'custom':
return customTheme || THEMES.APPHOUSE_DARK;
case 'light':
return THEMES.APPHOUSE_LIGHT;
default:
return THEMES.APPHOUSE_DARK;
}
};