export let terminal_widget_button = (b) => {
let row = attr_or(b, "row", 0)
let col = attr_or(b, "col", 0)
let label = attr_or(b, "label", "Button")
let variant = attr_or(b, "variant", "primary")
let label_cols = length(label) + 4
let cols = attr_or(b, "button_cols", attr_or(b, "cols", label_cols))
let disabled = attr_or(b, "disabled", "false") == "true"
let accent = attr_or(b, "accent_fill", variant == "danger" ? "#ef4444" : (variant == "secondary" ? "#334155" : "#38bdf8"))
let bg = attr_or(b, "background_fill", accent)
let fg = attr_or(b, "foreground_fill", attr_or(b, "label_fill", variant == "secondary" ? "#d7e0ff" : "#0b1020"))
let hover_bg = attr_or(b, "hover_background_fill", "#d7e0ff")
let base_class = attr_or(b, "class", "wdoc-widget-terminal_button")
let control_class = disabled ? "wdoc-terminal-control wdoc-terminal-control-disabled" : "wdoc-terminal-control"
let events = disabled ? [] : [{ trigger = "hover", state = "hovered", mode = "while" }]
[
{
kind = "group",
id = to_string(b.id),
row = row,
col = col,
rows = 1,
cols = cols,
class = base_class + " " + control_class,
cursor = disabled ? "default" : "pointer",
pointer_events = disabled ? "none" : "all",
_wdoc_runtime = "true",
_wdoc_terminal_grid_group = "true",
events = events,
children = [
{
kind = "terminal_surface",
id = to_string(b.id) + "_surface",
row = row,
col = col,
cols = cols,
background_fill = bg,
hover_background_fill = hover_bg,
_wdoc_runtime = "true"
},
{
kind = "terminal_text",
id = to_string(b.id) + "_label",
row = row,
col = col,
cols = cols,
content = "[ " + label + " ]",
foreground_fill = fg,
_wdoc_runtime = "true",
pointer_events = "none"
}
]
}
]
}