mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
WIP need to finish default styles
This commit is contained in:
parent
6cb35536b3
commit
7854f4a1ef
1 changed files with 71 additions and 0 deletions
71
styles/src/themes/common/syntax.ts
Normal file
71
styles/src/themes/common/syntax.ts
Normal file
|
@ -0,0 +1,71 @@
|
|||
import deepmerge from "deepmerge"
|
||||
import { fontWeights } from "../../common";
|
||||
|
||||
const defaultSyntaxHighlightStyle: Omit<SyntaxHighlightStyle, "color"> = {
|
||||
weight: fontWeights.normal,
|
||||
underline: false,
|
||||
italic: false
|
||||
}
|
||||
|
||||
function buildDefaultSyntax(colorScheme: ColorScheme): Syntax {
|
||||
const syntax: {
|
||||
[key: string]: Omit<SyntaxHighlightStyle, "color">
|
||||
} = {}
|
||||
|
||||
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<Syntax, Partial<ThemeSyntax>>(
|
||||
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
|
||||
}
|
Loading…
Reference in a new issue