Format
This commit is contained in:
+30
-12
@@ -3,8 +3,13 @@ import { font_weights, ThemeConfigInputSyntax, RampSet } from "../common"
|
||||
import { Syntax, SyntaxHighlightStyle, allSyntaxKeys } from "../types/syntax"
|
||||
|
||||
// Apply defaults to any missing syntax properties that are not defined manually
|
||||
function apply_defaults(ramps: RampSet, syntax_highlights: Partial<Syntax>): Syntax {
|
||||
const restKeys: (keyof Syntax)[] = allSyntaxKeys.filter(key => !syntax_highlights[key])
|
||||
function apply_defaults(
|
||||
ramps: RampSet,
|
||||
syntax_highlights: Partial<Syntax>
|
||||
): Syntax {
|
||||
const restKeys: (keyof Syntax)[] = allSyntaxKeys.filter(
|
||||
(key) => !syntax_highlights[key]
|
||||
)
|
||||
|
||||
const completeSyntax: Syntax = {} as Syntax
|
||||
|
||||
@@ -28,23 +33,36 @@ function apply_defaults(ramps: RampSet, syntax_highlights: Partial<Syntax>): Syn
|
||||
// Merge the base syntax with the theme syntax overrides
|
||||
// This is a deep merge, so any nested properties will be merged as well
|
||||
// This allows for a theme to only override a single property of a syntax highlight style
|
||||
const merge_syntax = (baseSyntax: Syntax, theme_syntax_overrides: ThemeConfigInputSyntax): Syntax => {
|
||||
return deepmerge<Syntax, ThemeConfigInputSyntax>(baseSyntax, theme_syntax_overrides, {
|
||||
arrayMerge: (destinationArray, sourceArray) => [
|
||||
...destinationArray,
|
||||
...sourceArray,
|
||||
],
|
||||
})
|
||||
const merge_syntax = (
|
||||
baseSyntax: Syntax,
|
||||
theme_syntax_overrides: ThemeConfigInputSyntax
|
||||
): Syntax => {
|
||||
return deepmerge<Syntax, ThemeConfigInputSyntax>(
|
||||
baseSyntax,
|
||||
theme_syntax_overrides,
|
||||
{
|
||||
arrayMerge: (destinationArray, sourceArray) => [
|
||||
...destinationArray,
|
||||
...sourceArray,
|
||||
],
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/** Returns a complete Syntax object of the combined styles of a theme's syntax overrides and the default syntax styles */
|
||||
export const syntaxStyle = (ramps: RampSet, theme_syntax_overrides: ThemeConfigInputSyntax): Syntax => {
|
||||
export const syntaxStyle = (
|
||||
ramps: RampSet,
|
||||
theme_syntax_overrides: ThemeConfigInputSyntax
|
||||
): Syntax => {
|
||||
const syntax_highlights: Partial<Syntax> = {
|
||||
"comment": { color: ramps.neutral(0.71).hex() },
|
||||
comment: { color: ramps.neutral(0.71).hex() },
|
||||
"comment.doc": { color: ramps.neutral(0.71).hex() },
|
||||
primary: { color: ramps.neutral(1).hex() },
|
||||
emphasis: { color: ramps.blue(0.5).hex() },
|
||||
"emphasis.strong": { color: ramps.blue(0.5).hex(), weight: font_weights.bold },
|
||||
"emphasis.strong": {
|
||||
color: ramps.blue(0.5).hex(),
|
||||
weight: font_weights.bold,
|
||||
},
|
||||
link_uri: { color: ramps.green(0.5).hex(), underline: true },
|
||||
link_text: { color: ramps.orange(0.5).hex(), italic: true },
|
||||
"text.literal": { color: ramps.orange(0.5).hex() },
|
||||
|
||||
Reference in New Issue
Block a user