presets formatting
This commit is contained in:
@@ -25,18 +25,32 @@ def load_preset_file(name: str) -> dict[str, Any]:
|
|||||||
return json.loads(path.read_text(encoding="utf-8"))
|
return json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
|
|
||||||
def build_palette(data: dict[str, Any], flavor: str, accent: str, mode: str) -> PresetPalette:
|
def build_palette(
|
||||||
flavor_entry = next(item for item in data["variants"]["flavors"] if item["id"] == flavor)
|
data: dict[str, Any], flavor: str, accent: str, mode: str
|
||||||
accent_entry = next(item for item in data["variants"]["accents"] if item["id"] == accent)
|
) -> PresetPalette:
|
||||||
|
flavor_entry = next(
|
||||||
|
item for item in data["variants"]["flavors"] if item["id"] == flavor
|
||||||
|
)
|
||||||
|
accent_entry = next(
|
||||||
|
item for item in data["variants"]["accents"] if item["id"] == accent
|
||||||
|
)
|
||||||
flavor_block = flavor_entry.get(mode, {})
|
flavor_block = flavor_entry.get(mode, {})
|
||||||
accent_block = accent_entry.get(flavor, {})
|
accent_block = accent_entry.get(flavor, {})
|
||||||
|
|
||||||
colors = {
|
colors = {
|
||||||
"primary": accent_block.get("primary", "#000000"),
|
"primary": accent_block.get("primary", "#000000"),
|
||||||
"secondary": accent_block.get("secondary", accent_block.get("primary", "#000000")),
|
"secondary": accent_block.get(
|
||||||
"tertiary": accent_block.get("primaryContainer", accent_block.get("surfaceTint", accent_block.get("primary", "#000000"))),
|
"secondary", accent_block.get("primary", "#000000")
|
||||||
|
),
|
||||||
|
"tertiary": accent_block.get(
|
||||||
|
"primaryContainer",
|
||||||
|
accent_block.get("surfaceTint", accent_block.get("primary", "#000000")),
|
||||||
|
),
|
||||||
"neutral": flavor_block.get("background", "#000000"),
|
"neutral": flavor_block.get("background", "#000000"),
|
||||||
"neutral_variant": flavor_block.get("surfaceVariant", flavor_block.get("outline", flavor_block.get("background", "#000000"))),
|
"neutral_variant": flavor_block.get(
|
||||||
|
"surfaceVariant",
|
||||||
|
flavor_block.get("outline", flavor_block.get("background", "#000000")),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
return PresetPalette(
|
return PresetPalette(
|
||||||
|
|||||||
Reference in New Issue
Block a user