ElixirOpentui.Style (ElixirOpentui v0.2.0)

Copy Markdown View Source

Style properties for layout computation, mirroring the Flexbox subset used by ElixirOpentui (no CSS grid, no float).

Summary

Functions

Build a Style from keyword attrs, normalizing shorthand padding/margin.

Types

align_items()

@type align_items() :: :flex_start | :flex_end | :center | :stretch

align_self()

@type align_self() :: :auto | :flex_start | :flex_end | :center | :stretch

border_style()

@type border_style() :: :single | :double | :rounded | :heavy

cursor_style()

@type cursor_style() :: :block | :underline | :bar

dimension()

@type dimension() :: non_neg_integer() | :auto | {:percent, float()}

flex_direction()

@type flex_direction() :: :row | :column | :row_reverse | :column_reverse

flex_wrap()

@type flex_wrap() :: :no_wrap | :wrap | :wrap_reverse

justify_content()

@type justify_content() ::
  :flex_start
  | :flex_end
  | :center
  | :space_between
  | :space_around
  | :space_evenly

position_type()

@type position_type() :: :relative | :absolute

t()

@type t() :: %ElixirOpentui.Style{
  align_items: align_items(),
  align_self: align_self(),
  bg: ElixirOpentui.Color.t() | nil,
  blink: boolean(),
  bold: boolean(),
  border: boolean(),
  border_style: border_style(),
  border_title: String.t() | nil,
  border_title_align: :left | :center | :right,
  bottom: non_neg_integer() | nil,
  cursor_color: ElixirOpentui.Color.t() | nil,
  cursor_style: cursor_style() | nil,
  dim: boolean(),
  fg: ElixirOpentui.Color.t() | nil,
  flex_basis: dimension(),
  flex_direction: flex_direction(),
  flex_grow: number(),
  flex_shrink: number(),
  flex_wrap: flex_wrap(),
  focus_bg: ElixirOpentui.Color.t() | nil,
  focus_border_color: ElixirOpentui.Color.t() | nil,
  focus_fg: ElixirOpentui.Color.t() | nil,
  gap: non_neg_integer(),
  height: dimension(),
  hidden: boolean(),
  inverse: boolean(),
  italic: boolean(),
  justify_content: justify_content(),
  left: non_neg_integer() | nil,
  margin:
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()},
  max_height: dimension(),
  max_width: dimension(),
  min_height: dimension(),
  min_width: dimension(),
  opacity: float(),
  overflow: :visible | :hidden,
  padding:
    {non_neg_integer(), non_neg_integer(), non_neg_integer(), non_neg_integer()},
  position: position_type(),
  right: non_neg_integer() | nil,
  strikethrough: boolean(),
  top: non_neg_integer() | nil,
  underline: boolean(),
  width: dimension(),
  z_index: integer()
}

Functions

from_attrs(attrs)

@spec from_attrs(keyword()) :: t()

Build a Style from keyword attrs, normalizing shorthand padding/margin.