Macaw.Layers.Theme.Extension behaviour (macaw_layers v0.2.2)

Copy Markdown View Source

What an adopter registers beyond the library's vocabulary (spec/04 §3.4), so one theme styles it: palette names in a group of the palette, and names of the color table, each with its default.

defmodule MyApp.Marks do
  @behaviour Macaw.Layers.Theme.Extension
  def name, do: "marks"
  def styles, do: %{lane: {:furniture, %{stroke: %{type: :solid, color: {:color, :lane}}}}}
  def colors, do: %{lane: "#8a8f99"}
end

Macaw.Layers.Theme.new(extensions: [MyApp.Marks])

A theme carries its extensions in extensions, given explicitly and default closed: a palette or color name that neither the library nor an extension has is a fault naming it. The names an extension adds are held to the contracts of their group, its default entries included. Two extensions adding one name, or an extension adding a library name, raise ArgumentError naming both.

Summary

Types

A group of the palette an extension's style joins.

Callbacks

The names it adds to the color table, each with its default value.

The extension's name, for faults.

The palette names it adds, each in a group with its default entry.

Types

group()

@type group() :: :state | :furniture | :modifier

A group of the palette an extension's style joins.

Callbacks

colors()

@callback colors() :: %{required(atom()) => term()}

The names it adds to the color table, each with its default value.

name()

@callback name() :: String.t()

The extension's name, for faults.

styles()

@callback styles() :: %{required(atom()) => {group(), map() | list()}}

The palette names it adds, each in a group with its default entry.