feat: themes
This commit is contained in:
@@ -21,6 +21,7 @@ from uframe.ir import (
|
||||
IRNode, Field, Password, Radio, Checkbox, FormButton,
|
||||
Source, IfBlock, ForLoop, OnSubmit, StateDecl, CacheControl,
|
||||
)
|
||||
from uframe.themes import get_theme, ThemeDef
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -79,7 +80,7 @@ def _micron_form_line(node: IRNode) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def compile(source: str, width: int = 64) -> CompileResult:
|
||||
def compile(source: str, width: int = 64, theme: str = "") -> CompileResult:
|
||||
"""Compile a µFrame .uf source string into ASCII and Micron output.
|
||||
|
||||
Args:
|
||||
@@ -102,6 +103,10 @@ def compile(source: str, width: int = 64) -> CompileResult:
|
||||
|
||||
w = page.width
|
||||
|
||||
# 1b. Resolve theme (CLI flag overrides source directive)
|
||||
theme_name = theme or page.theme_name or "default"
|
||||
theme_def = get_theme(theme_name)
|
||||
|
||||
# 2. Measure
|
||||
measure(page, w)
|
||||
|
||||
@@ -110,7 +115,7 @@ def compile(source: str, width: int = 64) -> CompileResult:
|
||||
|
||||
# 4. Create grid and paint
|
||||
grid = CharGrid(w, max(total_h, 1))
|
||||
paint(page, grid)
|
||||
paint(page, grid, theme_def)
|
||||
|
||||
# 5. Merge borders
|
||||
merge_borders(grid)
|
||||
|
||||
Reference in New Issue
Block a user