@scalar/api-client
Version:
the open source API testing client
57 lines (56 loc) • 2.19 kB
JavaScript
import * as t from "monaco-editor";
import { loadCssVariables as i } from "./load-css-variables.js";
const n = "scalar-theme", g = async (d, a) => {
const e = await i(d), r = a ? e.dark : e.light, l = Object.fromEntries(
Object.entries({
"editor.background": "--scalar-background-1",
"editor.foreground": "--scalar-color-1",
"editorLineNumber.foreground": "--scalar-color-3",
"editorLineNumber.activeForeground": "--scalar-color-1",
"editorLineHighlight.background": "--scalar-background-2",
"editorCursor.foreground": "--scalar-color-1",
"editorCursor.background": "--scalar-background-1",
"editor.selectionBackground": "--scalar-background-3",
"editor.inactiveSelectionBackground": "--scalar-background-3",
"editorIndentGuide.background": "--scalar-background-3",
"editorIndentGuide.activeBackground": "--scalar-background-2",
"editorWhitespace.foreground": "--scalar-border-color",
"editorBracketMatch.background": "--scalar-background-3",
"editorBracketMatch.border": "--scalar-color-accent",
"editor.selectionHighlightBackground": "--scalar-background-3",
"editor.hoverHighlightBackground": "--scalar-background-3",
"editorLink.activeForeground": "--scalar-color-3",
"editorOverviewRuler.border": "--scalar-border-color"
}).filter(([c, o]) => !!r[o]).map(([c, o]) => [c, r[o]])
);
t.editor.defineTheme(n, {
base: a ? "vs-dark" : "vs",
inherit: !0,
rules: [
// Default text
{ token: "", foreground: r["--scalar-color-3"] },
// Comments
{
token: "comment",
foreground: r["--scalar-color-2"],
fontStyle: "italic"
},
// Keywords
{
token: "keyword",
foreground: r["--scalar-color-accent"],
fontStyle: "bold"
},
// Numbers
{ token: "number", foreground: r["--scalar-color-purple"] },
// Strings
{ token: "string", foreground: r["--scalar-color-2"] },
// Delimiters (punctuation)
{ token: "delimiter", foreground: r["--scalar-color-3"] }
],
colors: l
}), t.editor.setTheme(n);
};
export {
g as applyScalarTheme
};