aboutsummaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/ColorScheme.ts7
-rw-r--r--src/shared/messages.ts2
-rw-r--r--src/shared/settings/Properties.ts23
-rw-r--r--src/shared/settings/Settings.ts3
-rw-r--r--src/shared/settings/schema.json4
-rw-r--r--src/shared/settings/validate.js45
6 files changed, 77 insertions, 7 deletions
diff --git a/src/shared/ColorScheme.ts b/src/shared/ColorScheme.ts
new file mode 100644
index 0000000..a7b874e
--- /dev/null
+++ b/src/shared/ColorScheme.ts
@@ -0,0 +1,7 @@
+enum ColorScheme {
+ System = "system",
+ Light = "light",
+ Dark = "dark",
+}
+
+export default ColorScheme;
diff --git a/src/shared/messages.ts b/src/shared/messages.ts
index f876b99..60d4c9e 100644
--- a/src/shared/messages.ts
+++ b/src/shared/messages.ts
@@ -127,7 +127,7 @@ export interface ConsoleGetPropertiesMessage {
type: typeof CONSOLE_GET_PROPERTIES;
}
-export type ConsoleRequesttabsResponse = {
+export type ConsoleRequestTabsResponse = {
index: number;
flag: TabFlag;
title: string;
diff --git a/src/shared/settings/Properties.ts b/src/shared/settings/Properties.ts
index cf10d61..7540c8a 100644
--- a/src/shared/settings/Properties.ts
+++ b/src/shared/settings/Properties.ts
@@ -1,20 +1,23 @@
+import ColorScheme from "../ColorScheme";
+
export type PropertiesJSON = {
hintchars?: string;
smoothscroll?: boolean;
complete?: string;
+ colorscheme?: ColorScheme;
};
export type PropertyTypes = {
hintchars: string;
smoothscroll: string;
complete: string;
+ colorscheme: string;
};
-type PropertyName = "hintchars" | "smoothscroll" | "complete";
+type PropertyName = "hintchars" | "smoothscroll" | "complete" | "colorscheme";
type PropertyDef = {
name: PropertyName;
- description: string;
defaultValue: string | number | boolean;
type: "string" | "number" | "boolean";
};
@@ -22,28 +25,31 @@ type PropertyDef = {
const defs: PropertyDef[] = [
{
name: "hintchars",
- description: "hint characters on follow mode",
defaultValue: "abcdefghijklmnopqrstuvwxyz",
type: "string",
},
{
name: "smoothscroll",
- description: "smooth scroll",
defaultValue: false,
type: "boolean",
},
{
name: "complete",
- description: "which are completed at the open page",
defaultValue: "sbh",
type: "string",
},
+ {
+ name: "colorscheme",
+ defaultValue: ColorScheme.System,
+ type: "string",
+ },
];
const defaultValues = {
hintchars: "abcdefghijklmnopqrstuvwxyz",
smoothscroll: false,
complete: "sbh",
+ colorscheme: ColorScheme.System,
};
export default class Properties {
@@ -53,18 +59,23 @@ export default class Properties {
public complete: string;
+ public colorscheme: ColorScheme;
+
constructor({
hintchars,
smoothscroll,
complete,
+ colorscheme,
}: {
hintchars?: string;
smoothscroll?: boolean;
complete?: string;
+ colorscheme?: ColorScheme;
} = {}) {
this.hintchars = hintchars || defaultValues.hintchars;
this.smoothscroll = smoothscroll || defaultValues.smoothscroll;
this.complete = complete || defaultValues.complete;
+ this.colorscheme = colorscheme || defaultValues.colorscheme;
}
static fromJSON(json: PropertiesJSON): Properties {
@@ -76,6 +87,7 @@ export default class Properties {
hintchars: "string",
smoothscroll: "boolean",
complete: "string",
+ colorscheme: "string",
};
}
@@ -92,6 +104,7 @@ export default class Properties {
hintchars: this.hintchars,
smoothscroll: this.smoothscroll,
complete: this.complete,
+ colorscheme: this.colorscheme,
};
}
}
diff --git a/src/shared/settings/Settings.ts b/src/shared/settings/Settings.ts
index 1bb9249..6f178ea 100644
--- a/src/shared/settings/Settings.ts
+++ b/src/shared/settings/Settings.ts
@@ -156,7 +156,8 @@ export const DefaultSettingJSONText = `{
"properties": {
"hintchars": "abcdefghijklmnopqrstuvwxyz",
"smoothscroll": false,
- "complete": "sbh"
+ "complete": "sbh",
+ "colorscheme": "system"
},
"blacklist": [
]
diff --git a/src/shared/settings/schema.json b/src/shared/settings/schema.json
index 31d47f1..be0f2ec 100644
--- a/src/shared/settings/schema.json
+++ b/src/shared/settings/schema.json
@@ -48,6 +48,10 @@
},
"complete": {
"type": "string"
+ },
+ "colorscheme": {
+ "type": "string",
+ "enum": ["system", "light", "dark"]
}
}
},
diff --git a/src/shared/settings/validate.js b/src/shared/settings/validate.js
index 236488d..30f7888 100644
--- a/src/shared/settings/validate.js
+++ b/src/shared/settings/validate.js
@@ -1,4 +1,5 @@
'use strict';
+var equal = require('ajv/lib/compile/equal');
var validate = (function() {
var pattern0 = new RegExp('.*');
var refVal = [];
@@ -273,6 +274,46 @@ var validate = (function() {
}
var valid2 = errors === errs_2;
}
+ if (valid2) {
+ var data2 = data1.colorscheme;
+ if (data2 === undefined) {
+ valid2 = true;
+ } else {
+ var errs_2 = errors;
+ if (typeof data2 !== "string") {
+ validate.errors = [{
+ keyword: 'type',
+ dataPath: (dataPath || '') + '.properties.colorscheme',
+ schemaPath: '#/properties/properties/properties/colorscheme/type',
+ params: {
+ type: 'string'
+ },
+ message: 'should be string'
+ }];
+ return false;
+ }
+ var schema2 = validate.schema.properties.properties.properties.colorscheme.enum;
+ var valid2;
+ valid2 = false;
+ for (var i2 = 0; i2 < schema2.length; i2++)
+ if (equal(data2, schema2[i2])) {
+ valid2 = true;
+ break;
+ } if (!valid2) {
+ validate.errors = [{
+ keyword: 'enum',
+ dataPath: (dataPath || '') + '.properties.colorscheme',
+ schemaPath: '#/properties/properties/properties/colorscheme/enum',
+ params: {
+ allowedValues: schema2
+ },
+ message: 'should be equal to one of the allowed values'
+ }];
+ return false;
+ }
+ var valid2 = errors === errs_2;
+ }
+ }
}
}
} else {
@@ -535,6 +576,10 @@ validate.schema = {
},
"complete": {
"type": "string"
+ },
+ "colorscheme": {
+ "type": "string",
+ "enum": ["system", "light", "dark"]
}
}
},