summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-03-29 16:09:44 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-03-29 16:09:44 +0900
commit8ce5366e80176e94f636e569eca726fafc7024fc (patch)
treeb0a76cd515c2b4ace4291768736361f359e2a393 /src/client
parentBetter sql log (diff)
downloadmisskey-8ce5366e80176e94f636e569eca726fafc7024fc.tar.gz
misskey-8ce5366e80176e94f636e569eca726fafc7024fc.tar.bz2
misskey-8ce5366e80176e94f636e569eca726fafc7024fc.zip
テーマ関係
Diffstat (limited to 'src/client')
-rw-r--r--src/client/theme.ts26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/client/theme.ts b/src/client/theme.ts
index cc69ee4060..2f4920e3af 100644
--- a/src/client/theme.ts
+++ b/src/client/theme.ts
@@ -27,7 +27,7 @@ export const builtinThemes = [
require('./themes/danboard.json5'),
require('./themes/olive.json5'),
require('./themes/tweetdeck.json5'),
-];
+] as Theme[];
let timeout = null;
@@ -66,16 +66,21 @@ export function applyTheme(theme: Theme, persist = true) {
}
}
-function compile(theme: Theme): { [key: string]: string } {
- function getColor(code: string): tinycolor.Instance {
- // ref
- if (code[0] == '@') {
- return getColor(theme.props[code.substr(1)]);
+function compile(theme: Theme): Record<string, string> {
+ function getColor(val: string): tinycolor.Instance {
+ // ref (prop)
+ if (val[0] === '@') {
+ return getColor(theme.props[val.substr(1)]);
+ }
+
+ // ref (const)
+ else if (val[0] === '$') {
+ return getColor(theme.props[val]);
}
// func
- if (code[0] == ':') {
- const parts = code.split('<');
+ else if (val[0] === ':') {
+ const parts = val.split('<');
const func = parts.shift().substr(1);
const arg = parseFloat(parts.shift());
const color = getColor(parts.join('<'));
@@ -87,12 +92,15 @@ function compile(theme: Theme): { [key: string]: string } {
}
}
- return tinycolor(code);
+ // other case
+ return tinycolor(val);
}
const props = {};
for (const [k, v] of Object.entries(theme.props)) {
+ if (k.startsWith('$')) continue; // ignore const
+
props[k] = genValue(getColor(v));
}