Alert
ui.widgets.AlertRetour persistant dans la page.
BEHAVIOR CONTRACT
info / success / warning / error, avec ou sans titre, gardent une même mise en page.
RECORDED INTERACTION
Montre les quatre niveaux de gravité.
// ── Alert ──
pub fn buildAlert(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
const a = cx.allocator;
const c = try col(cx, 12);
// 全 4 变体,且都带 closable(× 关闭按钮)
try c.appendChild(a, try W.Alert(.{ .variant = .info, .title = "Info", .message = "Informational message.", .closable = true }).mount(scope, cx));
try c.appendChild(a, try W.Alert(.{ .variant = .success, .title = "Success", .message = "It worked.", .closable = true }).mount(scope, cx));
try c.appendChild(a, try W.Alert(.{ .variant = .warning, .title = "Warning", .message = "Be careful.", .closable = true }).mount(scope, cx));
try c.appendChild(a, try W.Alert(.{ .variant = .@"error", .title = "Error", .message = "Something broke.", .closable = true }).mount(scope, cx));
// 无标题(仅 message)
try c.appendChild(a, try W.Alert(.{ .variant = .info, .message = "Title-less alert with just a message." }).mount(scope, cx));
return c;
}Le code source tel quel de la story dans le Storybook (zenit 5f9add5+wip 2026-09-30). W désigne ui.widgets ; col / row / label sont de petits helpers de mise en page du Storybook.
AlertProps
ui.widgets.Alertfn Alert(props: AlertProps) AlertBuilderChamp
Type
Défaut
Description
variantAlertVariant.info.success.warning.@"error".info—
title?[]const u8null—
message[]const u8""—
closableboolfalse—
on_close?core.HandlerRefnull—
close_icon_asset?svg_assets.Assetnull—
*Node
ui.widgets.Alertmount renvoie directement *Node : ajoutez-le à un parent.