feat(@projects/@magic-civilization): 🎨 theme type-variations — inheritance targets for override→inheritance migration (p2-87)

Foundation for collapsing the ~188 add_theme_color_override calls onto Godot
Theme inheritance. Adds a `typeVariations` section to design-tokens.json and
emits each as a Godot type variation in ui_theme.tres.

9 Label variations covering the high-count font_color override patterns:
LabelTitle/Muted/Secondary/Disabled/Positive/Negative/Warning/Gold/Science
(→ text.title/muted/secondary/disabled, semantic.positive/negative/warning,
accent.gold/science). Widgets set `theme_type_variation = "LabelMuted"` to
inherit instead of `add_theme_color_override("font_color", ...)`.

Additive — nothing consumes them yet, zero visual change. Verified: variations
baked into ui_theme.tres, theme --check clean, headless load exit 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Natalie 2026-06-19 02:45:59 -05:00
parent 6f89d0faaa
commit 54767fbd98
3 changed files with 40 additions and 0 deletions

View file

@ -567,5 +567,17 @@
},
"breakpoint": {
"mobile": { "$value": "768px", "$type": "dimension", "$description": "Guide app mobile breakpoint" }
},
"typeVariations": {
"_doc": "Godot Theme type variations (p2-87). Widgets set theme_type_variation to INHERIT a font colour instead of calling add_theme_color_override. base = base widget type; fontColor = a color token name resolved at build time. Emitted into ui_theme.tres by build-ui-theme.py.",
"LabelTitle": { "base": "Label", "fontColor": "text.title" },
"LabelMuted": { "base": "Label", "fontColor": "text.muted" },
"LabelSecondary": { "base": "Label", "fontColor": "text.secondary" },
"LabelDisabled": { "base": "Label", "fontColor": "text.disabled" },
"LabelPositive": { "base": "Label", "fontColor": "semantic.positive" },
"LabelNegative": { "base": "Label", "fontColor": "semantic.negative" },
"LabelWarning": { "base": "Label", "fontColor": "semantic.warning" },
"LabelGold": { "base": "Label", "fontColor": "accent.gold" },
"LabelScience": { "base": "Label", "fontColor": "accent.science" }
}
}

View file

@ -126,3 +126,21 @@ ItemList/styles/selected = SubResource("StyleBoxFlat_item_list_selected")
ItemList/styles/selected_focus = SubResource("StyleBoxFlat_item_list_selected")
RichTextLabel/colors/default_color = Color(0.878431, 0.847059, 0.784314, 1)
RichTextLabel/font_sizes/normal_font_size = 14
LabelDisabled/base_type = &"Label"
LabelDisabled/colors/font_color = Color(0.501961, 0.501961, 0.4, 0.501961)
LabelGold/base_type = &"Label"
LabelGold/colors/font_color = Color(0.85098, 0.627451, 0.12549, 1)
LabelMuted/base_type = &"Label"
LabelMuted/colors/font_color = Color(0.698039, 0.698039, 0.698039, 1)
LabelNegative/base_type = &"Label"
LabelNegative/colors/font_color = Color(0.85098, 0.34902, 0.25098, 1)
LabelPositive/base_type = &"Label"
LabelPositive/colors/font_color = Color(0.4, 0.901961, 0.4, 1)
LabelScience/base_type = &"Label"
LabelScience/colors/font_color = Color(0.4, 0.74902, 1, 1)
LabelSecondary/base_type = &"Label"
LabelSecondary/colors/font_color = Color(0.74902, 0.717647, 0.65098, 1)
LabelTitle/base_type = &"Label"
LabelTitle/colors/font_color = Color(0.94902, 0.85098, 0.45098, 1)
LabelWarning/base_type = &"Label"
LabelWarning/colors/font_color = Color(0.901961, 0.6, 0.2, 1)

View file

@ -347,6 +347,16 @@ def build_theme_text(tokens: dict) -> str:
f"RichTextLabel/font_sizes/normal_font_size = {fs_sm}",
]
# Type variations (p2-87): inheritance targets so widgets can set
# theme_type_variation instead of add_theme_color_override. Skips _doc.
variations = tokens.get("typeVariations", {})
for vname in sorted(variations):
if vname.startswith("_"):
continue
spec: dict = variations[vname]
resource_lines.append('%s/base_type = &"%s"' % (vname, spec["base"]))
resource_lines.append("%s/colors/font_color = %s" % (vname, c(spec["fontColor"])))
parts = [
f'[gd_resource type="Theme" format=3 uid="{THEME_UID}"]',
"",