From 7854f4a1ef4d9eeb06fff09a4c88885659c7685f Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Sun, 26 Feb 2023 14:57:43 -0500 Subject: [PATCH] WIP need to finish default styles --- styles/src/themes/common/syntax.ts | 71 ++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 styles/src/themes/common/syntax.ts diff --git a/styles/src/themes/common/syntax.ts b/styles/src/themes/common/syntax.ts new file mode 100644 index 0000000000..6faf48852f --- /dev/null +++ b/styles/src/themes/common/syntax.ts @@ -0,0 +1,71 @@ +import deepmerge from "deepmerge" +import { fontWeights } from "../../common"; + +const defaultSyntaxHighlightStyle: Omit = { + weight: fontWeights.normal, + underline: false, + italic: false +} + +function buildDefaultSyntax(colorScheme: ColorScheme): Syntax { + const syntax: { + [key: string]: Omit + } = {} + + for (const key of Object.keys({} as Syntax)) { + syntax[key as keyof Syntax] = { + ...defaultSyntaxHighlightStyle + } + } + + const color = { + comment: colorScheme.ramps.neutral(0.71).hex() + } + + const defaultSyntax: Syntax = { + ...syntax, + comment: { + color: color.comment + }, + "comment.doc": { + color: color.comment + }, + primary: { + color: colorScheme.ramps.neutral(1).hex() + }, + predictive: { + color: colorScheme.ramps.neutral(0.57).hex() + } + // TODO: Finish default styles + } + + return defaultSyntax +} + +function mergeSyntax(defaultSyntax: Syntax, colorScheme: ColorScheme): Syntax { + if (!colorScheme.syntax) { + return defaultSyntax + } + + return deepmerge>( + defaultSyntax, + colorScheme.syntax, + { + arrayMerge: (destinationArray, sourceArray) => [ + ...destinationArray, + ...sourceArray, + ], + } + ) +} + +import { ColorScheme, Syntax, SyntaxHighlightStyle, ThemeSyntax } from "./colorScheme"; + +export function buildSyntax(colorScheme: ColorScheme): Syntax { + + const defaultSyntax: Syntax = buildDefaultSyntax(colorScheme) + + const syntax = mergeSyntax(defaultSyntax, colorScheme) + + return syntax +} \ No newline at end of file