Packages

BEAM-native coding agent substrate for Elixir/OTP projects

Current section

Files

Jump to
vibe lib vibe tui widgets section.ex
Raw

lib/vibe/tui/widgets/section.ex

defmodule Vibe.TUI.Widgets.Section do
@moduledoc "TUI widget: labeled collapsible section."
@behaviour Vibe.TUI.Widget
alias Vibe.Terminal.{Theme, Width}
alias Vibe.TUI.Widget
@impl true
def render(%{props: %{title: title}, children: children}, width, theme) do
header = section_header(title, width, theme)
[header | Enum.flat_map(children, &Vibe.TUI.Widget.render(&1, width, theme))]
end
defp section_header(title, width, theme) do
title = IO.iodata_to_binary(title)
line_len = width - Width.visible_length(title) - 1
[
Theme.fg(theme, :accent, title),
" ",
Theme.fg(theme, :border, Widget.repeat(Theme.symbol(theme, :section_line), line_len))
]
end
end