This commit is contained in:
syuilo
2018-09-27 19:14:35 +09:00
parent cc6af402be
commit 459b374d61
5 changed files with 54 additions and 31 deletions

View File

@@ -7,6 +7,7 @@ type Theme = {
id: string;
name: string;
inherit: string;
vars: any;
};
} & {
[key: string]: string;
@@ -34,6 +35,22 @@ function compile(theme: Theme): { [key: string]: string } {
if (code[0] == '@') {
return getColor(theme[code.substr(1)]);
}
if (code[0] == '$') {
return getColor(theme.meta.vars[code.substr(1)]);
}
// func
if (code[0] == ':') {
const parts = code.split('<');
const func = parts.shift().substr(1);
const arg = parseInt(parts.shift(), 10);
const color = getColor(parts.join('<'));
switch (func) {
case 'darken': return color.darken(arg);
case 'lighten': return color.lighten(arg);
}
}
return tinycolor(code);
}