Current section
Files
Jump to
Current section
Files
lib/mead/style.ex
defmodule Mead.Style do
@moduledoc """
Visual and layout styling for a node.
Lengths are in PDF points. Colors are `{r, g, b}` tuples of 0-255 integers.
Text properties (`color`, `font_size`, `line_height`, `font_family`,
`font_weight`, `italic`, `text_align`) are inheritable: `nil` means "inherit from the
parent", with document defaults of black 14pt/1.2 regular in the default
family at the root.
`orphans`/`widows` (also inheritable, default 2 like CSS) set the minimum
number of text lines kept before / carried after a page break inside a
text node; a paragraph that cannot satisfy them moves to the next page.
At the top of a page an unsatisfiable rule breaks geometrically instead
(progress is never sacrificed). `1` disables the constraint.
"""
defstruct flex_direction: :column,
width: nil,
height: nil,
min_width: nil,
min_height: nil,
max_width: nil,
max_height: nil,
flex_grow: nil,
flex_shrink: nil,
flex_basis: nil,
padding: 0.0,
margin: 0.0,
gap: 0.0,
align_items: nil,
justify_content: nil,
align_self: nil,
border: 0.0,
border_color: nil,
border_radius: 0.0,
background: nil,
font_size: nil,
line_height: nil,
font_family: nil,
font_weight: nil,
italic: nil,
text_align: nil,
color: nil,
orphans: nil,
widows: nil
@type color :: {0..255, 0..255, 0..255}
@typedoc """
A length in points, or `{:percent, n}` with CSS-style `n` (50 = 50%).
"""
@type dimension :: number() | {:percent, number()}
@typedoc "Uniform, or per-side in CSS order {top, right, bottom, left}."
@type sides :: number() | {number(), number(), number(), number()}
@type alignment :: :start | :end | :center | :stretch | :baseline
@type justify :: :start | :end | :center | :space_between | :space_around | :space_evenly
@type t :: %__MODULE__{
flex_direction: :row | :column,
width: dimension() | nil,
height: dimension() | nil,
min_width: dimension() | nil,
min_height: dimension() | nil,
max_width: dimension() | nil,
max_height: dimension() | nil,
flex_grow: number() | nil,
flex_shrink: number() | nil,
flex_basis: number() | nil,
align_items: alignment() | nil,
justify_content: justify() | nil,
align_self: alignment() | nil,
border: sides(),
border_color: color() | nil,
border_radius: number(),
padding: sides(),
margin: sides(),
gap: number(),
background: color() | nil,
font_size: number() | nil,
line_height: number() | nil,
font_family: String.t() | nil,
font_weight: number() | :normal | :bold | nil,
italic: boolean() | nil,
text_align: :left | :center | :right | :justify | nil,
color: color() | nil,
orphans: pos_integer() | nil,
widows: non_neg_integer() | nil
}
end