Search documentation of Plushie

# Plushie.Widget.RichText.Span (Plushie v0.7.2)

Copy Markdown View Source

A typed span for `Plushie.Widget.RichText`.

Each span carries one segment of text with its own optional styling. Construct one with `new/1` and chain setters, or pass a plain map (the renderer accepts both):

    alias Plushie.Widget.RichText.Span

    Span.new("Hello ")
    |> Span.color("#003366")
    |> Span.size(18.0)
    |> Span.font(Plushie.Type.Font.new(weight: :bold))

Spans are encoded to the wire as maps with snake_case keys. Unset fields are omitted so the renderer falls back to the rich_text widget's default styling for that property.

## Summary

### Types

highlight()

Highlight backdrop drawn behind a span. `background` paints a solid colour; `border` adds a stroke around the highlighted region.

t()

### Functions

color(span, value)

Set the text colour.

encode(span)

Encode a span (or plain map) to its wire form.

font(span, value)

Set the font.

highlight(span, h)

Set the highlight backdrop. Accepts a `Plushie.Type.Color` (background only) or a map with `:background` and/or `:border`.

line_height(span, value)

Set the line height.

link(span, url)

Set a hyperlink URL the renderer emits as `link_click`.

new(text)

Build a span with the given text and no style overrides.

padding(span, value)

Set the padding around the span's text.

size(span, value)

Set the font size (pixels).

strikethrough(span, value)

Toggle the strikethrough decoration.

underline(span, value)

Toggle the underline decoration.

## Types

# highlight()

    @type highlight() :: %{
      optional(:background) => Plushie.Type.Color.t(),
      optional(:border) => Plushie.Type.Border.t()
    }

Highlight backdrop drawn behind a span. `background` paints a solid colour; `border` adds a stroke around the highlighted region.

# t()

    @type t() :: %Plushie.Widget.RichText.Span{
      color: Plushie.Type.Color.t() | nil,
      font: Plushie.Type.Font.t() | nil,
      highlight: highlight() | nil,
      line_height: Plushie.Type.LineHeight.t() | nil,
      link: String.t() | nil,
      padding: Plushie.Type.Padding.t() | nil,
      size: number() | nil,
      strikethrough: boolean() | nil,
      text: String.t(),
      underline: boolean() | nil
    }

## Functions

# color(span, value)

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

Set the text colour.

# encode(span)

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

Encode a span (or plain map) to its wire form.

# font(span, value)

    @spec font(t(), Plushie.Type.Font.t()) :: t()

Set the font.

# highlight(span, h)

    @spec highlight(t(), Plushie.Type.Color.input() | highlight()) :: t()

Set the highlight backdrop. Accepts a `Plushie.Type.Color` (background only) or a map with `:background` and/or `:border`.

# line_height(span, value)

    @spec line_height(t(), Plushie.Type.LineHeight.t() | number() | map()) :: t()

Set the line height.

# link(span, url)

    @spec link(t(), String.t()) :: t()

Set a hyperlink URL the renderer emits as `link_click`.

# new(text)

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

Build a span with the given text and no style overrides.

# padding(span, value)

    @spec padding(t(), Plushie.Type.Padding.t() | number() | map() | list()) :: t()

Set the padding around the span's text.

# size(span, value)

    @spec size(t(), number()) :: t()

Set the font size (pixels).

# strikethrough(span, value)

    @spec strikethrough(t(), boolean()) :: t()

Toggle the strikethrough decoration.

# underline(span, value)

    @spec underline(t(), boolean()) :: t()

Toggle the underline decoration.