style(themes): compact TOML formatting and lift semantic colors
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
import os
|
||||
import tomllib
|
||||
import tomli_w
|
||||
from pathlib import Path
|
||||
|
||||
# Get all keys from ThemePalette defaults
|
||||
from src.theme_models import ThemePalette
|
||||
|
||||
default_palette = ThemePalette()
|
||||
ALL_KEYS = list(default_palette.to_dict().keys())
|
||||
|
||||
DARK_SEMANTIC = {
|
||||
"status_success": [80, 255, 80],
|
||||
"status_warning": [255, 152, 48],
|
||||
"status_error": [255, 72, 64],
|
||||
"status_info": [0, 255, 255],
|
||||
"bubble_user": [30, 45, 75],
|
||||
"bubble_ai": [35, 65, 45],
|
||||
"bubble_vendor": [65, 55, 30],
|
||||
"bubble_system": [25, 25, 25],
|
||||
"slice_manual": [255, 165, 0],
|
||||
"slice_auto": [0, 255, 0],
|
||||
"slice_selection": [100, 100, 255],
|
||||
"diff_added": [51, 230, 51],
|
||||
"diff_removed": [230, 51, 51],
|
||||
"diff_header": [77, 178, 255],
|
||||
}
|
||||
|
||||
LIGHT_SEMANTIC = {
|
||||
"status_success": [40, 180, 40],
|
||||
"status_warning": [200, 140, 0],
|
||||
"status_error": [200, 40, 40],
|
||||
"status_info": [40, 100, 200],
|
||||
"bubble_user": [220, 230, 255],
|
||||
"bubble_ai": [220, 255, 220],
|
||||
"bubble_vendor": [255, 240, 200],
|
||||
"bubble_system": [240, 240, 240],
|
||||
"slice_manual": [255, 200, 0],
|
||||
"slice_auto": [80, 255, 80],
|
||||
"slice_selection": [180, 180, 255],
|
||||
"diff_added": [40, 180, 40],
|
||||
"diff_removed": [200, 40, 40],
|
||||
"diff_header": [40, 100, 200],
|
||||
}
|
||||
|
||||
def standardize_theme(path: Path):
|
||||
with open(path, "rb") as f:
|
||||
data = tomllib.load(f)
|
||||
|
||||
name = data.get("name", path.stem)
|
||||
syntax = data.get("syntax_palette", "dark")
|
||||
colors = data.get("colors", {})
|
||||
|
||||
is_light = "light" in name.lower() or syntax == "light"
|
||||
semantic = LIGHT_SEMANTIC if is_light else DARK_SEMANTIC
|
||||
|
||||
# Merge semantic
|
||||
for k, v in semantic.items():
|
||||
if k not in colors:
|
||||
colors[k] = v
|
||||
|
||||
# Ensure all keys are present (optional, but good for completeness)
|
||||
# for k in ALL_KEYS:
|
||||
# if k not in colors:
|
||||
# # We use defaults from ThemePalette anyway, so no need to bloat
|
||||
# pass
|
||||
|
||||
new_data = {
|
||||
"name": name,
|
||||
"syntax_palette": syntax,
|
||||
"description": data.get("description", ""),
|
||||
"colors": colors
|
||||
}
|
||||
|
||||
with open(path, "wb") as f:
|
||||
tomli_w.dump(new_data, f)
|
||||
print(f"Standardized {path}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
themes_dir = Path("themes")
|
||||
for f in themes_dir.glob("*.toml"):
|
||||
standardize_theme(f)
|
||||
Reference in New Issue
Block a user