Plushie.Type.Border (Plushie v0.6.0)

Copy Markdown View Source

Border specification for container and widget styling.

A border has three properties:

  • color - hex color string (e.g. "#ff0000"). nil means no color override.
  • width - border width in pixels. Default: 0.
  • radius - corner radius. Either a uniform number or a per-corner radius_map() from radius/4. Default: 0.

Wire format

The encoded border is a map:

%{color: "#ff0000", width: 2, radius: 8}

Radius can be a uniform number or a per-corner map:

%{top_left: 8, top_right: 8, bottom_right: 0, bottom_left: 0}

Example

border = Plushie.Type.Border.new()
         |> Plushie.Type.Border.color("#3366ff")
         |> Plushie.Type.Border.width(2)
         |> Plushie.Type.Border.rounded(8)

Summary

Types

Per-corner radius map.

t()

Border specification with color, width, and radius.

Functions

Sets the border color. Accepts a hex string or named color atom.

Encodes a border to the wire format.

Constructs a Border from a keyword list.

Creates a new border with default values (no color, zero width, zero radius).

Sets a uniform corner radius in pixels.

Sets the border width in pixels.

Types

radius_map()

@type radius_map() :: %{
  top_left: number(),
  top_right: number(),
  bottom_right: number(),
  bottom_left: number()
}

Per-corner radius map.

t()

@type t() :: %Plushie.Type.Border{
  color: Plushie.Type.Color.t() | nil,
  radius: number() | radius_map(),
  width: number()
}

Border specification with color, width, and radius.

Functions

color(border, color)

@spec color(border :: t(), color :: Plushie.Type.Color.input()) :: t()

Sets the border color. Accepts a hex string or named color atom.

encode(border)

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

Encodes a border to the wire format.

from_opts(opts)

@spec from_opts(opts :: keyword()) :: t()

Constructs a Border from a keyword list.

new()

@spec new() :: t()

Creates a new border with default values (no color, zero width, zero radius).

radius(top_left, top_right, bottom_right, bottom_left)

@spec radius(
  top_left :: number(),
  top_right :: number(),
  bottom_right :: number(),
  bottom_left :: number()
) :: radius_map()

Creates a per-corner radius map.

rounded(border, radius)

@spec rounded(border :: t(), radius :: number()) :: t()

Sets a uniform corner radius in pixels.

width(border, width)

@spec width(border :: t(), width :: number()) :: t()

Sets the border width in pixels.