Initial commit: VoIdeaAI - voice-first AI idea assistant
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
"""Generate CSS custom properties from design tokens."""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
_FILE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(_FILE_DIR)))
|
||||
TOKENS_PATH = os.path.join(ROOT, "docs", "design-system", "tokens.json")
|
||||
OUTPUT_PATH = os.path.join(ROOT, "app", "design-tokens", "css", "theme.css")
|
||||
|
||||
|
||||
def load_tokens() -> dict:
|
||||
with open(TOKENS_PATH, encoding="utf-8-sig") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def generate(tokens: dict) -> str:
|
||||
lines = [
|
||||
"/* Auto-generated from design tokens — do not edit manually */",
|
||||
":root {",
|
||||
]
|
||||
|
||||
for color_name, shades in tokens.get("colors", {}).items():
|
||||
if isinstance(shades, dict):
|
||||
for shade, value in shades.items():
|
||||
if shade != "system":
|
||||
if shade == "default":
|
||||
lines.append(f" --color-{color_name}: {value};")
|
||||
elif shade == "hover":
|
||||
lines.append(f" --color-{color_name}-hover: {value};")
|
||||
else:
|
||||
lines.append(f" --color-{color_name}-{shade}: {value};")
|
||||
|
||||
for family_name, value in tokens.get("typography", {}).get("font_family", {}).items():
|
||||
lines.append(f" --font-{family_name}: {value};")
|
||||
|
||||
for size_name, value in tokens.get("typography", {}).get("size", {}).items():
|
||||
lines.append(f" --font-size-{size_name}: {value};")
|
||||
|
||||
for space_name, value in tokens.get("spacing", {}).items():
|
||||
lines.append(f" --spacing-{space_name}: {value};")
|
||||
|
||||
for radius_name, value in tokens.get("border_radius", {}).items():
|
||||
lines.append(f" --radius-{radius_name}: {value};")
|
||||
|
||||
lines.append("}")
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
|
||||
def main():
|
||||
tokens = load_tokens()
|
||||
css = generate(tokens)
|
||||
os.makedirs(os.path.dirname(OUTPUT_PATH), exist_ok=True)
|
||||
with open(OUTPUT_PATH, "w", encoding="utf-8") as f:
|
||||
f.write(css)
|
||||
print(f"Written: {OUTPUT_PATH}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user