AshReports.Layout.IR.Style (ash_reports v0.1.0)

Intermediate Representation for styling properties.

StyleIR contains normalized styling information that can be applied to labels, fields, and other content elements.

Examples

style = AshReports.Layout.IR.Style.new(
  font_size: "12pt",
  font_weight: :bold,
  color: "#333333",
  font_family: "Helvetica"
)

Summary

Functions

Returns true if the style has any non-nil values.

Merges two styles, with the second style taking precedence.

Creates a new StyleIR struct with the given options.

Types

font_weight()

@type font_weight() :: :normal | :bold | :light | :medium | :semibold

t()

@type t() :: %AshReports.Layout.IR.Style{
  background_color: String.t() | nil,
  border: String.t() | nil,
  color: String.t() | nil,
  font_family: String.t() | nil,
  font_size: String.t() | nil,
  font_style: :normal | :italic | nil,
  font_weight: font_weight() | nil,
  padding: String.t() | nil,
  text_align: :left | :center | :right | :justify | nil,
  vertical_align: :top | :middle | :bottom | nil
}

Functions

empty?(style)

@spec empty?(t()) :: boolean()

Returns true if the style has any non-nil values.

merge(base, override)

@spec merge(t(), t()) :: t()

Merges two styles, with the second style taking precedence.

Only non-nil values from the second style override the first.

Examples

iex> base = AshReports.Layout.IR.Style.new(font_size: "12pt", color: "black")
iex> override = AshReports.Layout.IR.Style.new(color: "red")
iex> AshReports.Layout.IR.Style.merge(base, override)
%AshReports.Layout.IR.Style{font_size: "12pt", color: "red", ...}

new(opts \\ [])

@spec new(Keyword.t()) :: t()

Creates a new StyleIR struct with the given options.

Options

  • :font_size - Font size (e.g., "12pt", "1em")
  • :font_weight - Font weight (:normal, :bold, :light, etc.)
  • :font_style - Font style (:normal, :italic)
  • :color - Text color (e.g., "#333333", "red")
  • :background_color - Background color
  • :font_family - Font family name
  • :text_align - Horizontal text alignment
  • :vertical_align - Vertical text alignment
  • :padding - Padding value
  • :border - Border specification

Examples

iex> AshReports.Layout.IR.Style.new(font_size: "14pt", font_weight: :bold)
%AshReports.Layout.IR.Style{font_size: "14pt", font_weight: :bold, ...}