Created a new example that demonstrates what we need for proper string/type support:
**TextInput Example (currently a counter):**
- Initially tried to build reactive text input
- Exposed 5 critical limitations:
1. String signals stored as i32 (should be i8*)
2. F-string interpolation incomplete (f"Count: {count}" → "0")
3. No oninput event (only onclick supported)
4. No event value passing (can't get input.value)
5. No string operations (len, concat, etc.)
**Quick Fix Applied:**
- Added type coercion in _emit_signal_globals()
- String signals default to i32 0 (temporary)
- Bool signals convert True/False to 1/0
- Example now uses counter to demonstrate reactive updates
**TYPE_SYSTEM_ROADMAP.md:**
Complete implementation plan for proper type support:
- Phase 1: Type hints extraction (already works!)
- Phase 2: Typed signals (i32, i8*, i1)
- Phase 3: String interpolation in text nodes
- Phase 4: Generalized event system
- Phase 5: Component parameter type checking
- Phase 6: Delegate/callback types
This example will drive the type system implementation. Once complete,
text input will work with proper string signals and reactive updates.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
124 lines
3.0 KiB
HTML
124 lines
3.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Ritz TextInput Example</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.container {
|
|
background: white;
|
|
padding: 40px;
|
|
border-radius: 16px;
|
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
max-width: 500px;
|
|
width: 100%;
|
|
}
|
|
|
|
h1 {
|
|
color: #667eea;
|
|
margin-bottom: 10px;
|
|
font-size: 32px;
|
|
}
|
|
|
|
.instructions {
|
|
color: #666;
|
|
margin-bottom: 30px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.button-group {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
margin: 30px 0;
|
|
}
|
|
|
|
button {
|
|
width: 60px;
|
|
height: 60px;
|
|
font-size: 32px;
|
|
border: 2px solid #667eea;
|
|
background: white;
|
|
color: #667eea;
|
|
border-radius: 12px;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
font-weight: bold;
|
|
}
|
|
|
|
button:hover {
|
|
background: #667eea;
|
|
color: white;
|
|
transform: scale(1.1);
|
|
}
|
|
|
|
button:active {
|
|
transform: scale(0.95);
|
|
}
|
|
|
|
.counter-display {
|
|
background: #f8f9ff;
|
|
padding: 20px 40px;
|
|
border-radius: 12px;
|
|
border: 3px solid #667eea;
|
|
font-size: 24px;
|
|
font-weight: bold;
|
|
color: #667eea;
|
|
min-width: 150px;
|
|
text-align: center;
|
|
}
|
|
|
|
.todo {
|
|
margin-top: 40px;
|
|
padding-top: 30px;
|
|
border-top: 2px dashed #e0e0e0;
|
|
color: #999;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.todo-list {
|
|
margin-top: 15px;
|
|
padding-left: 25px;
|
|
}
|
|
|
|
.todo-list li {
|
|
color: #666;
|
|
font-size: 13px;
|
|
margin: 8px 0;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
#root {
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="root">Loading...</div>
|
|
|
|
<script src="../runtime/ritz-runtime.js"></script>
|
|
<script>
|
|
RitzRuntime.loadComponent('TextInput.wasm', 'TextInput', 'root')
|
|
.then(() => console.log('✅ TextInput loaded'))
|
|
.catch(err => console.error('❌ Failed to load:', err));
|
|
</script>
|
|
</body>
|
|
</html>
|