diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..463cb39 --- /dev/null +++ b/index.ts @@ -0,0 +1,137 @@ + +export const schema = { + get v1() { + return structuredClone(require('./schema/v1.json')); + } +}; + +export function load_theme(name: string) { + if (name.includes('/')) { + return null; + } + + return structuredClone(require(`./themes/${name}/theme.json`)); +} + +export type ColorThemeLabel + = 'light' + | 'dark' + | 'high_contrast' + | 'low_contrast' + | 'monochrome' + | 'greyscale' + | 'protanopia_safe' + | 'deuteranopia_safe' + | 'tritanopia_safe' + ; + +export interface ColorTheme { + $schema: ''; + + /** The name of the color theme as it should be displayed to a user */ + name: string; + + /** + * The labels field allows for categorizing color themes into high-level groupings + * like "light", "dark", or "high_contrast". This is purely meta-information that is + * intended to be used by applications to display color theme options with groupings + * or other indicators to the user in configuration interfaces + */ + labels?: ColorThemeLabel[]; + + // todo: clean up, organize, comment this list + colors: { + sun: string; + moon: string; + + bg_main: string; + bg_light: string; + bg_heavy: string; + bg_popup_mask: string; + + line: string; + line_safe: string; + line_warn: string; + line_danger: string; + + text_heading: string; + text_body: string; + text_light: string; + text_safe: string; + text_warn: string; + text_danger: string; + text_link: string; + text_link_active: string; + text_link_visited: string; + + bg_qrcode: string; + stroke_qrcode: string; + + text_highlight: string; + bg_text_highlight: string; + text_selection: string; + bg_text_selection: string; + + bg_button_primary: string; + bg_button_primary_hover: string; + text_button_primary: string; + bg_button_secondary: string; + bg_button_secondary_hover: string; + text_button_secondary: string; + + bg_error_box: string; + border_error_box: string; + text_error_box: string; + + bg_input: string; + border_input: string; + border_input_invalid: string; + + icon_active_indicator: string; + icon_success_indicator: string; + icon_failure_indicator: string; + icon_warning_indicator: string; + + accent_info: string; + accent_highlight: string; + accent_warning: string; + accent_problem: string; + + chart_axis: string; + chart_text: string; + chart_guideline: string; + chart_data_0: string; + chart_data_1: string; + chart_data_2: string; + chart_data_3: string; + chart_data_4: string; + chart_data_5: string; + chart_data_6: string; + chart_data_7: string; + chart_data_8: string; + chart_data_9: string; + + code_normal: string; + code_shadow: string; + code_background: string; + code_selection: string; + code_comment: string; + code_punc: string; + code_operator: string; + code_const_literal: string; + code_number_literal: string; + code_boolean_literal: string; + code_tag: string; + code_string: string; + code_keyword: string; + code_func_name: string; + code_class_name: string; + code_regex_important: string; + code_variable: string; + code_builtin: string; + code_attr_name: string; + code_gutter_divider: string; + code_line_number: string; + code_line_highlight: string; + }; +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b4c025b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,49 @@ +{ + "name": "@doc-utils/color-themes", + "version": "0.1.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@doc-utils/color-themes", + "version": "0.1.0", + "devDependencies": { + "@types/node": "^18.16.3", + "typescript": "^5.0.4" + } + }, + "node_modules/@types/node": { + "version": "18.16.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.5.tgz", + "integrity": "sha512-seOA34WMo9KB+UA78qaJoCO20RJzZGVXQ5Sh6FWu0g/hfT44nKXnej3/tCQl7FL97idFpBhisLYCTB50S0EirA==", + "dev": true + }, + "node_modules/typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + } + }, + "dependencies": { + "@types/node": { + "version": "18.16.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.5.tgz", + "integrity": "sha512-seOA34WMo9KB+UA78qaJoCO20RJzZGVXQ5Sh6FWu0g/hfT44nKXnej3/tCQl7FL97idFpBhisLYCTB50S0EirA==", + "dev": true + }, + "typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..7170eb4 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "@doc-utils/color-themes", + "version": "0.1.0", + "publishConfig": { + "registry": "https://gitea.home.jbrumond.me/api/packages/doc-utils/npm/" + }, + "scripts": { + "tsc": "tsc", + "clean": "rm -rf ./index.js ./index.js.map ./index.d.ts ./.tsbuildinfo" + }, + "main": "./index.ts", + "devDependencies": { + "@types/node": "^18.16.3", + "typescript": "^5.0.4" + } + } + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..6e6f141 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "outDir": ".", + "rootDir": ".", + "declaration": true, + "sourceMap": true, + "declarationMap": false, + "incremental": true, + "moduleResolution": "node", + "typeRoots": [ + "node_modules/@types/" + ], + "tsBuildInfoFile": ".tsbuildinfo", + "lib": [ + "es2020" + ] + }, + "exclude": [ + "node_modules", + "build" + ], + "include": [ + "./index.ts" + ] +} \ No newline at end of file