AshTui.Theme (AshTui v0.3.1)

Copy Markdown View Source

Color, style, and rich-text constants for the TUI.

Provides a consistent visual palette based on the Ash Framework brand colors. All functions are pure and return a color tuple, an %ExRatatui.Style{}, an %ExRatatui.Text.Span{}, or an %ExRatatui.Text.Line{} โ€” never a side effect.

Colors

Composite Styles

Rich Text

  • brand_title/1 - branded header line ("๐Ÿ”ฅ Ash TUI Explorer ยท breadcrumb")
  • resource_title/1 - dim-domain + bold-resource line for the tabs block
  • key_pill/2 - colored "key" pill %Span{} for footer / help hints
  • dim_span/1 - dim-text descriptor span between pills
  • footer_line/1 - assembles a %Line{} from a list of {keys, label} pairs

Summary

Functions

Ash Framework brand orange.

Returns focused_border_style/0 when focused? is true, unfocused_border_style/0 otherwise.

Branded header line โ€” ๐Ÿ”ฅ Ash TUI Explorer with an optional breadcrumb.

Cornflower blue, used for focused panel borders.

Muted border color for unfocused panels.

Dim span used between key pills in the footer / help.

Muted text color for secondary information.

Cornflower blue border style for the active/focused panel.

Builds a footer %Line{} from a list of {label, description} pairs.

Gold, used for highlights and selected items.

Subtle dark background for selected rows.

Bold gold text on a dark background, used for selected items.

Colored "key" pill โ€” keys render bold over a colored background, used in footer and help hints.

Dark background for modal overlays.

Title line for the detail (tabs) block โ€” the domain prefix renders dim while the bare resource name is bold gold.

Dim border style for inactive/unfocused panels.

Functions

ash_orange()

@spec ash_orange() :: ExRatatui.Style.color()

Ash Framework brand orange.

Examples

iex> AshTui.Theme.ash_orange()
{:rgb, 255, 107, 53}

border_style(focused?)

@spec border_style(boolean()) :: ExRatatui.Style.t()

Returns focused_border_style/0 when focused? is true, unfocused_border_style/0 otherwise.

Examples

iex> AshTui.Theme.border_style(true) == AshTui.Theme.focused_border_style()
true

iex> AshTui.Theme.border_style(false) == AshTui.Theme.unfocused_border_style()
true

brand_title(breadcrumb)

@spec brand_title(String.t()) :: ExRatatui.Text.Line.t()

Branded header line โ€” ๐Ÿ”ฅ Ash TUI Explorer with an optional breadcrumb.

Ash renders in ash_orange/0 bold, TUI in gold/0 bold, Explorer in white, and the breadcrumb in cornflower/0 bold separated by a dim โ”‚.

Examples

iex> %ExRatatui.Text.Line{spans: spans} = AshTui.Theme.brand_title("")
iex> Enum.map(spans, & &1.content)
[" ๐Ÿ”ฅ ", "Ash", " ", "TUI", " ", "Explorer "]

iex> %ExRatatui.Text.Line{spans: spans} = AshTui.Theme.brand_title("User")
iex> Enum.map_join(spans, "", & &1.content)
" ๐Ÿ”ฅ Ash TUI Explorer  โ”‚  User "

cornflower()

@spec cornflower() :: ExRatatui.Style.color()

Cornflower blue, used for focused panel borders.

Examples

iex> AshTui.Theme.cornflower()
{:rgb, 100, 149, 237}

dim_border()

@spec dim_border() :: ExRatatui.Style.color()

Muted border color for unfocused panels.

Examples

iex> AshTui.Theme.dim_border()
{:rgb, 60, 60, 80}

dim_span(text)

@spec dim_span(String.t()) :: ExRatatui.Text.Span.t()

Dim span used between key pills in the footer / help.

Examples

iex> span = AshTui.Theme.dim_span(" navigate")
iex> span.content
" navigate"
iex> span.style.fg == AshTui.Theme.dim_text()
true

dim_text()

@spec dim_text() :: ExRatatui.Style.color()

Muted text color for secondary information.

Examples

iex> AshTui.Theme.dim_text()
{:rgb, 150, 150, 170}

focused_border_style()

@spec focused_border_style() :: ExRatatui.Style.t()

Cornflower blue border style for the active/focused panel.

Examples

iex> style = AshTui.Theme.focused_border_style()
iex> style.fg
{:rgb, 100, 149, 237}

gold()

@spec gold() :: ExRatatui.Style.color()

Gold, used for highlights and selected items.

Examples

iex> AshTui.Theme.gold()
{:rgb, 255, 215, 0}

highlight_bg()

@spec highlight_bg() :: ExRatatui.Style.color()

Subtle dark background for selected rows.

Examples

iex> AshTui.Theme.highlight_bg()
{:rgb, 40, 40, 60}

highlight_style()

@spec highlight_style() :: ExRatatui.Style.t()

Bold gold text on a dark background, used for selected items.

Examples

iex> style = AshTui.Theme.highlight_style()
iex> style.fg
{:rgb, 255, 215, 0}
iex> style.modifiers
[:bold]

key_pill(label, kind \\ :default)

@spec key_pill(String.t(), :default | :quit) :: ExRatatui.Text.Span.t()

Colored "key" pill โ€” keys render bold over a colored background, used in footer and help hints.

Pass :quit for the warning red pill (used for q); any other atom uses the calm cyan pill.

Examples

iex> pill = AshTui.Theme.key_pill("Tab")
iex> pill.style.bg
:cyan
iex> pill.content
" Tab "

iex> pill = AshTui.Theme.key_pill("q", :quit)
iex> pill.style.bg
:red
iex> :bold in pill.style.modifiers
true

overlay_bg()

@spec overlay_bg() :: ExRatatui.Style.color()

Dark background for modal overlays.

Examples

iex> AshTui.Theme.overlay_bg()
{:rgb, 20, 20, 30}

resource_title(name)

@spec resource_title(String.t()) :: ExRatatui.Text.Line.t()

Title line for the detail (tabs) block โ€” the domain prefix renders dim while the bare resource name is bold gold.

Examples

iex> %ExRatatui.Text.Line{spans: spans} =
...>   AshTui.Theme.resource_title("AshDemo.Accounts.User")
iex> Enum.map(spans, & &1.content)
[" ", "AshDemo.Accounts.", "User", " "]

iex> %ExRatatui.Text.Line{spans: [_, _, name, _]} =
...>   AshTui.Theme.resource_title("Bare")
iex> name.content
"Bare"

iex> %ExRatatui.Text.Line{spans: [%{content: only}]} =
...>   AshTui.Theme.resource_title("")
iex> only
" No resource selected "

unfocused_border_style()

@spec unfocused_border_style() :: ExRatatui.Style.t()

Dim border style for inactive/unfocused panels.

Examples

iex> style = AshTui.Theme.unfocused_border_style()
iex> style.fg
{:rgb, 60, 60, 80}