Issho.Color (Issho v0.1.0)

Copy Markdown View Source

The colours of the people of a room.

An actor's own colour goes to other people's browsers, so only a plain CSS colour passes (sanitize/1). An actor with no colour gets an index into the theme's palette (index/1, 1 to 8, the same for a key in every browser and node): the theme decides the colours, so Sumi and a dark mode can choose their own (--issho-person-1 … --issho-person-8).

Summary

Functions

The palette index of a key, from 1 to 8.

The number of colours in a theme's palette.

The colour if it is a plain CSS colour, else nil.

Functions

index(key)

@spec index(String.t()) :: pos_integer()

The palette index of a key, from 1 to 8.

iex> Issho.Color.index("user:4") in 1..8
true

palette_size()

@spec palette_size() :: pos_integer()

The number of colours in a theme's palette.

sanitize(color)

@spec sanitize(term()) :: String.t() | nil

The colour if it is a plain CSS colour, else nil.

iex> Issho.Color.sanitize("#2563eb")
"#2563eb"
iex> Issho.Color.sanitize("red; background: url(x)")
nil