Toddy.Iced.Padding (Toddy v0.3.0)

Copy Markdown View Source

Spacing value for the padding prop on containers, buttons, and text inputs.

Maps to iced's Padding struct. Accepts a uniform number, a {vertical, horizontal} tuple, or an explicit four-side map. encode/1 always normalises to the full four-side map.

Summary

Functions

Normalises a padding value to the canonical four-side map with string keys.

Types

t()

@type t() ::
  number()
  | {number(), number()}
  | %{top: number(), right: number(), bottom: number(), left: number()}

Functions

encode(n)

@spec encode(padding :: t()) :: map()

Normalises a padding value to the canonical four-side map with string keys.

Examples

iex> Toddy.Iced.Padding.encode(8)
%{"top" => 8, "right" => 8, "bottom" => 8, "left" => 8}

iex> Toddy.Iced.Padding.encode({4, 12})
%{"top" => 4, "right" => 12, "bottom" => 4, "left" => 12}

iex> Toddy.Iced.Padding.encode(%{top: 1, right: 2, bottom: 3, left: 4})
%{"top" => 1, "right" => 2, "bottom" => 3, "left" => 4}