Fix nested components - render functions now return i32

Changes:
- Component render functions return i32 (root element) instead of void
- Nested components (yield SomeComponent()) now work correctly
- Added main() entry point that calls top-level component and sets root
- Updated runtime to call main() instead of render_ComponentName()

Note: Active state in ternary expressions still needs reactive updates
This commit fixes the nested component rendering issue

All tests passing (51 passed, 2 skipped)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Aaron SinclairandClaude committed 2025-11-15 11:16:23 -08:00
1 parent adf95f424d
commit b0e38db22c
26 files changed
+2310 -1222

No files matched your search

+20 -44
View File
@@ -20,28 +20,19 @@ def VerticalTabs():
setting_tab = value
with Div(class_="vertical-tabs"):
# Vertical tab menu
# Vertical tab menu - clean ternary syntax!
with Div(class_="vertical-tab-menu"):
if setting_tab == 0:
with Button(class_="vertical-tab active", onclick=lambda: set_setting(0)):
yield "⚙️ General"
else:
with Button(class_="vertical-tab", onclick=lambda: set_setting(0)):
yield "⚙️ General"
with Button(class_='vertical-tab active' if setting_tab == 0 else 'vertical-tab',
onclick=lambda: set_setting(0)):
yield "⚙️ General"
if setting_tab == 1:
with Button(class_="vertical-tab active", onclick=lambda: set_setting(1)):
yield "🔒 Privacy"
else:
with Button(class_="vertical-tab", onclick=lambda: set_setting(1)):
yield "🔒 Privacy"
with Button(class_='vertical-tab active' if setting_tab == 1 else 'vertical-tab',
onclick=lambda: set_setting(1)):
yield "🔒 Privacy"
if setting_tab == 2:
with Button(class_="vertical-tab active", onclick=lambda: set_setting(2)):
yield "🚀 Advanced"
else:
with Button(class_="vertical-tab", onclick=lambda: set_setting(2)):
yield "🚀 Advanced"
with Button(class_='vertical-tab active' if setting_tab == 2 else 'vertical-tab',
onclick=lambda: set_setting(2)):
yield "🚀 Advanced"
# Vertical tab content
with Div(class_="vertical-tab-content"):
@@ -94,34 +85,19 @@ def Tabs(orientation=0): # 0 = horizontal, 1 = vertical
with P(class_="subtitle"):
yield "Beautiful composition with TabMenu and TabPane components"
# Tab menu - ul/li structure with active states
# Tab menu - clean ternary syntax!
with Ul(class_="tab-menu"):
if tab_index == 0:
with Li(class_="tab active"):
with Button(onclick=lambda: set_tab(0)):
yield "🏠 Home"
else:
with Li(class_="tab"):
with Button(onclick=lambda: set_tab(0)):
yield "🏠 Home"
with Li(class_='tab active' if tab_index == 0 else 'tab'):
with Button(onclick=lambda: set_tab(0)):
yield "🏠 Home"
if tab_index == 1:
with Li(class_="tab active"):
with Button(onclick=lambda: set_tab(1)):
yield "👤 Profile"
else:
with Li(class_="tab"):
with Button(onclick=lambda: set_tab(1)):
yield "👤 Profile"
with Li(class_='tab active' if tab_index == 1 else 'tab'):
with Button(onclick=lambda: set_tab(1)):
yield "👤 Profile"
if tab_index == 2:
with Li(class_="tab active"):
with Button(onclick=lambda: set_tab(2)):
yield "⚙️ Settings"
else:
with Li(class_="tab"):
with Button(onclick=lambda: set_tab(2)):
yield "⚙️ Settings"
with Li(class_='tab active' if tab_index == 2 else 'tab'):
with Button(onclick=lambda: set_tab(2)):
yield "⚙️ Settings"
# Tab panes - match/case for clean switching
with Div(class_="tab-content"):