mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
Update VSCode color theme templates for improved contrast and readability (#931)
* matugen/vscode-theme: update VSCode templates for contrast and readability * vscode-theme: rework dark theme, refine light, restore default fallback * dank16: add variants option, make default vscode consistent, fix termial always dark --------- Co-authored-by: bbedward <bbedward@gmail.com>
This commit is contained in:
@@ -23,6 +23,17 @@ type ColorInfo struct {
|
||||
B int `json:"b"`
|
||||
}
|
||||
|
||||
type VariantColorValue struct {
|
||||
Hex string `json:"hex"`
|
||||
HexStripped string `json:"hex_stripped"`
|
||||
}
|
||||
|
||||
type VariantColorInfo struct {
|
||||
Dark VariantColorValue `json:"dark"`
|
||||
Light VariantColorValue `json:"light"`
|
||||
Default VariantColorValue `json:"default"`
|
||||
}
|
||||
|
||||
type Palette struct {
|
||||
Color0 ColorInfo `json:"color0"`
|
||||
Color1 ColorInfo `json:"color1"`
|
||||
@@ -42,6 +53,25 @@ type Palette struct {
|
||||
Color15 ColorInfo `json:"color15"`
|
||||
}
|
||||
|
||||
type VariantPalette struct {
|
||||
Color0 VariantColorInfo `json:"color0"`
|
||||
Color1 VariantColorInfo `json:"color1"`
|
||||
Color2 VariantColorInfo `json:"color2"`
|
||||
Color3 VariantColorInfo `json:"color3"`
|
||||
Color4 VariantColorInfo `json:"color4"`
|
||||
Color5 VariantColorInfo `json:"color5"`
|
||||
Color6 VariantColorInfo `json:"color6"`
|
||||
Color7 VariantColorInfo `json:"color7"`
|
||||
Color8 VariantColorInfo `json:"color8"`
|
||||
Color9 VariantColorInfo `json:"color9"`
|
||||
Color10 VariantColorInfo `json:"color10"`
|
||||
Color11 VariantColorInfo `json:"color11"`
|
||||
Color12 VariantColorInfo `json:"color12"`
|
||||
Color13 VariantColorInfo `json:"color13"`
|
||||
Color14 VariantColorInfo `json:"color14"`
|
||||
Color15 VariantColorInfo `json:"color15"`
|
||||
}
|
||||
|
||||
func NewColorInfo(hex string) ColorInfo {
|
||||
rgb := HexToRGB(hex)
|
||||
stripped := hex
|
||||
@@ -492,3 +522,54 @@ func GeneratePalette(primaryColor string, opts PaletteOptions) Palette {
|
||||
|
||||
return palette
|
||||
}
|
||||
|
||||
type VariantOptions struct {
|
||||
PrimaryDark string
|
||||
PrimaryLight string
|
||||
Background string
|
||||
UseDPS bool
|
||||
IsLightMode bool
|
||||
}
|
||||
|
||||
func mergeColorInfo(dark, light ColorInfo, isLightMode bool) VariantColorInfo {
|
||||
darkVal := VariantColorValue{Hex: dark.Hex, HexStripped: dark.HexStripped}
|
||||
lightVal := VariantColorValue{Hex: light.Hex, HexStripped: light.HexStripped}
|
||||
|
||||
defaultVal := darkVal
|
||||
if isLightMode {
|
||||
defaultVal = lightVal
|
||||
}
|
||||
|
||||
return VariantColorInfo{
|
||||
Dark: darkVal,
|
||||
Light: lightVal,
|
||||
Default: defaultVal,
|
||||
}
|
||||
}
|
||||
|
||||
func GenerateVariantPalette(opts VariantOptions) VariantPalette {
|
||||
darkOpts := PaletteOptions{IsLight: false, Background: opts.Background, UseDPS: opts.UseDPS}
|
||||
lightOpts := PaletteOptions{IsLight: true, Background: opts.Background, UseDPS: opts.UseDPS}
|
||||
|
||||
dark := GeneratePalette(opts.PrimaryDark, darkOpts)
|
||||
light := GeneratePalette(opts.PrimaryLight, lightOpts)
|
||||
|
||||
return VariantPalette{
|
||||
Color0: mergeColorInfo(dark.Color0, light.Color0, opts.IsLightMode),
|
||||
Color1: mergeColorInfo(dark.Color1, light.Color1, opts.IsLightMode),
|
||||
Color2: mergeColorInfo(dark.Color2, light.Color2, opts.IsLightMode),
|
||||
Color3: mergeColorInfo(dark.Color3, light.Color3, opts.IsLightMode),
|
||||
Color4: mergeColorInfo(dark.Color4, light.Color4, opts.IsLightMode),
|
||||
Color5: mergeColorInfo(dark.Color5, light.Color5, opts.IsLightMode),
|
||||
Color6: mergeColorInfo(dark.Color6, light.Color6, opts.IsLightMode),
|
||||
Color7: mergeColorInfo(dark.Color7, light.Color7, opts.IsLightMode),
|
||||
Color8: mergeColorInfo(dark.Color8, light.Color8, opts.IsLightMode),
|
||||
Color9: mergeColorInfo(dark.Color9, light.Color9, opts.IsLightMode),
|
||||
Color10: mergeColorInfo(dark.Color10, light.Color10, opts.IsLightMode),
|
||||
Color11: mergeColorInfo(dark.Color11, light.Color11, opts.IsLightMode),
|
||||
Color12: mergeColorInfo(dark.Color12, light.Color12, opts.IsLightMode),
|
||||
Color13: mergeColorInfo(dark.Color13, light.Color13, opts.IsLightMode),
|
||||
Color14: mergeColorInfo(dark.Color14, light.Color14, opts.IsLightMode),
|
||||
Color15: mergeColorInfo(dark.Color15, light.Color15, opts.IsLightMode),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ func GenerateJSON(p Palette) string {
|
||||
return string(marshalled)
|
||||
}
|
||||
|
||||
func GenerateVariantJSON(p VariantPalette) string {
|
||||
marshalled, _ := json.Marshal(p)
|
||||
return string(marshalled)
|
||||
}
|
||||
|
||||
func GenerateKittyTheme(p Palette) string {
|
||||
var result strings.Builder
|
||||
fmt.Fprintf(&result, "color0 %s\n", p.Color0.Hex)
|
||||
|
||||
Reference in New Issue
Block a user