summaryrefslogtreecommitdiff
path: root/src/client/app/common/scripts/theme.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/app/common/scripts/theme.ts')
-rw-r--r--src/client/app/common/scripts/theme.ts21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/client/app/common/scripts/theme.ts b/src/client/app/common/scripts/theme.ts
index 2cad547c01..a08028ff9a 100644
--- a/src/client/app/common/scripts/theme.ts
+++ b/src/client/app/common/scripts/theme.ts
@@ -1,6 +1,23 @@
import * as tinycolor from 'tinycolor2';
+const lightTheme = require('../../../theme/light');
+const darkTheme = require('../../../theme/dark');
+
+type Theme = {
+ meta: {
+ id: string;
+ name: string;
+ inherit: string;
+ };
+} & {
+ [key: string]: string;
+};
+
+export default function(theme: Theme) {
+ if (theme.meta.inherit) {
+ const inherit = [lightTheme, darkTheme].find(x => x.meta.id == theme.meta.inherit);
+ theme = Object.assign({}, inherit, theme);
+ }
-export default function(theme: { [key: string]: string }) {
const props = compile(theme);
Object.entries(props).forEach(([k, v]) => {
@@ -11,7 +28,7 @@ export default function(theme: { [key: string]: string }) {
localStorage.setItem('theme', JSON.stringify(props));
}
-function compile(theme: { [key: string]: string }): { [key: string]: string } {
+function compile(theme: Theme): { [key: string]: string } {
function getColor(code: string): tinycolor.Instance {
// ref
if (code[0] == '@') {