ziex/test/data/component/multiple.zx

34 lines
905 B
Zig

pub fn Page(allocator: zx.Allocator) zx.Component {
return (
<main @allocator={allocator}>
<Button title="Submit" />
<Button title="Cancel" />
<AsyncScore index={1} label="Score" />
<AsyncScore index={2} label="Points" />
<AsyncScore index={3} label="Rating" />
</main>
);
}
const ButtonProps = struct { title: []const u8 };
fn Button(allocator: zx.Allocator, props: ButtonProps) zx.Component {
return (
<button @allocator={allocator}>
{props.title}
</button>
);
}
const AsyncScoreProps = struct { index: u64, label: []const u8 };
fn AsyncScore(allocator: zx.Allocator, props: AsyncScoreProps) zx.Component {
return (
<span @allocator={allocator}>
{props.label}
#
{[props.index:d]}
</span>
);
}
const zx = @import("zx");